分层数据预测的回归ARIMA方法
在gts对象上尝试使用ARIMA进行回归时,我遇到此错误: 傅里叶(x,K,长度(x)+(1:h))中的误差: K不得大于周期/2 下面是一段简单的可复制代码。我应该将k设置为什么?我尝试过不同的价值观,但似乎都不管用分层数据预测的回归ARIMA方法,r,time-series,hierarchical-data,forecasting,R,Time Series,Hierarchical Data,Forecasting,在gts对象上尝试使用ARIMA进行回归时,我遇到此错误: 傅里叶(x,K,长度(x)+(1:h))中的误差: K不得大于周期/2 下面是一段简单的可复制代码。我应该将k设置为什么?我尝试过不同的价值观,但似乎都不管用 library(hts) y3 <- ts(matrix(rnorm(300),ncol=60,nrow=5)) blnames3 <- paste0(rep(c("CA", "NY"), each = 30), # State rep(
library(hts)
y3 <- ts(matrix(rnorm(300),ncol=60,nrow=5))
blnames3 <- paste0(rep(c("CA", "NY"), each = 30), # State
rep(c("AL", "LA", "CL", "ES"), each = 15), # County
rep(c("O", "O", "O", "C", "C"), 12), # Industry
rep(c("p", "q", "r", "p", "q"), 12), # Sub-industry
rep(504:507, 15)) # Product
colnames(y3) <- blnames3
gy3 <- gts(y3, characters=list(c(2,2),c(1,1,3)))
i=5
fc <- forecast(gy3, fmethod="arima", seasonal=FALSE, h=6, xreg=fourier(gy3, K=i), newxreg=fourierf(gy3, K=i, h=6))
库(hts)
y3这里有几个问题。首先,您的时间序列仅包含5个观测值,每个观测值太少,无法用于预测目的。其次,在ts()
调用中不指定数据的频率。第三,不能将gts对象作为第一个参数传递给fourier
()
以下是一些有效的代码:
library(hts)
y3 <- ts(matrix(rnorm(3000),ncol=60), frequency=12)
blnames3 <- paste0(rep(c("CA", "NY"), each = 30), # State
rep(c("AL", "LA", "CL", "ES"), each = 15), # County
rep(c("O", "O", "O", "C", "C"), 12), # Industry
rep(c("p", "q", "r", "p", "q"), 12), # Sub-industry
rep(504:507, 15)) # Product
colnames(y3) <- blnames3
gy3 <- gts(y3, characters=list(c(2,2),c(1,1,3)))
i <- 5
fc <- forecast(gy3, fmethod="arima", seasonal=FALSE, h=6,
xreg=fourier(y3[,1], K=i), newxreg=fourierf(y3[,1], K=i, h=6))
库(hts)
y3抱歉,已通过包含i更正代码。gts来自hts包-您的时间序列还需要频率属性。