This is a quick post on the importance of benchmarking time-series forecasts. First we need to reload the functions from my last few posts on times-series cross-validation. (I copied the relevant code at the bottom of this post so you don’t have to find it).

Next, we need to load data for the S&P 500. To simplify things, and allow us to explore seasonality effects, I’m going to load monthly data, back to 1980.

The object “Data” has monthly closing prices for the S&P 500 back until 1980. Next, we cross validate 3 time series forecasting models: auto.arima, from the forecast package, a mean forecast, that returns the mean value over the last year, and a naive forecast, which assumes the next value of the series will be equal to the present value. These last 2 forecasts serve as benchmarks, to help determine if auto.arima would be useful for forecasting the S&P 500. Also note that I’m using BIC as a criteria for selecting arima models, and I have trace on so you can see the results of the model selection process.

After the 3 models finish cross-validating, it is useful to plot their forecast errors at different horizons. As you can see, auto.arima performs much better than the mean model, but is constantly worse than the naive model. This illustrates the importance of benchmarking forecasts. If you can’t constantly beat a naive forecast, there’s no reason to waste processing power on a useless model.

Finally, here is all the code in one place. Note that you can parallelize the cv.ts function by loading your favorite foreach backend.

*Related*

To

**leave a comment** for the author, please follow the link and comment on their blog:

** Modern Toolmaking**.

R-bloggers.com offers

**daily e-mail updates** about

R news and

tutorials on topics such as:

Data science,

Big Data, R jobs, visualization (

ggplot2,

Boxplots,

maps,

animation), programming (

RStudio,

Sweave,

LaTeX,

SQL,

Eclipse,

git,

hadoop,

Web Scraping) statistics (

regression,

PCA,

time series,

trading) and more...

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook...