fpp3: Cross Validation -- stretch_tsibble

I have 10-year-monthly data. I am trying to find the best ARIMA model that forecasts 36 month period using cross validation.

My questions are:

  1. What is the appropriate (or minimum) .init should I use under stretch_tsibble() given that I use ARIMA models?
  2. Is .step = 1 standard practice?
suppressWarnings(suppressMessages(library(fpp3)))
########
# Data
########
toy_data <- PBS %>%
  filter(ATC2 == "H02",
         year(Month) > 1991 & year(Month) < 2002) %>%
  select(Month, Concession, Type, Cost) %>%
  summarise(TotalC = sum(Cost)) %>%
  mutate(Cost = TotalC/1e6) %>% 
  select(Cost)

############################################
# Time series cross-validation accuracy
###########################################
# Strech 
toy_data_tr <- toy_data %>%
  slice(1:(n()-36)) %>% 
  stretch_tsibble(.init = 60, .step = 1)
# Models
fc <- toy_data_tr %>%
  model(m1 = ARIMA(Cost ~ pdq(0,1,3) + PDQ(0,1,1)),
        m2 = ARIMA(Cost ~ pdq(0,1,2) + PDQ(0,1,1))) %>%
  forecast(h = 36)
# Accuracy
fc %>% accuracy(toy_data)
#> # A tibble: 2 x 9
#>   .model .type     ME   RMSE    MAE   MPE  MAPE  MASE  ACF1
#>   <chr>  <chr>  <dbl>  <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 m1     Test  0.0260 0.0713 0.0574  2.62  7.56  1.08 0.600
#> 2 m2     Test  0.0355 0.0790 0.0635  3.91  8.30  1.20 0.616

Created on 2020-11-10 by the reprex package (v0.3.0)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.