help for egranger

Engle-Granger (EG) and Augmented Engle-Granger (AEG) cointegration tests and 2- > step ECM estimation

egranger varlist [, ecm Lags(#) TRend QTRend REGress ]


egranger conducts tests for cointegration proposed by Engle and Granger (1987), reporting test statistics plus critical values calculated by MacKinnon (1990, 2010). egranger will also estimate an ECM (Error Correction Mechanism) model using the 2-step procedure proposed by Engle and Granger (1987).

egranger requires Stata 9.0 or higher.

Engle-Granger tests for cointegration

The Engle-Granger (EG) test for cointegration is a two-step residual-based test. Say that we suspect that the variables y, x_1, ..., x_k are cointegrated. The simplest form of the test is performed as follows. First, y is regressed on a constant and x_1, ..., x_k and the residuals are calculated. Then, the first difference of the residuals is regressed on the lagged level of the residuals without a constant. The test statistic is the traditional OLS t-statistic on the lagged residual. Under the null hypothesis that y and x_1, ..., x_k are not cointegrated, the residual should be non-stationary, hence the resemblance of the EG test to the Dickey-Fuller test for non-stationarity (see dfuller). Rejection of the null is evidence the residual is stationary, i.e., that the series are indeed cointegrated.

The EG test requires the error terms to be serially independent. If this is not the case, lags of the first difference of the residual can be included in the second (test) regression so that the residuals in that regression appear serially uncorrelated. This version of the test is usually known as the Augmented Engle-Granger (AEG) test. The number of desired lags is specified by the lags(#) option.

A linear or quadratic trend may be included in the first-step regression by using the trend or qtrend options.

The distributions of the EG/AEG test statistics are non-standard, and depend on the number of series being tested, the sample size, and whether a linear or quadratic trend is included. MacKinnon (1990, 2010) has computed response surface regressions which provide critical values for all these cases. These are the critical reported by egranger.

The EG/AEG test can be seen as a robust alternative to the Johansen tests for cointegration available via Stata's vecrank. The EG test makes fewer distributional assumptions, but, unlike vecrank, does not allow the identification of the number of cointegrating vectors. In some applications this last limitation may not be important, e.g., in the bivariate case when there are only two variables and hence at most one cointegrating relationship.

Engle-Granger two-step ECM model estimation

Engle and Granger (1987) also proposed a two-step method for estimating ECM (Error Correction Mechanism) models.

The first step is identical to the first step in the EG/AEG test procedure described above. In the second step, the first difference of y is regressed on the lagged level of the first-step residual and the lagged first differences of x_1, ..., x_k using OLS. The coefficient on the lagged residual is an estimate of the ECM "speed of correction" parameter.

The EG two-step ECM estimation is obtained by specifying the ecm option. Lags of y and x can be included by specifying the lags(#) option: lags(1) causes the lagged first difference of y to be added to the second-step ECM alongside the lagged first difference of x; lags(tau) where tau>1 causes lags 1..tau of the first differences of y and x to appear in the second-step ECM.

Saved results and postestimation options

egranger uses Stata's regress to estimate the test regression and ECM. All the main regress results are preserved after egranger has run. This allows the user to employ Stata's built-in postestimation commands for regress after egranger is used. In particular, the standard regress postestimation commands can be used to obtain information criteria and to test for serial correlation in the EG/AEG test regression or ECM estimation regression.

In addition to the standard regress results, egranger saves the following:

Variables _egresid First-step residuals

Scalars e(lags) Number of lags in the test or second-step regression e(N1) Sample size in the first-step regression e(N2) Sample size in the second-step regression

Scalars (EG and AEG tests only) e(Zt) EG/AEG test statistic e(cv1) EG/AEG 1% critical value e(cv5) EG/AEG 5% critical value e(cv10) EG/AEG 10% critical value


ecm requests that the Engle-Granger two-step ECM is estimated. The default is to report the EG/AEG cointegration test.

lags(#) specifies the number of lags of the first difference of the residuals to include in the AEG test regression or the number of lags of first differences of the potentially cointegrating variables to include in the ECM second-step regression.

trend specifies that a linear trend is included in the first-step regression.

qtrend specifies that a quadratic trend is included in the first-step regression.

regress requests that the first-step and (if applicable) EG/AEG test regressions are reported.


(Cointegration test)

. webuse rdinc

. egranger ln_ne ln_se

. egranger ln_ne ln_se, lags(2)

. egranger ln_ne ln_se, lags(2) trend

. egranger ln_ne ln_se ln_me, lags(1) qtrend

(Report the internal 1st-step and test regressions)

. egranger ln_ne ln_se, lags(2) regress

(Replicate the above test by hand)

. regress ln_ne ln_se

. predict double resid, res

. regress D.resid L.resid L(1/2)D.resid, nocons

(Two-step ECM estimation)

. egranger ln_ne ln_se, ecm

(Use lags(#) option)

. egranger ln_ne ln_se, ecm lags(2)

(Report the internal 1st-step regression)

. egranger ln_ne ln_se, ecm lags(2) regress

(Replicate the above 2-step ECM estimation by hand)

. regress ln_ne ln_se

. capture drop resid

. predict double resid, res

. regress D.ln_ne L.resid L(1/2)D.(ln_ne ln_se)


egranger is not an official Stata command. It is a free contribution to the research community, like a paper. Please cite it as such:

Schaffer, M.E. 2010. egranger: Engle-Granger (EG) and Augmented Engle-Granger (AEG) cointegration tests and 2-step ECM estimation. http://ideas.repec.org/c/boc/bocode/s457210.html


Engle, R.F. and Granger, C.W.J. 1987. "Co-integration and Error Correction: Representation, Estimation and Testing" Econometrica, Vol. 55, pp. 251276.

MacKinnon, James G. 1990, 2010. Critical Values for Cointegration Tests. Queen's Economics Department Working Paper No. 1227, Queen's University, Kingston, Ontario, Canada. Available at http://ideas.repec.org/p/qed/wpaper/1227.html.


Mark E Schaffer, Heriot-Watt University, UK m.e.schaffer@hw.ac.uk


Thanks to Julia Darby and the students in the SGPE QM1 course for the impetus for writing this program, and to Kit Baum for feedback on the program and help file.

Also see

Manual: [TS] dfuller; [TS] vec intro; [TS] vecrank On-line: help for dfuller; vec intro; vecrank