I am trying to do cross-validation on a model with lagged predictors. I had some unexpected forecasting results. Below, you'll find an example.
library(fpp3)
insurance_train <- insurance %>%
stretch_tsibble(.init = 39, .step = 1, .id=".id")
# Commenting out this rule leads to a different forecast for May 2005
# insurance_train <- filter(insurance_train, .id == 2)
fit <- insurance_train %>%
model(
lag = ARIMA(Quotes ~ pdq(d = 0) + lag(TVadverts))
)
insurance_test <- new_data(insurance_train, 1) %>%
left_join(select(insurance, TVadverts), by='Month')
fit %>%
forecast(insurance_test)
So far, I noticed that:
The issue does not occur if the predictor is not lagged (Quotes ~ pdq(d = 0) + TVadverts).
The issue does not occur if the lagged predictor is created manually before stretching the tsibble, thus by adding a variable TVadverts_lag = lag(TVadverts) and using Quotes ~ pdq(d = 0) + TVadverts_lag.
Thanks for creating the fable package and having a look at this issue :pray:.
Timo
Thanks for this issue. I've migrated this to fabletools as this issue relates to the model definition objects and how lagged elements are recalled automatically (all handled in fabletools).
Hi all,
I am trying to do cross-validation on a model with lagged predictors. I had some unexpected forecasting results. Below, you'll find an example.
So far, I noticed that:
Quotes ~ pdq(d = 0) + TVadverts
).TVadverts_lag = lag(TVadverts)
and usingQuotes ~ pdq(d = 0) + TVadverts_lag
.Thanks for creating the fable package and having a look at this issue :pray:. Timo