The stock market is risky, right? You're better off investing in real estate if you can, right?

Well, maybe that's not so right.

The idea that real estate investments trump stock investments isn't new, but it's been fueled in the past few years by two things: the stock market's recent sluggishness, and the red-hot real estate market in many regions. I can see how this line of thinking is easy to adopt. I became a homeowner for the first time a few years ago, and I have seen the value of my house go up considerably in short order. Meanwhile, my stock holdings haven't been advancing too much. I've even lost ground on several companies that I still believe in, such as Washington Post (NYSE:WPO), Wal-Mart (NYSE:WMT), and Pfizer (NYSE:PFE), a Motley Fool Inside Value recommendation.

I read an interesting article in TheNew YorkTimes a few months ago that tackled this conventional wisdom about real estate. It said: "[T]he last five years -- when homes in some hot markets like Manhattan and Las Vegas have outperformed stocks -- has been a highly unusual period. In fact, by a wide margin over time, stock prices have risen more quickly than home values, even on the East and West coasts, where home values have appreciated most."

The article offered the example of a New Jersey couple who built a home in 1970 for $110,000 and sold it in 2005 for $900,000. While that looks like a hefty gain, it doesn't account for inflation or for the money that they poured into their home, such as for their new master bathroom (with Jacuzzi and marble floors).

The Times explained: "Add it all up, and they ended up making an inflation-adjusted profit of less than 10% over the 35 years. That return does not come close to the gains of the stock market over the same period. The Standard & Poor's 500-stock index has increased almost 200% since 1970, even after accounting for inflation."

This rings true for me and my little house, too. Yes, it's worth a lot more, in short order. But I know that these kinds of increases aren't common. And I'm paying a third of what I used to pay in rent just for taxes. Then there's home insurance, the new roof, some landscaping, and so on. Is my home still a great deal? Well, it's a good deal. It's providing a secure (new) roof over my head, and my payments toward it are building equity, something my 20 years of rent payments never did. But over the long run, my stock portfolio might well outperform my home. And that's OK. I can't put my furniture in my stocks, and my mutual funds won't hold all of my books or my boxes of Lucky Charms cereal.

The Times offered some more data on the issue: "Since 1980 . money invested in the Standard & Poor's 500 has delivered a return of 10% a year on average. Including dividends, the return on the S&P 500 rises to 12% a year. Even in New York and San Francisco, homes have risen in value only about 7% a year over the same span."

So keep your real estate investment in perspective. And if you're thinking of buying or selling a home -- or an investment property -- spend some time in our Home Center, which features lots of money-saving tips and even some special mortgage rates.

You might also want to check out these articles:

Longtime Fool contributor Selena Maranjian owns shares of Washington Post, Pfizer, and Wal-Mart. The Motley Fool has a disclosure policy.