Model tests

Model tests — diagnostic and specification tests for models

Functions

double wald_omit_F ()
double wald_omit_chisq ()
int add_test ()
int add_test_full ()
int omit_test ()
int omit_test_full ()
int nonlinearity_test ()
int reset_test ()
int autocorr_test ()
int comfac_test ()
double get_DW_pvalue_for_model ()
int chow_test ()
int chow_test_from_dummy ()
int QLR_test ()
double QLR_pval ()
int cusum_test ()
int panel_specification_test ()
int panel_hausman_test ()
int vif_test ()
int bkw_test ()
int leverage_test ()
int add_leverage_values_to_dataset ()
void print_add_omit_null ()

Types and Values

Includes

#include <libgretl.h>

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.

Functions

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.

Parameters

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.

Parameters

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 (MODEL *pmod,
          const int *addvars,
          DATASET *dset,
          gretlopt opt,
          PRN *prn);

Performs an LM test on pmod for the null hypothesis that the addvars variables do not contribute significant explanatory power.

Parameters

pmod

pointer to model to be tested.

 

addvars

list of variables to test.

 

dset

dataset struct.

 

opt

can contain OPT_Q (quiet) to suppress printing of the auxiliary model, OPT_I to suppress all printing of results.

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


add_test_full ()

int
add_test_full (MODEL *orig,
               MODEL *pmod,
               const int *addvars,
               DATASET *dset,
               gretlopt opt,
               PRN *prn);

Re-estimate a given model after adding the specified variables, and records a joint test on the additional variables.

Parameters

orig

pointer to original model.

 

pmod

pointer to receive augmented model.

 

addvars

list of variables to add to original model.

 

dset

dataset struct.

 

opt

can contain OPT_Q (quiet) to suppress printing of the new model, OPT_O to print its covariance matrix, OPT_I for silent operation.

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


omit_test ()

int
omit_test (MODEL *pmod,
           const int *omitvars,
           DATASET *dset,
           gretlopt opt,
           PRN *prn);

Performs a Wald test on pmod for the null hypothesis that the omitvars variables do not contribute explanatory power.

Parameters

pmod

pointer to model to be tested.

 

omitvars

list of variables to test.

 

dset

dataset struct.

 

opt

can contain OPT_Q (quiet) to suppress printing of results.

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


omit_test_full ()

int
omit_test_full (MODEL *orig,
                MODEL *pmod,
                const int *omitvars,
                DATASET *dset,
                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).

Parameters

orig

pointer to original model.

 

pmod

pointer to receive new model, with vars omitted.

 

omitvars

list of variables to omit from original model.

 

dset

dataset struct.

 

opt

can contain OPT_Q (quiet) to suppress printing of the new model, OPT_O to print its covariance matrix, OPT_I for silent operation; for OPT_A, see below.

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


nonlinearity_test ()

int
nonlinearity_test (MODEL *pmod,
                   DATASET *dset,
                   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.

Parameters

pmod

pointer to original model.

 

dset

dataset struct.

 

aux

AUX_SQ for squares or AUX_LOG for logs

 

opt

if contains OPT_S, save test results to model; if contains OPT_I, run silently.

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


reset_test ()

int
reset_test (MODEL *pmod,
            DATASET *dset,
            gretlopt opt,
            PRN *prn);

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

Parameters

pmod

pointer to model to be tested.

 

dset

dataset struct.

 

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. OPT_I produces silent operation.

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


autocorr_test ()

int
autocorr_test (MODEL *pmod,
               int order,
               DATASET *dset,
               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.

Parameters

pmod

pointer to model to be tested.

 

order

lag order for test.

 

dset

dataset struct.

 

opt

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

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


comfac_test ()

int
comfac_test (MODEL *pmod,
             DATASET *dset,
             gretlopt opt,
             PRN *prn);

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

Parameters

pmod

pointer to original model.

 

dset

dataset struct.

 

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 (MODEL *pmod,
                         DATASET *dset,
                         int *err);

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

Parameters

pmod

model to be tested.

 

dset

dataset struct.

 

err

location to receive error code.

 

Returns

the p-value, or NADBL on error.


chow_test ()

int
chow_test (int splitobs,
           MODEL *pmod,
           DATASET *dset,
           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.)

Parameters

splitobs

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

 

pmod

pointer to model to be tested.

 

dset

dataset struct.

 

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,
                      DATASET *dset,
                      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.

Parameters

splitvar

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

 

pmod

pointer to model to be tested.

 

dset

dataset struct.

 

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,
          DATASET *dset,
          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.

Parameters

pmod

pointer to model to be tested.

 

dset

dataset struct.

 

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_pval ()

double
QLR_pval (double X2,
          int df,
          double p1,
          double p2);

cusum_test ()

int
cusum_test (MODEL *pmod,
            DATASET *dset,
            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; OPT_U governs the associated plot, if wanted.

Parameters

pmod

pointer to model to be tested.

 

dset

dataset struct.

 

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_specification_test ()

int
panel_specification_test (MODEL *pmod,
                          DATASET *dset,
                          gretlopt opt,
                          PRN *prn);

Tests the given pooled model for fixed and random effects.

Parameters

pmod

pointer to model to be tested.

 

dset

dataset struct.

 

opt

option flags.

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


panel_hausman_test ()

int
panel_hausman_test (MODEL *pmod,
                    DATASET *dset,
                    gretlopt opt,
                    PRN *prn);

vif_test ()

int
vif_test (MODEL *pmod,
          DATASET *dset,
          gretlopt opt,
          PRN *prn);

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

Parameters

pmod

pointer to model to be tested.

 

dset

dataset struct.

 

opt

may contain OPT_Q for quiet operation.

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


bkw_test ()

int
bkw_test (MODEL *pmod,
          DATASET *dset,
          gretlopt opt,
          PRN *prn);

Calculates and displays the Belsley-Kuh-Welsch collinearity diagnostics for pmod .

Parameters

pmod

pointer to model to be tested.

 

dset

dataset struct.

 

opt

may contain OPT_Q for quiet operation.

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


leverage_test ()

int
leverage_test (MODEL *pmod,
               DATASET *dset,
               gretlopt opt,
               PRN *prn);

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

Parameters

pmod

pointer to model to be tested.

 

dset

dataset struct.

 

opt

if OPT_S, add calculated series to data set; operate silently if OPT_Q. If includes OPT_O, do not adjust save names (overwrite any existing series of the same names).

 

prn

gretl printing struct.

 

Returns

0 on successful completion, error code on error.


add_leverage_values_to_dataset ()

int
add_leverage_values_to_dataset (DATASET *dset,
                                gretl_matrix *m,
                                gretlopt opt,
                                int flags);

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

Parameters

dset

dataset struct.

 

m

matrix containing leverage values.

 

opt

OPT_O = overwrite series on save.

 

flags

may include SAVE_LEVERAGE, SAVE_INFLUENCE, and/or SAVE_DFFITS.

 

Returns

0 on successful completion, error code on error.


print_add_omit_null ()

void
print_add_omit_null (const int *list,
                     const DATASET *dset,
                     gretlopt opt,
                     PRN *prn);

Types and Values

enum SeriesSaveCode

Members

SAVE_LEVERAGE

   

SAVE_INFLUENCE

   

SAVE_DFFITS

   

SAVE_TREND

   

SAVE_CYCLE

   

enum 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.

Members

AUX_NONE

not an auxiliary regression

 

AUX_SQ

nonlinearity test (squared terms)

 

AUX_LOG

nonlinearity test (log terms)

 

AUX_CHOW

Chow test

 

AUX_ADD

LM test regression for added 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

unused

 

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