I am building a dynamic regression model in Stata which basically has this form: $$Y = a_1x_1 + a_2x_2 +... + e$$ where the error $e$ is then modeled as ARIMA process.

Is there a command to find optimal ARIMA order for the error? In R we can use the auto_arima function to do it; how can I do this in Stata?

  • $\begingroup$ Isn't it auto.arima()? Also, you don't have any lags of $y$ in the equation. $\endgroup$
    – dimitriy
    May 5, 2014 at 21:10
  • $\begingroup$ auto.arima()? Is that a function in Stata? I didnt find any in my version .. is that in a new one? Lags of y would come in the arima model of error. $\endgroup$ May 5, 2014 at 21:28
  • $\begingroup$ I believe it is called auto.arima() in R (part of the forecast package), and not auto_arima(). $\endgroup$
    – dimitriy
    May 5, 2014 at 21:30

1 Answer 1


There's no automated Stata version as far as I know.

The Hyndman-Khandakar algorithm that auto.arima() uses to pick p,d, and q is described here. The basic steps are:

  1. The number of differences d is determined using repeated KPSS tests.
  2. The values of p and q are then chosen by minimizing the AICc after differencing the data d times. Rather than considering every possible combination of p and q, the algorithm uses a stepwise search to traverse the model space.

(a) The best model (with smallest AICc) is selected from the following four:

  • ARIMA(2,d,2)
  • ARIMA(0,d,0)
  • ARIMA(1,d,0)
  • ARIMA(0,d,1).

If d=0 then the constant c is included; if d≥1 then the constant c is set to zero. This is called the "current model".

(b) Variations on the current model are considered:

  • vary p and/or q from the current model by ±1
  • include/exclude c from the current model.

The best model considered so far (either the current model, or one of these variations) becomes the new current model.

(c) Repeat Step 2(b) until no lower AICc can be found.

All of the tests/statistics involved can be calculated with Stata, so you could achieve something similar by hand, and automate it with a bit more effort. For KPSS, use Chris Baum's kpss from SSC. You can get the corrected AIC by using estat ic and this formula.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.