Time series cross-validation

Forecasting in R

Rob J. Hyndman

Professor of Statistics at Monash University

Time series cross-validation

ch2_vid4_slides.002.png

Forecasting in R

Time series cross-validation

ch2_vid4_slides.003.png

Forecasting in R

Time series cross-validation

ch2_vid4_slides.004.png

Forecasting in R

Time series cross-validation

ch2_vid4_slides.005.png

Forecasting in R

tsCV function

MSE using time series cross-validation

e <- tsCV (oil, forecastfunction = naive, h = 1)
mean(e^2 , na.rm = TRUE)
2355.753

When there are no parameters to be estimated, tsCV with h=1 will give the same values as residuals

Forecasting in R

tsCV function

  sq <- function(u){u^2}
  tsCV(oil, forecastfunction = naive, h = 10) %>%
    sq() %>% colMeans(na.rm=TRUE)
      h=1       h=2       h=3       h=4       h=5       h=6
 2355.753  5734.838  9842.239 14299.997 18560.887 23264.410
      h=7       h=8       h=9      h=10
26932.799 30766.136 32892.200 32986.214

The MSE increases with the forecast horizon

Forecasting in R

tsCV function

  • Choose the model with the smallest MSE computed using time series cross-validation
  • Compute it at the forecast horizon of most interest to you
Forecasting in R

Let's practice!

Forecasting in R

Preparing Video For Download...