At what cost, percentage wise, is it better to rent than buy, if you plan on staying at a given location forever?

Buying a home is likely the most expensive purchase you will ever make.

And it’s not always the right decision.

Many factors come into play when deciding whether it makes sense to buy, including: your current cash flow, the local markets, how long you plan to stay, interest rates and potential tax deductions, just to name a few.

But it’s not just about finances: It’s also important to consider the lifestyle ramifications that come with owning a home.

Here’s what people should take into account when deciding whether to take the leap into homeownership:

Your monthly budget
The first step when deciding your housing future is to figure out just how much you can afford to spend.

First calculate how much money you bring in every month. Next, consider what you spend on essentials like food and transportation.

A good rule of thumb is to keep total housing costs ? whether renting or owning ? at around 28%-30% of your gross monthly income.

“You don’t want to bite off more than you can chew,”.

To help make a buy vs rent comparison, Fidelity recommended running a simple price-to-rent ratio: divide a home price by the annual rent of a comparable rental unit. If the ratio is less than 20%, buying is probably a better bet.

And it’s not just home prices. Interest rates will also play a big role.

“When mortgage rates are very low, your buying power is much higher, with rates now that picking up again the dynamic has changing a little bit, said Cheryl Young, senior economist at Trulia.

But other factors should be considered as well when making the buy vs rent decision. For instance, how long do you plan to stay in the area? Typically, the longer you stay in a home, the more financial sense it makes to buy.

Some online calculators can tell you how long you’d need to live in a city to make buying the more affordable option. Look for calculators that include things like insurance, maintenance, home price appreciation and selling costs. While the figures will be assumptions, they can help paint a more accurate financial picture.

In many cities the favor tips to buyers in as little as two years, while in more expensive cities it can take closer to 10 years.

But buying a home is also investment and can be a key component of building wealth. Every mortgage payment means you own more of your home, which you will get back when you sell it (hopefully at a higher price than you paid for it, but that’s not always the case).

“Part of the mortgage payment s is defacto investing into something that appreciates over the long term, and that is a big deal,” said Skylar Olsen, senior economist at Zillow.

The opportunity costs
Buying a home comes with more upfront costs, including a down payment, closing costs and other legal fees. For renters, the upfront cost is typically a month or two of rent for a security deposit. Homeowners also have more reoccurring costs like property taxes, home insurance and maintenance costs.

Renting means you could save all that money for a down payment and closing costs and invest in the stock market instead. The return on that investment could potentially be worth be more than a home’s price appreciation.

“You are sinking a lot of money into a home, which means you aren’t investing in stock market,” said Joe Kirchner, senior economist for

Tax benefits

Homeowners can also take advantage of tax deductions, which can lessen the cost of owning a home. But keep in mind, the newly-passed tax reform dampened some of the deductions. Buyers are now only able to deduct interest on the first $750,000 of mortgage debt on a home. Plus, homeowners can now only deduct up to $10,000 in state and local taxes, including property taxes ? a deduction which used to be unlimited.

While the changes mostly affect buyers in high-cost markets, the deductions have become less valuable because of the near doubling of the standard deduction, which means fewer homeowners will itemize and take advantage of them.

Becoming a homeowner means committing to fixing the leaky roof, backed up toilet or heat pump that stops working on the coldest night of the year. Some people just don’t want the responsibility. Renters can pick up the phone and call the landlord. Landlords also tend to pick up the tab for utilities, trash pick up and landscaping

Also, consider the source of your income. If your paychecks aren’t steady or your job security is uncertain, it might make sense to hold off on buying a home. Renters can always pick up and move to cut back or follow a new job.