I would like to compute “rolling origin” multi-step forecasts on a test set, i.e. train models using data up to time T and then produce h-step forecasts with origin at T, T+1, T+2 and so on, for evaluation. This is similar to time series cross-validation as described here, except the models are re-estimated each time origin is moved. I presume it may take a long time sometimes, in which case I would probably prefer not to re-estimate. Is there an automated way in fable
to that?
I thought of using refit()
and fitted()
functions like this:
library(fpp3)
google_stock <- gafa_stock |>
filter(Symbol == "GOOG", year(Date) >= 2015) |>
mutate(day = row_number()) |>
update_tsibble(index = day, regular = TRUE)
google_2015 <- google_stock |> filter(year(Date) == 2015)
google_2016 <- google_stock |> filter(year(Date) == 2016)
# compute 3-step forecasts
gf <- google_2015 |>
model(NAIVE(Close)) |>
refit(google_2016)
fitted(gf, h=3)
but it seems it doesn’t work.
a-Tom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.