Where to put your cash? A house or a stock

stocks vs house where to invest
Better buy: Stocks or a house?   

Even as the stock market soars to record highs, federal regulators are announcing new, cheaper ways for cash-strapped borrowers to buy a home. With the catastrophic housing crash of the last decade still glaring through the rear view mirror, the government is again pushing home ownership as the best way to build wealth, but is it?

"It would perhaps be smarter, if wealth accumulation is your goal, to rent and put money in the stock market, which has historically shown much higher returns than the housing market," said Nobel Prize-winning economist Robert Shiller at a Standard and Poor's conference last week.

Read MoreCase-Shiller home price index: CNBC Explains

Shiller notes that the comparison between stock returns and home value returns is rough, given that stocks pay cash dividends and housing pays "in kind," in the form of housing services; that is, you get to live in a house.

Still, if you remove all forms of dividends and compare the Standard and Poor's U.S. composite stock price index since 1871 and Shiller's own real U.S. home price index since 1890, the stock market capital gains outperform the housing market's capital gains. Both, he notes, are smaller than one might expect.

Read MoreLow down payment mortgages back for buyers

House vs. Stocks?
Getty Images
House vs. Stocks?

"The real S&P composite has increased 12.2-fold from January 1890 to December 2014, or 2.03 percent per year, much less than most people would have guessed. Most of the real return in the stock market over the last century has come from dividends, not real capital gains," said Shiller. "Home prices have increased only 1.5-fold, or only 33 basis points a year. Essentially, home price capital gains overall have amounted to virtually nothing."

One must also account for the costs of home ownership, costs that don't exist in stock ownership. Property taxes, insurance, maintenance, renovation all subtract from the capital gains of owning a home.

Read MoreThe top 10 housing markets for growth in 2015

The downside to stocks, however, is capital gains taxes.

"If we had much stronger 401K [retirement]-type programs in the United States, much more heavily pushed, much bigger commitment from everybody, would that replace homeownership as a way to build wealth?" asked David Blitzer, chairman and managing director at S&P Dow Jones Indices. "Right now my impression is that the tax benefits of a 401(k) plan or other contribution pension plans pale compared to home ownership."


Housing vs. stock through the years

The Case Shiller home price index (red) versus the S&P 500 Index (blue) since 1987. Source: S&P Dow Jones Indices

A house can offer greater returns if the owner chooses to rent it out and not to live in it; however the consumption value of the home to the owner, again that value of actually inhabiting it, is gone. And that adds to Shiller's point that a home should not be seen as an investment vehicle, like a stock, but as a consumption good, like a car.

Read MoreJumbo mortgage: CNBC Explains

"You don't accrue as much wealth as a renter as you do as a buyer," noted Sam Khater, deputy chief economist of CoreLogic. "The con, though, is that with home ownership being the primary way that the middle class gets richer over time, and with the bulk of their wealth and equity tied up in housing, if home prices decline, they take a huge hit."

The happy compromise, it seems, would be to keep less equity in your home, through a long-term, low-down payment mortgage, or, if you can qualify, through an interest-only loan, and keep more cash ready for investing in the stock market.

Read MoreSelf-employed? Good luck getting a mortgage

It's a riskier choice, given the current volatility in home prices, but it may be the best way to build wealth.