ARIMA for forecasting independent variables

Hi,

I am working on time series forecasting model using fable to predict sales. Before predicting sales, I need to get forecast on multiple independent variables at once where each variable has values stopping at different month/year. I have created a reprex to show a small sample of what it looks like. In the below example, I would like to use ARIMA on each of the variables A, B, C, D to get their forecast values until 2020-12-01.

df <- data.frame(
           date = c("2020-01-01","2020-02-01",
                    "2020-03-01","2020-04-01","2020-05-01","2020-06-01","2020-07-01",
                    "2020-08-01","2020-09-01","2020-10-01","2020-11-01",
                    "2020-12-01"),
          sales = c(2061292,2087140,2136628,449335,
                    1105069,1535344,2130425,NA,NA,NA,NA,NA),
              A = c(5067331.423,4856897.658,4175123.217,
                    3494987.878,3768201.526,4058111.486,NA,NA,NA,NA,NA,
                    NA),
           B = c(153, 146, 115, 108, 133, 150, 153, 152, NA, NA, NA, NA),
              C = c(58.247345,50.548263,30.994029,
                    20.521175,28.040035,38.072555,40.682499,39.97,39.92,NA,NA,
                    NA),
              D = c(609026,595426.8,598968.2,544902.2,
                    556805.2,553345.6,NA,NA,NA,NA,NA,NA)
   )

If I was forecasting values for just one independent variable, example A in this case, I could use the ARIMA as follows:

library(tidyverse)
library(tsibble)
library(fable)

A_fc <- df%>%
  mutate(month = yearmonth(date)) %>%
  as_tsibble(index=month) %>%
  model(model = ARIMA(A) %>%
  forecast(h=6)

Instead of doing this for each variable A, B, C, D separately and then combining the data together, is there a better way or tidyverse way to perform this task for all the variables and get a new data frame with all the forecast values for all variables except for sales which we will predict afterwards.

Thanks for your help!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.