The online listings database calculated the number of years after which buying makes more financial sense than renting by introducing the “breakeven horizon” — the exact time when the costs of renting equal the costs of buying. Past the horizon, buying is financially advantageous.

In Boston, the breakeven horizon was 3.4 years on average in the last quarter of 2014, up slightly from 3.0 years during the same period in 2013. The national average was 1.9 years in the last quarter of 2014, down a smidge from 2.0 in 2013. In most major metro areas, breakeven horizons grew because the pace of home-price appreciation slowed in 2014, according to Zillow.

Within Boston, the horizons ranged from one year in Roxbury to 6.1 years in Back Bay and 7.2 years in Beacon Hill.

Zillow calculated the breakeven horizon by comparing the costs of owning a home versus renting a home after 30 years. The horizon assumes that the home was purchased with a 30-year fixed mortgage and takes into account variables such as inflation rate, property taxes, tax benefits, home appreciation rates, and rental appreciation rates.

Dallas-Fort Worth led the pack of big cities in terms of shortest breakeven horizon with 1.2 years. In Los Angeles, it takes the longest for a purchase to be worth it — 5.1 years.

According to Svenja Gudell, Zillow’s senior director of economic research, the national average of two years is considered an extremely short period. There are two major factors that can affect the breakeven horizon, she said, and they pull the metric in different directions. While “aggressively growing” rents make home-buying more appealing and lowers the breakeven horizon, the slowing of home-appreciation rates increases the breakeven horizon.

This makes forecasting difficult. “In theory, breakeven horizons will continue to climb, but it really depends on what rents will do,” Gudell said.

According to Zillow, Bostonians on average spent 34 percent of their monthly income on rent in the third quarter of 2014, and that number continues to rise.

Still, it doesn’t mean renters will all at once swarm the market for a home. According to Zillow, half of the renters the company surveyed said they can’t buy a home because of poor credit scores or they can’t afford other costs that come with owning a home.

“If the buy versus rent decision were about simple math, we’d likely have millions more homebuyers in the market, because the equation is tilted heavily in favor of buying,” Zillow’s chief economist Stan Humphries said in a statement. “But no matter what the numbers say, buying a home is a huge commitment. Every day, Americans make decisions to buy or rent based on any number of personal dynamics, including preference, flexibility needs, family factors, and yes, financial considerations.”