I have the following dataframe, which I've used to build an ARIMA model and forecasts, before plotting it in a fanchart using the fable
package.
I'm hoping to find a solution in which I can fit my ARIMA forecasts for multiple variables (Component 1 and 2), where for example each variable is weighted equally (50% each) in my forecasts. Is there any way to do this and plot my fanchart with these weighted forecasts? My example below has only run an ARIMA forecast on one of the variables (Component 1), but I'm hoping to run an ARIMA forecasts on all of my variables and weight them accordingly
library(tidyverse)
library(tsibble)
library(fable)
data <- structure(list(Date = structure(c(18383, 18414, 18444, 18475,
18506, 18536, 18567, 18597, 18628, 18659, 18687, 18718, 18748
), class = c("yearmonth", "vctrs_vctr")), `Component 1` = c(-0.136535845906039,
-0.836519457510263, -1.18729738867468, 1.15910388651122, 1.2562958338269,
-1.19066468349899, -1.21838083407816, -1.34198585493321, -0.843625520768398,
0.192071067785477, 2.43893315702964, 7.53338782924422, 7.31128441509166
), `Component 2` = c(2.16292504382349, 3.61278939509646, 4.46165448523277,
3.64200206159624, 3.77062926096379, 4.26941270942491, 4.58011851783391,
4.2695187122175, 4.96351398840244, 4.16536909803045, 3.78233085059824,
4.2340896479389, 3.48259766258533)), row.names = c(NA, -13L), key = structure(list(
.rows = structure(list(1:13), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, -1L), class = c("tbl_df",
"tbl", "data.frame")), index = structure("Date", ordered = TRUE), index2 = "Date", interval = structure(list(
year = 0, quarter = 0, month = 1, week = 0, day = 0, hour = 0,
minute = 0, second = 0, millisecond = 0, microsecond = 0,
nanosecond = 0, unit = 0), .regular = TRUE, class = c("interval",
"vctrs_rcrd", "vctrs_vctr")), class = c("tbl_ts", "tbl_df", "tbl",
"data.frame"))
arima_model <- data %>% model(arima = ARIMA(`Component 1`))
forecasts <- arima_model %>%
forecast(h = '6 months')
fanchart <- autoplot(forecasts, level = seq(10, 90, by = 10))
fanchart