system

system

Functions

equation_system * equation_system_start ()
char * get_system_name_from_line ()
equation_system * get_anonymous_equation_system ()
int equation_system_append ()
int equation_system_append_multi ()
int system_parse_line ()
int equation_system_finalize ()
int equation_system_estimate ()
int estimate_named_system ()
void equation_system_destroy ()
void delete_anonymous_equation_system ()
int system_want_df_corr ()
int system_n_restrictions ()
int system_max_indep_vars ()
int system_n_indep_vars ()
int * system_get_list ()
int system_get_list_length ()
int * compose_ivreg_list ()
int system_get_depvar ()
const char * system_short_string ()
void equation_system_set_name ()
int system_method_from_string ()
const char * system_method_full_string ()
const char * system_method_short_string ()
int * system_get_endog_vars ()
int * system_get_instr_vars ()
void system_attach_uhat ()
void system_attach_sigma ()
void system_attach_coeffs ()
void system_attach_vcv ()
MODEL * system_get_model ()
int system_get_overid_df ()
int system_vcv_geomean ()
double system_vcv_denom ()
int rhs_var_in_identity ()
void print_equation_system_info ()
void system_set_restriction_matrices ()
int system_normality_test ()
int multi_eqn_wald_test ()
int system_wald_test ()
int system_diag_test ()
double * system_get_resid_series ()
double * equation_system_get_series ()
gretl_matrix * equation_system_get_matrix ()
int highest_numbered_var_in_system ()
int equation_system_serialize ()
int equation_system_bundlize ()
int gretl_system_print ()
int system_print_sigma ()
const gretl_matrix * system_get_forecast_matrix ()
gretl_matrix * sys_get_fitted_values ()
int system_adjust_t1t2 ()
int system_supports_method ()
equation_system * equation_system_from_XML ()
int system_save_and_print_results ()
int system_autocorrelation_test ()
int system_arch_test ()
MODEL single_equation_liml ()
int gretl_system_get_sample ()

Types and Values

enum GretlSystemMethods
typedef id_atom
typedef identity
typedef predet
typedef liml_data
struct equation_system_

Description

Functions

equation_system_start ()

equation_system *
equation_system_start (const char *param,
                       const char *name,
                       gretlopt opt,
                       int *err);

Start compiling an equation system. Either param must contain an estimation method or the system must be given a name. If a method is given, the system will be estimated as soon as its definition is complete. If a name is given, the system definition is saved on a stack and it can subsequently be estimated via various methods. If both a name and an estimation method are given, the system is both estimated and saved.

Parameters

param

may incude an estimation method spec.

 

name

the name to be given to system, if any, otherwise NULL or an empty string.

 

opt

may include OPT_I for iterative estimation (will be ignored if the the estimation method does not support it).

 

err

location to receive error code.

 

Returns

pointer to a new equation system, or NULL on error.


get_system_name_from_line ()

char *
get_system_name_from_line (const char *s);

get_anonymous_equation_system ()

equation_system *
get_anonymous_equation_system (void);

equation_system_append ()

int
equation_system_append (equation_system *sys,
                        const int *list);

Adds an equation, as represented by list , to sys .

Parameters

sys

initialized equation system.

 

list

list containing dependent variable and regressors.

 

Returns

0 on success, non-zero on failure, in which case sys is destroyed.


equation_system_append_multi ()

int
equation_system_append_multi (equation_system *sys,
                              const char *parm1,
                              const char *parm2,
                              const DATASET *dset);

Adds one or more equations to sys as follows.

If parm2 is NULL then parm1 is taken to be the name of a matrix, and we interpret the rows of the specified matrix as lists. Lists of differing length can be accommodated by padding unused trailing elements of short rows with zeros.

If parm2 is non-NULL then parm1 is taken to be the name of a list of regressands, one per equation; parm2 , pertaining to regressors, should be the name of a list if the regressors are in common across the equations or an array of lists (one per equation) otherwise.

Parameters

sys

initialized equation system.

 

parm1

the name of a pre-defined matrix or list.

 

parm2

the name of list or array of lists (or NULL).

 

dset

pointer to dataset struct.

 

Returns

0 on success, non-zero on failure, in which case sys is destroyed.


system_parse_line ()

int
system_parse_line (equation_system *sys,
                   const char *line,
                   DATASET *dset);

Modifies sys according to the command supplied in line , which must start with "identity" (and supply an identity to be added to the system, or "endog" (and supply a list of endogenous variables), or "instr" (and supply a list of instrumental variables).

Parameters

sys

initialized equation system.

 

line

command line.

 

dset

dataset struct.

 

Returns

0 on success, non-zero on failure, in which case sys is destroyed.


equation_system_finalize ()

int
equation_system_finalize (equation_system *sys,
                          DATASET *dset,
                          gretlopt opt,
                          PRN *prn);

Finalize an equation system, e.g. in response to "end system". If the system has a specified name, we save it on a stack of defined systems. If it has a specified estimation method, we go ahead and estimate it. If it has both, we do both.

Parameters

sys

pre-defined equation system.

 

dset

dataset struct.

 

opt

may include OPT_V for verbose operation, OPT_S to permit estimation of a single equation, OPT_R for a robust variance matrix (OLS only), OPT_N for no df correction (OLS and TSLS only).

 

prn

printing struct.

 

Returns

0 on success, non-zero on error. If the system is mal-formed, it is destroyed.


equation_system_estimate ()

int
equation_system_estimate (equation_system *sys,
                          DATASET *dset,
                          gretlopt opt,
                          PRN *prn);

Estimate a pre-defined equation system and print the results to prn .

Parameters

sys

pre-defined equation system.

 

dset

dataset struct.

 

opt

may include OPT_V for more verbose operation.

 

prn

printing struct.

 

Returns

0 on success, non-zero on error.


estimate_named_system ()

int
estimate_named_system (const char *sysname,
                       const char *param,
                       DATASET *dset,
                       gretlopt opt,
                       PRN *prn);

equation_system_destroy ()

void
equation_system_destroy (equation_system *sys);

delete_anonymous_equation_system ()

void
delete_anonymous_equation_system (int level);

system_want_df_corr ()

int
system_want_df_corr (const equation_system *sys);

system_n_restrictions ()

int
system_n_restrictions (const equation_system *sys);

system_max_indep_vars ()

int
system_max_indep_vars (const equation_system *sys);

system_n_indep_vars ()

int
system_n_indep_vars (const equation_system *sys);

system_get_list ()

int *
system_get_list (const equation_system *sys,
                 int i);

system_get_list_length ()

int
system_get_list_length (const equation_system *sys,
                        int i);

compose_ivreg_list ()

int *
compose_ivreg_list (const equation_system *sys,
                    int i);

system_get_depvar ()

int
system_get_depvar (const equation_system *sys,
                   int i);

system_short_string ()

const char *
system_short_string (const MODEL *pmod);

equation_system_set_name ()

void
equation_system_set_name (equation_system *sys,
                          const char *name);

system_method_from_string ()

int
system_method_from_string (const char *s);

system_method_full_string ()

const char *
system_method_full_string (int method);

system_method_short_string ()

const char *
system_method_short_string (int method);

system_get_endog_vars ()

int *
system_get_endog_vars (const equation_system *sys);

system_get_instr_vars ()

int *
system_get_instr_vars (const equation_system *sys);

system_attach_uhat ()

void
system_attach_uhat (equation_system *sys,
                    gretl_matrix *E);

system_attach_sigma ()

void
system_attach_sigma (equation_system *sys,
                     gretl_matrix *S);

system_attach_coeffs ()

void
system_attach_coeffs (equation_system *sys,
                      gretl_matrix *b);

system_attach_vcv ()

void
system_attach_vcv (equation_system *sys,
                   gretl_matrix *vcv);

system_get_model ()

MODEL *
system_get_model (const equation_system *sys,
                  int i);

system_get_overid_df ()

int
system_get_overid_df (const equation_system *sys);

system_vcv_geomean ()

int
system_vcv_geomean (const equation_system *sys);

system_vcv_denom ()

double
system_vcv_denom (const equation_system *sys,
                  int i,
                  int j);

rhs_var_in_identity ()

int
rhs_var_in_identity (const equation_system *sys,
                     int lhsvar,
                     int rhsvar);

print_equation_system_info ()

void
print_equation_system_info (const equation_system *sys,
                            const DATASET *dset,
                            gretlopt opt,
                            PRN *prn);

Prints details of an equation system to prn .

Parameters

sys

gretl equation system.

 

dset

dataset information.

 

opt

use OPT_H for printing in a form designed to appear in the header when results of estimation are printed.

 

prn

printing struct.

 

system_set_restriction_matrices ()

void
system_set_restriction_matrices (equation_system *sys,
                                 gretl_matrix *R,
                                 gretl_matrix *q);

system_normality_test ()

int
system_normality_test (const equation_system *sys,
                       gretlopt opt,
                       PRN *prn);

multi_eqn_wald_test ()

int
multi_eqn_wald_test (const gretl_matrix *b,
                     const gretl_matrix *V,
                     const gretl_matrix *R,
                     const gretl_matrix *q,
                     int dfu,
                     gretlopt opt,
                     PRN *prn);

system_wald_test ()

int
system_wald_test (const equation_system *sys,
                  const gretl_matrix *R,
                  const gretl_matrix *q,
                  gretlopt opt,
                  PRN *prn);

system_diag_test ()

int
system_diag_test (const equation_system *sys,
                  double *test,
                  double *pval);

system_get_resid_series ()

double *
system_get_resid_series (equation_system *sys,
                         int eqnum,
                         DATASET *dset,
                         int *err);

equation_system_get_series ()

double *
equation_system_get_series (const equation_system *sys,
                            const DATASET *dset,
                            int idx,
                            const char *key,
                            int *err);

equation_system_get_matrix ()

gretl_matrix *
equation_system_get_matrix (const equation_system *sys,
                            int idx,
                            int *err);

highest_numbered_var_in_system ()

int
highest_numbered_var_in_system (const equation_system *sys,
                                const DATASET *dset);

equation_system_serialize ()

int
equation_system_serialize (equation_system *sys,
                           SavedObjectFlags flags,
                           PRN *prn);

equation_system_bundlize ()

int
equation_system_bundlize (equation_system *sys,
                          gretl_bundle *b);

gretl_system_print ()

int
gretl_system_print (equation_system *sys,
                    const DATASET *dset,
                    gretlopt opt,
                    PRN *prn);

system_print_sigma ()

int
system_print_sigma (const equation_system *sys,
                    PRN *prn);

system_get_forecast_matrix ()

const gretl_matrix *
system_get_forecast_matrix (equation_system *sys,
                            int t1,
                            int t2,
                            DATASET *dset,
                            gretlopt opt,
                            int *err);

sys_get_fitted_values ()

gretl_matrix *
sys_get_fitted_values (equation_system *sys,
                       int v,
                       int t1,
                       int t2,
                       const DATASET *dset,
                       int *err);

system_adjust_t1t2 ()

int
system_adjust_t1t2 (equation_system *sys,
                    const DATASET *dset);

system_supports_method ()

int
system_supports_method (equation_system *sys,
                        int method);

equation_system_from_XML ()

equation_system *
equation_system_from_XML (xmlNodePtr node,
                          xmlDocPtr doc,
                          int *err);

system_save_and_print_results ()

int
system_save_and_print_results (equation_system *sys,
                               DATASET *dset,
                               gretlopt opt,
                               PRN *prn);

system_autocorrelation_test ()

int
system_autocorrelation_test (equation_system *sys,
                             int order,
                             gretlopt opt,
                             PRN *prn);

system_arch_test ()

int
system_arch_test (equation_system *sys,
                  int order,
                  gretlopt opt,
                  PRN *prn);

single_equation_liml ()

MODEL
single_equation_liml (const int *list,
                      DATASET *dset,
                      gretlopt opt);

gretl_system_get_sample ()

int
gretl_system_get_sample (const equation_system *sys,
                         int *t1,
                         int *t2);

Types and Values

enum GretlSystemMethods

Members

SYS_METHOD_SUR

   

SYS_METHOD_3SLS

   

SYS_METHOD_FIML

   

SYS_METHOD_LIML

   

SYS_METHOD_OLS

   

SYS_METHOD_TSLS

   

SYS_METHOD_WLS

   

SYS_METHOD_MAX

   

id_atom

typedef struct id_atom_ id_atom;

identity

typedef struct identity_ identity;

predet

typedef struct predet_ predet;

liml_data

typedef struct liml_data_ liml_data;

struct equation_system_

struct equation_system_ {
    char *name;                 /* user-specified name for system, or NULL */
    int refcount;               /* for saving/deleting */
    int fd;                     /* function execution depth */
    int t1;                     /* starting observation number */
    int t2;                     /* ending observation number */
    int smpl_t1;                /* first obs in sample range */
    int smpl_t2;                /* last obs in sample range */
    int T;                      /* number of observations per equation */
    int df;                     /* T - average coeffs per equation */
    int method;                 /* estimation method */
    int neqns;                  /* number of stochastic equations */
    int nidents;                /* number of identities */
    int order;                  /* max lag of endogenous variable */
    int iters;                  /* number of iterations taken */
    int flags;                  /* to record options */
    double ll;                  /* log-likelihood (restricted) */
    double llu;                 /* unrestricted log-likelihood */
    double X2;                  /* chi-square test value */
    double ess;                 /* total error sum of squares */
    double diag_test;           /* test stat for diagonal covariance matrix */
    double bdiff;               /* summary stat for change in coefficients */
    double ldet;                /* log-determinant of covariance matrix */
    int **lists;                /* regression lists for stochastic equations */
    int **tslists;              /* back-up of TSLS-style lists */
    int *ylist;                 /* list of endogenous variables */
    int *ilist;                 /* list of instruments */
    int *xlist;                 /* list of truly exogenous variables */
    int *plist;                 /* list of predetermined variables */
    int *biglist;               /* list of all variables, for data checking */
    predet *pre_vars;           /* array of info on predetermined regressors */
    identity **idents;          /* set of identities */
    gretl_matrix *b;            /* coefficient estimates */
    gretl_matrix *vcv;          /* covariance matrix of coefficients */
    gretl_matrix *S;            /* cross-equation covariance matrix */
    gretl_matrix *R;            /* LHS of any linear restrictions */
    gretl_matrix *q;            /* RHS of any linear restrictions */

    gretl_matrix *E;            /* residuals, all equations */
    gretl_matrix *yhat;         /* fitted values, all equations */
    gretl_matrix *Gamma;        /* structural form Gamma matrix (endog + identities)*/
    gretl_matrix *B;            /* structural form B matrix (exogenous) */
    gretl_matrix *A;            /* structural form A matrix (lagged endogenous) */
    gretl_matrix *F;            /* forecast matrix */
    gretl_matrix *Sr;           /* reduced-form error covariance matrix */
    MODEL **models;             /* set of pointers to per-equation models */
    liml_data *ldata;           /* extra info from LIML estimation */
};