在R中对时间序列数据使用predict()函数时出现意外错误

时间:2015-05-14 09:35:02

标签: r time-series forecasting predict

从7/21/2009 11:30到7/23/2014 23:30,数据有半小时负载数据(电力需求)。变量“LOAD.MW”在固定的时间间隔内按时间顺序测量,因此结果数据可以被认为是时间序列。

我已将数据转换为“ts”类

data.ts <- ts(data$LOAD.MW, start=c(as.numeric(as.Date("2009/07/21")),26), 
              end=c(as.numeric(as.Date("2014/7/23")),48),frequency=48)

然后我安装了arima模型:

 data.fit1 <- arima(data.ts, order = c(2,0,0))
 data.fit1

# Call:
# arima(x = data.ts, order = c(2, 0, 0))

# Coefficients:
#          ar1      ar2  intercept
#       1.8421  -0.8765  2675.7445
# s.e.  0.0016   0.0016     5.5789

# sigma^2 estimated as 3222:  log likelihood = -479024.8,  aic = 958057.7

现在我想做一些预测。所以,我使用了predict函数:

data.pred1 <- predict(data.fit1,n.ahead=100)   #Making 100 half hour prediction
  

预测错误(data.fit1,n.ahead = 100):   未使用的参数(n.ahead = 100)

它给了我一个错误。我无法理解为什么会收到此错误。为什么论证n.ahead=100被认为未使用?我之前也使用过这个功能,但后来我为我工作了。事实上,我也经历过,有时它会起作用,有时则不然。

当我尝试使用forecast()函数进行预测时,我得到了相同的错误。

forecast(data.fit1,5)
  

预测错误(对象,n.ahead = h):未使用的参数(n.ahead = h)

请提供您的专家意见并帮助我纠正此错误。

0 个答案:

没有答案