Stocks will bring you highs, but periodically will seriously let you down. Treasury bonds will keep you safe, but they won’t make you rich. Housing? That’s the best of both worlds. In rich countries, over the very long term, housing investments get you returns similar to equities (like stocks and other securities), while providing the low volatility of bonds.

This is the argument of a groundbreaking new paper from economists at University of California-Davis, University of Bonn, and the Deutsche Bundesbank (the central bank of Germany). In a feat of extraordinary data collection, the researchers pulled together the annual returns of treasury bills, treasury bonds, equities, and residential housing from 1870 to 2015 for 16 now-rich countries such as the US, Germany, and Japan. The dataset is the first of its kind.

They find that, in the average wealthy country, the annual return on housing during that period was just over 7% when adjusted for inflation, while the return on equities was just under 7%. At the same time, the risk associated with housing was far lower. By standard measures of uncertainty, housing was about half as risky as equities, and slightly less risky than bonds.

The reason these findings are so remarkable is that they fly in the face of economic theories of asset valuation, which suggest risky assets like stocks should have higher returns than stable ones like housing. But that’s not so, the authors write. The ultimate investor, according to the study, would actually hold “an internationally diversified portfolio of real estate holdings, even more so than equities.” The economists do not offer an explanation for their finding, but hope other researchers will use their data to try to solve the puzzle.

Although housing performed better than equities overall, there were large differences across the 16 countries included. At 3.3%, the extra return you would have gotten on housing compared to equity investment was largest in France, where equity investments were particularly low due to the devastation of World War II, a wave of nationalizations of private businesses after that war, and an oil crisis in the 1960s.

Recent history has been kinder to equities. Since 1980, the annual return on equities in these 16 countries was 10.7%, compared to 6.4% for housing. The researchers attribute this dip to Japan’s post-1990 housing-price collapse and slow growth in Germany’s residential real estate. At the same time, equities in Scandinavian countries like Sweden, Norway, and Finland exploded.

Yet even since 1980, when adjusted for risk, housing did better than equities. The Sharpe ratio is a popular measure of investment returns that accounts for the volatility of a stock. The metric is useful for investors who want high returns, but don’t want their account balance to ever get too low. By the Sharpe ratio, since 1980, housing was a better investment in 14 of the 16 countries examined in this study.

One limitation of the analysis is that it does not account for taxes. Researchers left out property taxes because they are often byzantine, with rates varying between and even within countries. There are also often complicated tax exemptions for certain kinds of housing. The researchers do offer a ballpark estimate of tax impact: including taxes, they write, would decrease the returns on housing one percentage point compared to equities—making housing still the better risk-adjusted asset.

The study’s findings are more useful for investors who can consider investing in multiple residential properties than they are for individuals (or individual families) who would likely be buying just one home. A single home is a much riskier asset than a diverse portfolio of residential real estate. That said, even if you aren’t a millionaire, you can diversify your residential home investments through financial products like a real estate investment trust (REIT). In other words, you probably shouldn’t buy one house based on this research, but if you are looking for a safe and valuable long term investment, you might want to buy shares in many different real estate holdings.