hasTsp(x)中的错误:尝试使用R中的arima在NULL上设置属性

时间:2017-05-23 21:36:56

标签: r time-series forecasting

我正在使用R.

进行简单的ts预测
    sub_weekly<-ts(weekly$sub,
         frequency = 365.25/7,
         start = decimal_date(mdy('1/11/2016')))

    sub_diff<-diff(sub_weekly, differences = 2)

    acf(sub_diff, lag.max = 20, plot = T)

    sub_arima<-arima(sub_weekly, order = c(0,1,1))

    plot.forecast(sub_arima)

我收到此错误:Error in hasTsp(x) : attempt to set an attribute on NULL

我的ts中没有任何空缺,所以我不知道该怎么做。

谢谢!

1 个答案:

答案 0 :(得分:1)

尝试这样的事情

library(forecast)
ts.sim <- arima.sim(list(order = c(1,1,0), ar = 0.7), n = 200)

fit = arima(ts.sim, c(1, 1, 0))

plot(forecast(fit, h=200), include = ts.sim)

enter image description here