【发布时间】:2020-01-14 22:44:43
【问题描述】:
我想在分层时间序列中使用 xreg = Fourier(ts, k,f) 作为回归量。
我可以让回归器为单个系列工作。
我有一个分层时间序列 hts,它由与第一个相似的序列组成(时间步数相同)。
hts 参考:https://robjhyndman.com/publications/hierarchical-tourism/
我在使用相同回归量的 hts 的预测中出现错误。有什么问题?
train_ts:整个 hts,形式为 visnights。
top_ts :只是顶级时间序列
当为单个系列完成时, top_ts ,使用 xreg 和 newxreg 可以工作。
KK <- 12
REG= fourier(top_ts,KK,52)
model <- auto.arima(top_ts, xreg=fourier(top_ts, K=KK))
fcstResult <- forecast(model, h=1, xreg= REG, newxreg=REG)
作品
当我对类似于 visnights、train_ts 的 hts 进行预测时,
train_ts <- window(vis_ts, c(2,1), end= c(3, 52))
fcstResult <- forecast(train_ts, h=1, fmethod="arima", method = "bu")
作品
当我在 hts 上使用相同的回归量 XREG 时,它会出错:
fcstResult <- forecast(
train_ts, h = 1, method = "bu", fmethod = "arima", xreg=REG, newxreg=REG)
OR
fcstResult <- forecast(
train_ts, h = 1, method = "bu", fmethod = "arima", xreg=REG, newxreg=REG, lambda=0)
Error in model.frame.default(formula = x ~ xregg, drop.unused.levels = TRUE) :
variable lengths differ (found for 'xregg')
(我将所有列设为非零并添加了一个小的随机噪声,所以这不是问题)
【问题讨论】:
-
Per
r标签(悬停查看):请提供最小且可重现的示例以及所需的输出。对数据使用dput(),并使用library()调用指定所有非基础包。
标签: r regression fft hierarchical-data arima