Everyone knows that if you’re going to spend a short time someplace, it makes no sense to buy a house there. Short stints are for renting.

If you’re putting down roots for the long haul — say, your children’s growing-up years or your retirement — that’s when it makes financial sense to buy, if you can afford to. By the time you sell the house, years later, much of the money you would have put into rent instead will have become equity, assuming you maintained the house and the real estate market was steady.

The question is, at what point does it become financially advantageous to buy rather than rent?

Zillow’s Breakeven Horizon offers an answer: As of the first quarter 2017, it would take 2 years and 1 month before it would make more sense for someone paying the national median rent to buy a house at the national median value. That answer changes at the individual market level, though. If you live in a place with particularly high home values like Los Angeles, for example, the breakeven point is at 4 years and 7 months.

It’s not necessarily “cheap” to rent in pricey markets, of course. It’s just that higher home values often translate into higher upfront costs to purchase. It takes time to recoup those costs and make the purchase profitable.

The Breakeven Horizon weighs tenants’ monthly rent payments and security deposits against home buyers’ down payments (assuming 20 percent down), mortgage payments (assuming a 30-year, fixed-rate mortgage at today’s prevailing rates), property taxes and home maintenance costs. It assumes that renters invest the 20 percent they would have used for a down payment, along with the property taxes they avoid paying, and make 5 percent on that money annually. The model also takes into account rental and home value appreciation forecasts for each market, among other things.

Your mileage can vary a lot. If you’re a renter who does not save the money you’d otherwise be spending on a down payment, maintenance and taxes, then your Breakeven Horizon will come much sooner than the median, as homeownership turns into a forced savings vehicle. Conversely, if you’re a renter who invests that money and makes more than 5 percent on it, then your personal Breakeven Horizon will be longer than the median.

Buying a house is a personal decision, with financial considerations that go beyond that one, admittedly large, asset. It can also be an emotional choice, and the Breakeven Horizon is just one measure that can help remove some of the guesswork.

Methodology

For buying, Zillow’s Breakeven Horizon assumes a 20 percent down payment, monthly payments on a 30-year fixed rate mortgage at the current interest rate for people with credit ratings between 680 and 740, property taxes, homeowner’s insurance, 3 percent purchase costs, 8 percent selling costs (because that’s how you’d realize the gains), annual maintenance costs equal to 1 percent of your home’s value, and, for condos, 1.2 percent a year in HOA fees. Those costs are offset by home appreciation forecasts and federal tax deductions. For renting, costs include a deposit equal to one month’s rent, rent payments and renter’s insurance. Those costs are offset by 5 percent annual investment gains on the down payment, savings from not paying for things like property taxes. We estimate a unique Breakeven Horizon for up to 3,000 individual homes pulled randomly from each ZIP code and use the Zestimate and Rental Zestimate on the same houses, so we’re able to consider the costs of buying a house against the costs of renting that same house.

Related: