-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
I am having difficulties to forecast ARIMA model with exogenous variables.
Fitting of the model is not an issue, however when calling forecast on fitted ARIMA model with exogenous variables the whole process fails. I do not have rank problems with my exogenous variables.
The error I am receiving is :
`Error in `mutate()`:
ℹ In argument: `.mdl = (function (object, ...) ...`.
Caused by error in `as.matrix(newxreg) %*% coefs`:
! non-conformable arguments`
The issue I am having arises with a short time series. Here you can find a reproducible example with two time series, one works fine while the other raises the said issue calling forecast. The code uses as input data_weekly.csv .
I know that fitting an ARIMA model on short time series is not the best practice but I do not expect an error, just a not so precise model.
Thanks.
Example:
require(tidyverse)
require(dplyr)
require(ggplot2)
require(cowplot)
require(readr)
require(lubridate)
require(tsibble)
require(fable)
require(knitr)
require(ISOweek)
require(imputeTS)
require(Metrics)
require(timeDate)
require(log4r)
require(feasts)
require(future)
require(purrr)
require(furrr)
require(fst)
data <- read_csv('data_weekly.csv')
data <- data %>%
mutate(WEEK=yearweek(WEEK)) %>%
as_tsibble(key=c(PRODUCT, CLIENT), index=WEEK)
last_train_week <- yearweek("2024 W14")
# models training
weekly_model <- data %>%
filter(WEEK<=last_train_week) %>%
model(.mdl=ARIMA(UNITS ~ Ex_var_1 + Ex_var_2 + Ex_var_3), greedy=TRUE))
# forecast working fine
weekly_forecast_right <- weekly_model %>%
filter(PRODUCT=="AA", CLIENT=="BB") %>%
forecast(new_data=data %>% filter(WEEK>last_train_week))
# forecast raising error
weekly_forecast_wrong <- weekly_model %>%
filter(PRODUCT=="XX", CLIENT=="YY") %>%
forecast(new_data=data %>% filter(WEEK>last_train_week))
alessandro-peron-sdg and schneiderpy
Metadata
Metadata
Assignees
Labels
No labels