Big Data/Analytics Zone is brought to you in partnership with:

Rob Hyndman is a Professor of Statistics at Monash University, Australia. He is Editor-in-Chief of the International Journal of Forecasting and author of over 100 research papers in statistical science. He also maintains an active consulting practice, assisting hundreds of companies and organizations. His recent consulting work has involved forecasting electricity demand, tourism demand, the Australian government health budget and case volume at a US call centre. Rob J is a DZone MVB and is not an employee of DZone and has posted 42 posts at DZone. You can read more from them at their website. View Full User Profile

Out-of-Sample One Step Forecasts

02.14.2013
| 999 views |
  • submit to reddit

It is com­mon to fit a model using train­ing data, and then to eval­u­ate its per­for­mance on a test data set. When the data are time series, it is use­ful to com­pute one-​​step fore­casts on the test data. For some rea­son, this is much more com­monly done by peo­ple trained in machine learn­ing rather than statistics.

If you are using the fore­cast pack­age in R, it's eas­ily done with ETS and ARIMAmod­els. For example:

library(forecast)
fit <- ets(trainingdata)
fit2 <- ets(testdata, model=fit)
onestep <- fitted(fit2)

Note that the sec­ond call to ets does not involve the model being re-​​estimated. Instead, the model obtained in the first call is applied to the test data in the sec­ond call. This works because fit­ted val­ues are one-​​step fore­casts in a time series model.

The same process works for ARIMA mod­els when ets is replaced by Arima orauto.arima. Note that it does not work with the arima func­tion from the stats pack­age. One of the rea­sons I wrote Arima (in the fore­cast pack­age) is to allow this sort of thing to be done.

Published at DZone with permission of Rob J Hyndman, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)