Model tests

Model tests — diagnostic and specification tests for models

Synopsis

#include <libgretl.h>

enum                SeriesSaveCode;
enum                ModelAuxCode;
double              wald_omit_F                         (const int *list,
                                                         MODEL *pmod);
double              wald_omit_chisq                     (const int *list,
                                                         MODEL *pmod);
int                 add_test                            (const int *addvars,
                                                         MODEL *orig,
                                                         MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 omit_test                           (const int *omitvars,
                                                         MODEL *orig,
                                                         MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 nonlinearity_test                   (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         ModelAuxCode aux,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 reset_test                          (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 autocorr_test                       (MODEL *pmod,
                                                         int order,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 comfac_test                         (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
double              get_DW_pvalue_for_model             (const MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         int *err);
int                 chow_test                           (int splitobs,
                                                         MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 chow_test_from_dummy                (int splitvar,
                                                         MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 QLR_test                            (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 cusum_test                          (MODEL *pmod,
                                                         double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 panel_hausman_test                  (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 vif_test                            (MODEL *pmod,
                                                         double **Z,
                                                         DATAINFO *pdinfo,
                                                         PRN *prn);
int                 leverage_test                       (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 add_leverage_values_to_dataset      (double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretl_matrix *m,
                                                         int flags);

Description

Included here are several tests for "pathologies" of the error term in regression models, as well as specification tests covering nonlinearity and the omission or addition of variables.

Details

enum SeriesSaveCode

typedef enum {
    SAVE_LEVERAGE  = 1 << 0,
    SAVE_INFLUENCE = 1 << 1,
    SAVE_DFFITS    = 1 << 2,
    SAVE_TREND     = 1 << 3,
    SAVE_CYCLE     = 1 << 4
} SeriesSaveCode;


enum ModelAuxCode

typedef enum {
    AUX_NONE, 
    AUX_SQ,
    AUX_LOG,
    AUX_CHOW,
    AUX_ADD,
    AUX_AR,
    AUX_ARCH,
    AUX_WHITE,
    AUX_COINT,
    AUX_DF,
    AUX_ADF,
    AUX_KPSS, 
    AUX_OMIT, 
    AUX_RESET,
    AUX_SYS,
    AUX_VAR,
    AUX_VECM,
    AUX_JOHANSEN,
    AUX_GROUPWISE,
    AUX_HET_1,
    AUX_BP,
    AUX_AUX,
    AUX_COMFAC,
    AUX_BIPROB
} ModelAuxCode;

Symbolic names to keep track of auxiliary regression models, which are estimated either for the purpose of carrying out some sort of diagnostic test or which form part of a multi-equation system.

AUX_NONE

not an auxiliary regression

AUX_SQ

nonlinearity test (squared terms)

AUX_LOG

nonlinearity test (log terms)

AUX_CHOW

Chow test

AUX_ADD

test for adding variables

AUX_AR

autocorrelation test

AUX_ARCH

ARCH test

AUX_WHITE

heteroskedasticity (White's test)

AUX_COINT

cointegration test

AUX_DF

Dickey-Fuller test

AUX_ADF

augmented Dickey-Fuller test

AUX_KPSS

KPSS unit-root test

AUX_OMIT

test for omission of variables

AUX_RESET

Ramsey's RESET

AUX_SYS

single equation from multivariate system

AUX_VAR

single equation from VAR system

AUX_VECM

single equation from VECM system

AUX_JOHANSEN

Johansen cointegration test

AUX_GROUPWISE

test for groupwise heteroskedasticity

AUX_HET_1

Pesaran-Taylor HET_1 test

AUX_BP

Breusch-Pagan heteroskedastcity test

AUX_AUX

auxiliary regression not otherwise specified

AUX_COMFAC

common factor test

AUX_BIPROB

biprobit initializer

wald_omit_F ()

double              wald_omit_F                         (const int *list,
                                                         MODEL *pmod);

Simple form of Wald F-test for omission of variables. If list is non-NULL, do the test for the omission of the variables in list from the model pmod. Otherwise test for omission of all variables in pmod except for the constant.

list :

list of variables to omit, or NULL.

pmod :

model to be tested.

Returns :

Calculated F-value, or NADBL on failure.

wald_omit_chisq ()

double              wald_omit_chisq                     (const int *list,
                                                         MODEL *pmod);

Simple form of Wald chi-square for omission of variables. If list is non-NULL, do the test for the omission of the variables in list from the model pmod. Otherwise test for omission of all variables in pmod except for the constant.

list :

list of variables to omit, or NULL.

pmod :

model to be tested.

Returns :

Calculated chi-square value, or NADBL on failure.

add_test ()

int                 add_test                            (const int *addvars,
                                                         MODEL *orig,
                                                         MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Re-estimate a given model after adding the specified variables.

addvars :

list of variables to add to original model.

orig :

pointer to original model.

pmod :

pointer to receive new model, with vars added.

pZ :

pointer to data matrix.

pdinfo :

information on the data set.

opt :

can contain OPT_Q (quiet) to suppress printing of the new model, OPT_O to print covariance matrix, OPT_I for silent operation. Additional options that are applicable only for 2SLS models: OPT_B (add to both list of regressors and list of instruments), OPT_T (add to list of instruments only).

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

omit_test ()

int                 omit_test                           (const int *omitvars,
                                                         MODEL *orig,
                                                         MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Re-estimate a given model after removing the variables specified in omitvars. Or if OPT_A is given, proceed sequentially, at each step dropping the least significant variable provided its p-value is above a certain threshold (currently 0.10, two-sided). Or if omitvars is NULL and orig was not estimated using two-stage least squares, drop the last independent variable in orig.

omitvars :

list of variables to omit from original model.

orig :

pointer to original model.

pmod :

pointer to receive new model, with vars omitted.

pZ :

pointer to data array.

pdinfo :

information on the data set.

opt :

can contain OPT_Q (quiet) to suppress printing of the new model, OPT_O to print covariance matrix, OPT_I for silent operation; for OPT_A, see below. Additional options that are applicable only for IV models: OPT_B (omit from both list of regressors and list of instruments), OPT_T (omit from list of instruments only).

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

nonlinearity_test ()

int                 nonlinearity_test                   (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         ModelAuxCode aux,
                                                         gretlopt opt,
                                                         PRN *prn);

Run an auxiliary regression to test pmod for nonlinearity, via the addition of either squares or logs of the original indepdendent variables.

pmod :

pointer to original model.

pZ :

pointer to data array.

pdinfo :

information on the data set.

aux :

AUX_SQ for squares or AUX_LOG for logs

opt :

if contains OPT_S, save test results to model.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

reset_test ()

int                 reset_test                          (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Carries out and prints Ramsey's RESET test for model specification.

pmod :

pointer to model to be tested.

pZ :

pointer to data matrix.

pdinfo :

information on the data set.

opt :

if contains OPT_S, save test results to model. OPT_Q suppresses the printout of the auxiliary regression. OPT_R and OPT_C stand for "squares only" and "cubes only", respectively.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

autocorr_test ()

int                 autocorr_test                       (MODEL *pmod,
                                                         int order,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Tests the given model for autocorrelation of order equal to the specified value, or equal to the frequency of the data if the supplied order is zero. Prints TR^2 and LMF test statistics.

pmod :

pointer to model to be tested.

order :

lag order for test.

pZ :

pointer to data matrix.

pdinfo :

information on the data set.

opt :

if flags include OPT_S, save test results to model; if OPT_Q, be less verbose.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

comfac_test ()

int                 comfac_test                         (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

If pmod was estimated via an AR(1) estimator, run an auxiliary regression to test the implied common-factor restriction.

pmod :

pointer to original model.

pZ :

pointer to data array.

pdinfo :

information on the data set.

opt :

if contains OPT_S, save test results to model.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

get_DW_pvalue_for_model ()

double              get_DW_pvalue_for_model             (const MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         int *err);

Computes the p-value for the Durbin-Watson statistic for the given model, using the Imhof method.

pmod :

model to be tested.

pZ :

pointer to data array.

pdinfo :

dataset information.

err :

location to receive error code.

Returns :

the p-value, or NADBL on error.

chow_test ()

int                 chow_test                           (int splitobs,
                                                         MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Tests the given model for structural stability (Chow test) using the sample break-point given by splitobs and prints the results to prn. (The second portion of the sample runs from observation splitobs to the end of the original sample range.)

splitobs :

the 0-based observation number at which to split the sample.

pmod :

pointer to model to be tested.

pZ :

pointer to data array.

pdinfo :

dataset information.

opt :

if flags include OPT_S, save test results to model.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

chow_test_from_dummy ()

int                 chow_test_from_dummy                (int splitvar,
                                                         MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Tests the given model for structural stability (Chow test), using the dummy variable specified by splitvar to divide the original sample range of pmod into two portions.

splitvar :

the ID number of a dummy variable that should be used to divide the sample.

pmod :

pointer to model to be tested.

pZ :

pointer to data array.

pdinfo :

dataset information.

opt :

if flags include OPT_S, save test results to model.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

QLR_test ()

int                 QLR_test                            (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Tests the given model for structural stability via the Quandt Likelihood Ratio test for a structural break at an unknown point in the sample range.

pmod :

pointer to model to be tested.

pZ :

pointer to data array.

pdinfo :

dataset information.

opt :

if flags include OPT_S, save test results to model.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

cusum_test ()

int                 cusum_test                          (MODEL *pmod,
                                                         double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Tests the given model for parameter stability via the CUSUM test, or if opt includes OPT_R, via the CUSUMSQ test; OPT_Q makes the test quiet.

pmod :

pointer to model to be tested.

Z :

data array.

pdinfo :

information on the data set.

opt :

if flags include OPT_S, save results of test to model.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

panel_hausman_test ()

int                 panel_hausman_test                  (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Tests the given pooled model for fixed and random effects.

pmod :

pointer to model to be tested.

pZ :

pointer to data matrix.

pdinfo :

information on the data set.

opt :

option flags.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

vif_test ()

int                 vif_test                            (MODEL *pmod,
                                                         double **Z,
                                                         DATAINFO *pdinfo,
                                                         PRN *prn);

Calculates and displays the Variance Inflation Factors for the independent variables in the given model.

pmod :

pointer to model to be tested.

Z :

pointer to data matrix.

pdinfo :

information on the data set.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

leverage_test ()

int                 leverage_test                       (MODEL *pmod,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

Tests the data used in the given model for points with high leverage and influence on the estimates.

pmod :

pointer to model to be tested.

pZ :

pointer to data matrix.

pdinfo :

information on the data set.

opt :

if OPT_S, add calculated series to data set.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

add_leverage_values_to_dataset ()

int                 add_leverage_values_to_dataset      (double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretl_matrix *m,
                                                         int flags);

Adds to the working dataset one or more series calculated by the gretl test for leverage/influence of data points.

pZ :

pointer to data array.

pdinfo :

dataset information.

m :

matrix containing leverage values.

flags :

may include SAVE_LEVERAGE, SAVE_INFLUENCE, and/or SAVE_DFFITS.

Returns :

0 on successful completion, error code on error.