Hello,
Is there a way to perform ARIMA on all external regressors at once? I have several variables and I am running into issues of dealing with each variable at a time. My sample data below includes only 2 external regressors, but my original data includes 7 to 8 and it gets difficult to handle ARIMA on all of them. Any help would be appreciated!
library(tidyverse)
library(lubridate)
library(tsibble)
library(fable)
df <- data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
date = c("2019-01-01",
"2019-04-01","2019-07-01","2019-10-01","2020-01-01",
"2020-04-01","2020-07-01","2020-10-01","2021-01-01",
"2021-04-01","2021-07-01","2021-10-01"),
`sales` = c(21999,28022,30464,
26861,24990,17015,30381,29716,NA,NA,NA,NA),
`gdp` = c(2211.94,2259.38,2243.29,
2246.55,2158.49,2086.65,2305.75,NA,NA,NA,NA,
NA),
`oil` = c(191125,191125,189738,
238556,263929,274390,282798,292390,302517,NA,NA,
NA)
)
df <- df1%>%
mutate(date = yearquarter(date)) %>%
as_tsibble(index = date)
For now, I am performing ARIMA on each variable individually. Though, I am getting results as I would like, but its tedious with different horizon for each as seen in the data.
If I try to make longer data, I am not able to perform ARIMA even to get values on just Q2 while keeping horizon as 1. Of course, horizon would change for each of these external variables. I am not sure how to have efficient way to code here. Any help would be appreciated. Thanks for your help!
df1 <- df %>%
pivot_longer(-date, "features", "value")%>%
filter_index(~"2020 Q1")
df2%>%
model(
arima = ARIMA(value)
)%>%
forecast(h = 1)