[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**Data based investing**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Time is the investor’s best friend. The longer the investment horizon, the less the investment returns depend on factors such as crashes and current valuation levels. It is known that the chance for losing in the stock market on a 20-year period has historically been about zero. This post attempts to expand on this fact and take a look at how risky the U.S. stock market has actually been for long-term investors.

As usual, we’ll use data from Robert Shiller to answer the questions. The data begins from the year 1871, long before the actual S&P 500 index was created. We’ll only consider lump-sum investing, since dollar cost averaging is another story.

Let’s first look at the inflation-adjusted returns for an U.S. investor, including reinvested dividends. Keep in mind, that the U.S. stock market has been one of the best performing in the world, and future returns are likely to be lower because of high valuations and lower productivity and population growth. The upper and lower bands are the 95 percent prediction intervals, i.e. 95 percent of the time the investment return has been between these bands. The y-axis tells how many times your investment would have been multiplied. Notice that the axis is logarithmic.

This chart demonstrates how uncertain investing is. There has been a 5 percent chance that your investment would have only doubled in fifty years. Most of these cases happened during the 1930s, and it is important to remember that it might happen again. France once had a 66-year period where stocks didn’t beat inflation, for Italy the longest streak was 73 years and for Austria a painful period of 97 years. This is why global diversification is important. There has however been a 5 percent chance that the investment would have increased 20.5-fold in the U.S. for the same period. The risk works both ways.

Let’s also look at the nominal, non-inflation-adjusted returns to see how inflation eats returns:

The inflation in the U.S. has been quite high, over three percent annually. Inflation of course affects different companies in a different way, but the net effect is that lower inflation does not necessarily lead to higher inflation-adjusted returns.

Be sure to follow me on Twitter for updates about new blog posts!

The R code used in the analysis can be found here.

To

**leave a comment**for the author, please follow the link and comment on their blog:**Data based investing**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.