Is buying a house a better investment than the stock market?

We did the math, and the answer is clear.

Even with the dot-com crash and the stock-market crash in the wake of the financial crisis of the late 2000s, the cumulative gains in the stock market since the beginning of the 1990s have resulted in a gain of over 700%, while housing prices have increased 164% in that time.

But timing matters. Starting at the top of the dot-com bubble in September 2000 leads to a narrow edge for housing prices.

Housing prices are up about 85% while stocks are up 79% since September 2000, when the stock market peaked during the tech bubble.

Buying at the post-tech-bubble bottom for the stock market had the opposite effect.

Housing prices are up 60% and stocks are up 233% since October 2002.

Stocks have also understandably outperformed house prices since the top of the housing bubble.

Stocks are up 93% since the FHFA house-price index topped out in March 2007, while housing took a long time to recover. Housing prices are up just 17% in the past 11 years, with the FHFA index not fully recovering until 2016.

Stocks reached their peak a few months after housing did amid the financial crisis.

Housing prices are up 21% since November 2007, while stocks are up 76%.

The stock market has generally been on a tear since the post-crisis bottom in 2009.

Stocks are up 273% since hitting a low in March 2009, while housing prices are up 36%.

Housing prices have generally been on the rise since 2011, but stocks have still outperformed.

Housing prices are up 48% from May 2011, when the FHFA index hit its post-crisis low, while stocks are up 99%.

Location also matters. Here’s how New York City housing prices have fared compared with stocks since the start of the FHFA series.

Stocks are up nearly 700% since January 1991, while housing prices in the New York-Jersey City-White Plains metropolitan division are up 174%.

Miami was an epicenter of the housing bubble. At the bubble’s height, housing price growth since 1991 briefly surpassed stocks.

As of the second quarter of 2018, housing prices in the Miami-Miami Beach-Kendall metropolitan division are up 297% since Q1 1991.

Denver had the biggest total increase in housing prices since 1991 among the 20 biggest metro areas and divisions tracked by the FHFA.

Housing prices in the Denver-Aurora-Lakewood metropolitan area are up 413% since Q1 1991, still below the nearly 700% increase in stock prices.

In most time intervals and metro areas, stock prices have outperformed housing prices in the US over the past couple of decades.

The numbers are only one thing to consider, and it’s important to bear in mind that past performance can’t predict the future.

This doesn’t mean that stocks are always the best investment for everyone at every time, or that buying a home is the wrong choice. Everyone has different financial and housing needs, with several factors involved in making these kinds of decisions.

Article was written by Andy Kiersz, www.businessinsider.com