Search code examples
rtime-seriesforecasting

Error in hasTsp(x) : attempt to set an attribute on NULL using arima in R


I'm doing a simple ts forecast using R.

    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)

And I get this error:Error in hasTsp(x) : attempt to set an attribute on NULL

There aren't any Nulls in my ts, so I'm not sure what to do.

Thanks!


Solution

  • Try something like this

    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