ARIMA for forecasting independent variables


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",
          sales = c(2061292,2087140,2136628,449335,
              A = c(5067331.423,4856897.658,4175123.217,
           B = c(153, 146, 115, 108, 133, 150, 153, 152, NA, NA, NA, NA),
              C = c(58.247345,50.548263,30.994029,
              D = c(609026,595426.8,598968.2,544902.2,

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


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

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.