The buy-vs.-rent calculation, which had shifted in favor of renting during the housing market’s down years, has shifted back again as growing demand for rental units have outstripped the supply.

RealtyTrac’s most recent “buy-or-rent” analysis found that housing payments (including mortgage, insurance and property taxes) were lower than the rent on comparable three-bedroom homes in 66 percent (188) of the 285 counties the company analyzed. But the study also found that the markets in which the scales tipped toward rental were those suffering most from the foreclosure crisis that followed the housing downturn.

On that point (foreclosures), the foreclosure inventory has dropped to its lowest level in nearly eight years, according to a recent CoreLogic report. The number of completed foreclosures on residential properties in May was 19.2 percent below the year-ago level and nearly 65 percent below the September, 2010 peak.

The approximately 490,000 foreclosed homes in May represented 1.3 percent of all homes with mortgages, down from 1.7 percent (676,000 homes) a year ago.