ADF, KPSS, Engle-Granger

ADF, KPSS, Engle-Granger — unit root and cointegration tests

Synopsis

#include <libgretl.h>

int                 adf_test                            (int order,
                                                         const int *list,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 kpss_test                           (int order,
                                                         const int *list,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 levin_lin_test                      (int vnum,
                                                         const int *plist,
                                                         double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 engle_granger_test                  (int order,
                                                         const int *list,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
double              get_urc_pvalue                      (double tau,
                                                         int n,
                                                         int niv,
                                                         int itv,
                                                         gretlopt opt);

Description

Implementations of the (Augmented) Dickey-Fuller test and the Kwiatkowski, Phillips, Schmidt and Shin test for the presence of a unit root in a time series, along with the Engle-Granger test for cointegration of two or more time series.

The Johansen cointegration test is also provided in libgretl; see johansen_test() and johansen_test_simple().

Details

adf_test ()

int                 adf_test                            (int order,
                                                         const int *list,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Carries out and prints the results of the Augmented Dickey-Fuller test for a unit root.

By default two tests are performed, one for a model including a constant and one including a linear trend. The deterministic components of the model can be controlled via flags in opt as follows: OPT_N, omit the constant; OPT_C, run just one test using the constant; OPT_T, one test including linear trend; OPT_R, one test including a quadratic trend; OPT_D, include seasonal dummy variables.

Additional flags that may be given in opt include: OPT_V for verbose operation; OPT_F to apply first-differencing before testing; OPT_G for GLS preprocessing as in Elliott, Rothenberg and Stock (incompatible with OPT_N, OPT_R, OPT_D); OPT_E to "test down" from a given maximum lag order (see the entry for "adf" in the Gretl Command Reference for details).

order :

lag order for the (augmented) test.

list :

list of variables to test.

pZ :

pointer to data matrix.

pdinfo :

data information struct.

opt :

option flags.

prn :

gretl printing struct.

Returns :

0 on successful completion, non-zero on error.

kpss_test ()

int                 kpss_test                           (int order,
                                                         const int *list,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Carries out and prints the results of the KPSS test for stationarity. Flags that may be given in opt include: OPT_T to include a linear trend; OPT_F to apply first-differencing before testing; OPT_V for verbose operation.

order :

window size for Bartlett smoothing.

list :

list of variables to test.

pZ :

pointer to data array.

pdinfo :

dataset information.

opt :

option flags.

prn :

gretl printing struct.

Returns :

0 on successful completion, non-zero on error.

levin_lin_test ()

int                 levin_lin_test                      (int vnum,
                                                         const int *plist,
                                                         double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Carries out and prints the results of the Levin-Lin-Chu test for a unit root in panel data.

The list plist should contain either a single lag order to be applied to all units, or a set of unit-specific orders; in the latter case the length of the list must equal the number of panel units in the current sample range. (This is a gretl list: the first element holds a count of the number of elements following.)

By default a test with constant is performed, but the (mutually exclusive) options OPT_N and OPT_T in opt switch to the case of no constant or constant plus trend respectively. The OPT_Q flag may be used to suppress printed output.

vnum :

ID number of variable to test.

plist :

list of ADF lag orders.

Z :

data array.

pdinfo :

data information struct.

opt :

option flags.

prn :

gretl printing struct.

Returns :

0 on successful completion, non-zero on error.

engle_granger_test ()

int                 engle_granger_test                  (int order,
                                                         const int *list,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Carries out the Engle-Granger test for cointegration. Flags that may be given in opt include: OPT_N, do not an include a constant in the cointegrating regression; OPT_T include constant and linear trend; OPT_R, include quadratic trend; OPT_S, skip DF tests for individual variables; OPT_E, test down from maximum lag order (see the entry for "adf" in the Gretl Command Reference for details).

order :

lag order for the test.

list :

specifies the variables to use.

pZ :

pointer to data matrix.

pdinfo :

data information struct.

opt :

option flags.

prn :

gretl printing struct.

Returns :

0 on successful completion, non-zero code on error.

get_urc_pvalue ()

double              get_urc_pvalue                      (double tau,
                                                         int n,
                                                         int niv,
                                                         int itv,
                                                         gretlopt opt);

Retrieves the p-value for tau from the Dickey–Fuller unit-root test or the Engle–Granger cointegration test, as per James MacKinnon (1996).

tau :

test statistic.

n :

sample size (or 0 for asymptotic result).

niv :

number of potentially cointegrated variables (1 for simple unit-root test).

itv :

code: 1, 2, 3, 4 for nc, c, ct, ctt models respectively.

opt :

give OPT_G if GLS adjustment was applied in the test from which tau was obtained.

Returns :

p-value, or NADBL on failure.