The math is shifting.

By Ian Salisbury
Credit: Getty Images

This article originally appeared on Money

Millennials locked out of the housing market have this consolation: House prices have shot up so quickly that the financial advantage of being a homeowner is fast eroding in many of the most expensive U.S. cities.

"While it's still a better deal to buy, the economic benefit has narrowed to the point that in some places, for some households, the decision to rent or buy a home may be too close to call," says Cheryl Young, an economist at real estate data company Trulia, which tracks the comparative advantage of home-ownership in the 100 largest U.S cities.

The shift has come, she explains, because home prices and interest rates have risen recently, while rents have largely stagnated.

To be sure, owning remains at least a bit cheaper than renting in all 100 of the major cities on Trulia's list. On average, U.S. homeowners can expect to pay 33% less than renters in 2017 for an equivalent dwelling, even after you factor in costs such as payments on a 30-year mortgage, home maintenance, and taxes.

Yet that difference has narrowed sharply from last year, when owners were paying roughly 41% less than renters.

In some popular cities, moreover, the homeowner advantage is close to being erased. Owning was only about 3.5% more cost effective in San Jose, Calif., and 8% in nearby San Francisco. In both Portland, Ore., and New York City, the cost advantage was 22%.

And it wouldn't take that much to erase those homeowner price advantages altogether, the Trulia data shows. Even a 22% difference could be eliminated if home prices continue to outpace rents — or if interest rates rise.

For instance, Trulia's calculations are based on the current average 30-year mortgage rate of 4.1%. If rates climbed 2.7 percentage points to 6.8%, the current homeowner advantage in Portland and New York would disappear completely, Trulia found.

That's not necessarily an outlandish scenario. While mortgage rates have remained low since the 2008 financial crisis, rates around 7% are much closer to the historical norm. Federal Reserve officials, whose control of short-term interest rates gives them some sway over mortgage prices, expect those short-term rates to rise roughly two to three percentage points over the next few years.

WATCH: Paint Your House This Color and It Could Sell For Almost $5,000 More

Trulia's rent vs. buy calculations are based on median homes value and rental prices for April 2017. Trulia also assumed homeowners took out a 30-year mortgage covering 80% of a property's value and lived in the property for seven years.

That seven-year assumption is key, because there is one scenario where it's often cheaper to rent than buy: when you plan to stay in a home for just a couple of years.

In that case, says Young, "one-time costs like the real estate agent's commission and closing costs loom larger — and you benefit less from your home's appreciation."

This Story Originally Appeared On