我使用了一些代码,这些代码使用 fable 自动将外部回归器列表传递给 ARIMA()(感谢@seapen 和@Mitchell O'Hara-Wild)。
我想通过差分和转换为对数刻度来转换所有变量。据我了解,如果这是在 model() 中完成的,那么 fable 会自动对预测进行反向转换。
请有人帮我修改下面的代码,以便每个自动生成的变量都以 dlog 形式通过 model() 调用,从而允许进行自动反向转换?
library(tidyverse)
library(fable)
library(BBmisc)
library(progressr)
# Load data
df <- tsibbledata::hh_budget
# Build lists of external regressor combinations
subsets_list <- function(set, subset_size) {
combn(set, subset_size) %>%
BBmisc::convertColsToList() %>%
unname()
}
xregs <-
map(.x = 1:(length(df) - 3), .f = subsets_list,
set = colnames(df[4:length(df)])) %>%
unlist(recursive = F)
# Construct formulas
rhs <- map_chr(seq_along(xregs), ~ paste(xregs[[.]], collapse = " + "))
lhs <- "Debt"
formulas <- map(paste(lhs, rhs, sep = " ~ "), as.formula)
# Create model specifications
model_specs <- set_names(map(formulas, ARIMA), formulas)
# Train - test split for model fit
train <- df %>% filter(Year <= 2014)
test <- df %>% filter(Year > 2014)
# Estimate models based on training data (added a progress bar since it takes ~30secs)
fit <- with_progress(train %>%
model(!!!model_specs))
# forecast all models using test data
fc <- fit %>%
forecast(test)
非常感谢任何帮助。