rerror-handlingtime-seriesautoregressive-models

Simulating ar(2) model generates an error message


I am new to simulation especially when it comes to time series and so I apologize if this question seems too naive. I am trying to understand why simulating this ar(2) model generates an error:

arima.sim(list(order = c(2, 0, 0), ar = c(0.7, 0.3)), n = time_n, sd=0.2) 
Error in arima.sim(list(order = c(2, 0, 0), ar = c(0.7, 0.3)), n = time_n,  : 
  'ar' part of model is not stationary

Any pointer will be appreciated!


Solution

  • According to theory (e.g. see here), in order for an autoregressive model to be stationary, if r are the roots of the autoregressive polynomial

    1 - phi_1 x - phi_2 x ...
    

    then

    The linear AR(p) process is strictly stationary and ergodic if and only if |rj|>1 for all j, where |rj| is the modulus of the complex number rj.

    In your case

    polyroot(c(1, -0.7, -0.3))
    

    gives (1,-3.333)

    In fact, this is the actual code within arima.sim:

      minroots <- min(Mod(polyroot(c(1, -model$ar))))
        if (minroots <= 1) 
            stop("'ar' part of model is not stationary")
    

    Looking at the patterns and being lazy about the math, I suspect that the criterion for AR2 translates to (ph1 + phi2 < 1).