I am using fable to train and test multiple timeseries.
I have created a stretching window using tsibble_stretch to prepare the time series cross validation. Then I use ARIMA to find the best model for each fold and forecast to test each timeseries.
I use the following two lines of code for this and it works great:
ARIMA_model <- stretching_window %>%
model(ARIMA(pend_app))
ARIMA_forecast <- ARIMA_model %>%
forecast(h = "2 months")
However, when I want to do this using an external regressor, I get a lot of errors using the forecast function. I train my model like this:
ARIMA_model_ext <- stretching_window %>%
model(arima_regr = ARIMA(pend_app ~ new_app + rec_rate))
when I simply try to forecast two months into the future it says it is missing external regressors. Although these are in the stretching_window dataset. When I try to use the new_data function:
test <- new_data(stretching_window, 2) %>%
group_by_key() %>%
mutate( pend_app = last(stretching_window$pend_app),
new_app = last(stretching_window$new_app),
rec_rate = last(stretching_window$rec_rate))
ARIMA_model_ext %>%
fabletools::forecast( new_data = test)
I get the following error:
Forecasts from an ARIMA model must start one step beyond the end of the trained data.
Ideally, I would not want to use the new_data() function but simply use my stretching_window dataset. Because from my understanding it should already split the data in test and train folds with all the required data ( incl. external regressors) to forecast.