We're often told of the importance of investing in stocks, especially when it comes to long-term savings goals, like retirement. But new data suggests that there may be another way to generate comparable returns over a lengthy period of time: becoming a landlord.

Researchers from UCLA's Anderson School of Management and Structured Portfolio Management in Stamford, Connecticut recently found that single-family homes in large U.S. cities generated average annual returns of roughly 9% between 1986 and 2014. In the study, about half of those returns stemmed from rental income, and the other half from increases in property value.

House with for rent sign in the front yard.

Image source: Getty Images.

Why is that significant? Because the stock market has historically delivered returns in the 9% ballpark as well. This data therefore suggests that you can make about as much money being a landlord as you can managing a stock portfolio over time. It also indicates that owning a rental property can be far more lucrative than conservative investments such as bonds. The question therefore becomes: Should you divert some of your investment dollars away from the stock market and buy property instead?

Stocks are risky -- but so is owning property

If there's one drawback to owning stocks, it's having to deal with the market's perpetual volatility. But when you own property, you face your fair share of risks as well.

For one thing, there's always the risk of winding up with tenants who don't pay, or who force you to take legal action against them that ends up costing you money. There's also the risk that your tenants damage your property, leaving you on the hook to pay for their carelessness. Furthermore, when you own property, a steady stream of rental income isn't a given. You might face extended vacancies, or a string of short-term vacancies that eat away at your profits.

Then there are the general risks of maintaining property that all owners face, regardless of whether they use their real estate as an income stream. As an owner, you're the one responsible for home repairs, which can be extremely costly when high-ticket items break or wear out. There's also the possibility of real estate market downturns to contend with. If property values sink in your area at the exact point you're looking to sell, you may not see anywhere close to the sort of overall returns we talked about above.

Finally, remember that in buying property, you're tying up a lot of cash in a fairly illiquid investment. Dumping a stock is much easier than selling a home, even when the real estate market is booming, so that's something to keep in the back of your mind.

On the other hand, if you're already loaded up on stocks and are looking to diversify your investments, buying a home and becoming a landlord might be the way to go. And if you're going to do it, now's a decent time. Mortgage rates are still a reasonable level, and more Americans are renting today than in years past, which means your likelihood of finding tenants is strong.

Of course, there's another option to consider as well: REITs (real estate investment trusts). REITs allow you to get a piece of the real estate action without having to actually go out and buy a home or deal with the hands-on work associated with managing property and tenants. So if you're eager to put some money into real estate but want to minimize some of the aforementioned risks, REITs might be your ticket to strong returns that mimic or even surpass those of the stock market.