我正在使用fable
R 中的包来尝试一些 Arima 预测并将其放入 fanchart 中。我在下面复制了我的数据集和代码的片段
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
如您所见,我只运行了我的 ARIMA 模型并对我的数据集中的一个变量(组件 1)进行了预测。有什么方法可以创建加权 ARIMA 和预测,其中我的数据集中的组件 1 和组件 2 在我的模型中的权重相同?