# Predicting future returns with R: are returns stationarity?

“Essentially, all models are wrong, but some are useful.” - George E. P. Box

I spent probably at least a year of my life building models. While it was and is part of my work, I always keep the words of George Box in my mind. As a risk manager, I always considered that models aiming to predict were among the least useful.

First days of this month, however, I ended up studying economic forecasting. While it did not change my view on usefulness of forecasts, it managed to make me a little bit curious.

This and potentially few following posts are an attempt to apply some of the statistical techniques (and R) to predict long term future returns of S&P 500 index.

The endeavor will naturally start with investigation of Prof. Shiller’s CAPE ratio and it’s predictive power.

## Getting the data

The first step is getting the data. For that I will use Quandl.com, that already has Shiller’s data set.

```#Load Quandl import package
#Importing Shiller's data from Quandl
#Simplifying column names
library(Quandl)
df <- Quandl("YALE/SPCOMP", type="xts", collapse="monthly")
colnames(df) <- c('sp500','dividend','earnings','cpi','interest','rsp500'
,'rdivdend', 'rearnings', 'cape') ```

The data for S&P 500 start in Jan 1871 and continues to May 2015.

## Calculating future returns

Second step is to calculate historical future investment returns. I will continue with both nominal and real returns.

As future 10 year returns are available only starting May 2005, that will be a natural limitation for the analysis. From this moment I will consider data from Jan 1871 to May 2005 as my full series.

```## Future nominal returns (5 and 10 year)
df\$fnr5 <-  (lag(df\$sp500, -60) / df\$sp500) ^ (1/5) - 1
df\$fnr10 <- (lag(df\$sp500, -120) / df\$sp500) ^ (1/10) - 1
## Future real returns (5 and 10 year)
df\$frr5 <-  (lag(df\$rsp500, -60) / df\$rsp500) ^ (1/5) - 1
df\$frr10 <- (lag(df\$rsp500, -120) / df\$rsp500) ^ (1/10) - 1
#Working data set
df <-  window(df, start = as.yearmon("1871-01-01"),
end =  as.yearmon("2005-05-31"))```

## Are market returns stationary?

Any attempt to predict using statistical methods should start with answering whether the data is stationary (simplified: mean reverting), as future steps should depend on it.

So, are the market returns stationary? While in theory they should be, quick look at the plots suggest that it might not necessarily be the case.

To check whether return data are stationary I performed Augmented Dickey–Fuller Test and it did not confirm my thought of non-stationarity. However, same test performed on data starting in 1950 gave probabilities of non-stationarity between 14% and 60% for different return series. In any way I will proceed with assumption that returns are stationary.

```library(tseries)