AR(1) forecasting

Hi everyone! I'd like to have some help to overcome the following error. I have a time series of monthly yields from 2010/01 to 2019/12 and I need to forecast only the 2019 data (better, 2019 will be my out-of-sample). I run these commands, but at the end I obtain this error:

x<-arima.sim(n=108, list(ar=0.5))
data.ts<-ts(x, start = c(2010,01), frequency = 12)
time=window(data.ts, start=c(2010,01), end=c(2018,12))
yieldsarima<- arima(time, order=c(1,0,0))
ar1 intercept 0.4458780 -0.1409129
forecast(yieldsarima, h=12)
Error in attr(data, "tsp") <- c(start, end, frequency) : object is not a matrix

This would be the last passage but I don't know how to solve it. Can anyone help me?

Is it because yeildsarima is a model?

> yieldsarima

arima(x = time, order = c(1, 0, 0))

         ar1  intercept
      0.3915     0.0827
s.e.  0.0882     0.1682

sigma^2 estimated as 1.145:  log likelihood = -160.65,  aic = 327.31

You can forecast data.ts as it is a matrix.

By the way, fable has succeeded the forecast package.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.