Libgretl Reference Manual  

Top  Description 
#include <libgretl.h> int adf_test (int order
,const int *list
,DATASET *dset
,gretlopt opt
,PRN *prn
); int kpss_test (int order
,const int *list
,DATASET *dset
,gretlopt opt
,PRN *prn
); int levin_lin_test (int vnum
,const int *plist
,DATASET *dset
,gretlopt opt
,PRN *prn
); int engle_granger_test (int order
,const int *list
,DATASET *dset
,gretlopt opt
,PRN *prn
); double get_urc_pvalue (double tau
,int n
,int niv
,int itv
,gretlopt opt
);
Implementations of the (Augmented) DickeyFuller test and the Kwiatkowski, Phillips, Schmidt and Shin test for the presence of a unit root in a time series, along with the EngleGranger 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()
.
int adf_test (int order
,const int *list
,DATASET *dset
,gretlopt opt
,PRN *prn
);
Carries out and prints the results of the Augmented DickeyFuller 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 firstdifferencing
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).

lag order for the (augmented) test. 

list of variables to test. 

dataset struct. 

option flags. 

gretl printing struct. 
Returns : 
0 on successful completion, nonzero on error. 
int kpss_test (int order
,const int *list
,DATASET *dset
,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
firstdifferencing before testing; OPT_V for verbose
operation.

window size for Bartlett smoothing. 

list of variables to test. 

dataset struct. 

option flags. 

gretl printing struct. 
Returns : 
0 on successful completion, nonzero on error. 
int levin_lin_test (int vnum
,const int *plist
,DATASET *dset
,gretlopt opt
,PRN *prn
);
Carries out and prints the results of the LevinLinChu 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 unitspecific
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.

ID number of variable to test. 

list of ADF lag orders. 

data information struct. 

option flags. 

gretl printing struct. 
Returns : 
0 on successful completion, nonzero on error. 
int engle_granger_test (int order
,const int *list
,DATASET *dset
,gretlopt opt
,PRN *prn
);
Carries out the EngleGranger 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); OPT_V,
verbose operation.

lag order for the test. 

specifies the variables to use. 

dataset struct. 

option flags. 

gretl printing struct. 
Returns : 
0 on successful completion, nonzero code on error. 
double get_urc_pvalue (double tau
,int n
,int niv
,int itv
,gretlopt opt
);
Retrieves the pvalue for tau
from the Dickey–Fuller
unitroot test or the Engle–Granger cointegration
test, as per James MacKinnon (1996).

test statistic. 

sample size (or 0 for asymptotic result). 

number of potentially cointegrated variables (1 for simple unitroot test). 

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

give OPT_G if GLS adjustment was applied in
the test from which tau was obtained. 
Returns : 
pvalue, or NADBL on failure. 