Search code examples
rmathstatisticstime-seriesforecasting

Arima.sim issues in R


I am working on making a prediction in R using time-series models. I used the auto.arima function to find a model for my dataset (which is a ts object). fit<-auto.arima(data) I can then plot the results of the prediction for the 20 following dates using the forecast function:

plot(forecast(fit,h=20))

However I would like to add external variables and I cannot do it using forecast because it is kind of a black box to me as I am new to R. So I tried to mimic it by using the arima.sim function and a problem arose: HOW TO INITIALIZE THIS FUNCTION ? I got the model by setting model=as.list(coef(fit)) but the other parameters are still obscure to me. I went through hundreds of page including in stackoverflow but nobody seems to really know what is going on. How is it calculated ? Like why does n.start (the burn-in period) must have ma+ar length and not only a max(ar,ma) length ? What is exactly start.innov? I thought I understood when there is only an AR part but I cannot reproduce the results with an AR+MA filter. My understanding as for the AR is concerned is that start.innov represent the errors between a filtered zero-signal and the true signal, is it true ? Like if you want to have an ar of order 2 with initial conditions (a1,a2) you need to set

start.innov[1]=a1-ar1*0-ar2*0=a1 

start.innov[2]=a2-ar1*start.innov[1]

and innov to rep(0,20) but what to do when facing an arima function how do you set the innov to get exactly the same curbs as forecast does ? thanks for your help !!!


Solution

  • You seem to be confused between modelling and simulation. You are also wrong about auto.arima().

    auto.arima() does allow exogenous variables via the xreg argument. Read the help file. You can include the exogenous variables for future periods using forecast.Arima(). Again, read the help file.

    It is not clear at all why you are referring to arima.sim() here. It is for simulating ARIMA processes, not for modelling or forecasting.