| Libgretl Reference Manual |
|---|
systemsystem — |
enum gretl_system_methods; typedef id_atom; typedef identity; struct gretl_equation_system_; void make_system_data_info (gretl_equation_system *sys, int eqn, DATAINFO *pdinfo, int v, int code); gretl_equation_system* system_start (const char *line, gretlopt opt); char* get_system_name_from_line (const char *s); int gretl_equation_system_append (gretl_equation_system *sys, const int *list); int system_parse_line (gretl_equation_system *sys, const char *line, const DATAINFO *pdinfo); int gretl_equation_system_finalize (gretl_equation_system *sys, double ***pZ, DATAINFO *pdinfo, PRN *prn); int gretl_equation_system_estimate (gretl_equation_system *sys, double ***pZ, DATAINFO *pdinfo, gretlopt opt, PRN *prn); int estimate_named_system (const char *line, double ***pZ, DATAINFO *pdinfo, gretlopt opt, PRN *prn); void gretl_equation_system_destroy (gretl_equation_system *sys); const char* system_get_full_string (const gretl_equation_system *sys); int system_save_uhat (const gretl_equation_system *sys); int system_save_yhat (const gretl_equation_system *sys); int system_save_vcv (const gretl_equation_system *sys); int system_want_df_corr (const gretl_equation_system *sys); int system_n_restrictions (const gretl_equation_system *sys); int system_max_indep_vars (const gretl_equation_system *sys); int system_n_indep_vars (const gretl_equation_system *sys); int system_adjust_t1t2 (gretl_equation_system *sys, int *t1, int *t2, const double **Z); int* system_get_list (const gretl_equation_system *sys, int i); int* compose_tsls_list (gretl_equation_system *sys, int i); int system_get_depvar (const gretl_equation_system *sys, int i); const char* gretl_system_short_string (const MODEL *pmod); void gretl_system_set_name (gretl_equation_system *sys, const char *name); int gretl_system_method_from_string (const char *s); const char* system_method_full_string (int method); const char* system_method_short_string (int method); int* system_get_endog_vars (const gretl_equation_system *sys); int* system_get_instr_vars (const gretl_equation_system *sys); void system_attach_uhat (gretl_equation_system *sys, gretl_matrix *uhat); void system_attach_sigma (gretl_equation_system *sys, gretl_matrix *sigma); void system_attach_coeffs (gretl_equation_system *sys, gretl_matrix *b); void system_attach_vcv (gretl_equation_system *sys, gretl_matrix *vcv); MODEL* system_get_model (const gretl_equation_system *sys, int i); int system_get_overid_df (const gretl_equation_system *sys); int system_vcv_geomean (const gretl_equation_system *sys); double system_vcv_denom (const gretl_equation_system *sys, int i, int j); int rhs_var_in_identity (const gretl_equation_system *sys, int lhsvar, int rhsvar); void print_equation_system_info (const gretl_equation_system *sys, const DATAINFO *pdinfo, gretlopt opt, PRN *prn); void system_set_restriction_matrices (gretl_equation_system *sys, gretl_matrix *R, gretl_matrix *q); int system_normality_test (const gretl_equation_system *sys, PRN *prn); int gretl_system_add_resids_to_dataset (gretl_equation_system *sys, int eqnum, double ***pZ, DATAINFO *pdinfo); double* gretl_equation_system_get_series (const gretl_equation_system *sys, const DATAINFO *pdinfo, int idx, const char *key, int *err); gretl_matrix* gretl_equation_system_get_matrix (const gretl_equation_system *sys, int idx, int *err); int highest_numbered_var_in_system (const gretl_equation_system *sys, const DATAINFO *pdinfo); int gretl_system_serialize (gretl_equation_system *sys, SavedObjectFlags flags, FILE *fp); void gretl_system_set_save_flag (gretl_equation_system *sys); void gretl_system_unset_save_flag (gretl_equation_system *sys); int gretl_system_save_flag_set (gretl_equation_system *sys); gretl_equation_system* gretl_system_from_XML (xmlNodePtr node, xmlDocPtr doc, int *err);
typedef enum {
SYS_SUR = 0,
SYS_3SLS,
SYS_FIML,
SYS_LIML,
SYS_OLS,
SYS_TSLS,
SYS_WLS,
SYS_MAX
} gretl_system_methods;
struct gretl_equation_system_ {
char *name; /* user-specified name for system, or NULL */
int refcount; /* for saving/deleting */
int t1; /* starting observation number */
int t2; /* ending observation number */
int method; /* estimation method */
int n_equations; /* number of stochastic equations */
int n_identities; /* number of identities */
int n_obs; /* number of observations per equation */
int iters; /* number of iterations taken */
char flags; /* to record options (e.g. save residuals) */
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 stat for diagonal covariance matrix */
double bdiff; /* summary stat for change in coefficients */
int **lists; /* regression lists for stochastic equations */
int *endog_vars; /* list of endogenous variables */
int *instr_vars; /* list of instruments (exogenous vars) */
identity **idents; /* set of identities */
gretl_matrix *b; /* coefficient estimates */
gretl_matrix *vcv; /* covariance matrix of coefficients */
gretl_matrix *sigma; /* cross-equation covariance matrix */
gretl_matrix *R; /* LHS of any linear restrictions */
gretl_matrix *q; /* RHS of any linear restrictions */
gretl_matrix *uhat; /* residuals, all equations */
MODEL **models; /* set of pointers to per-equation models: just
convenience pointers -- these should NOT be
freed as part of sys cleanup
*/
};
void make_system_data_info (gretl_equation_system *sys, int eqn, DATAINFO *pdinfo, int v, int code);
sys : |
|
eqn : |
|
pdinfo : |
|
v : |
|
code : |
gretl_equation_system* system_start (const char *line, gretlopt opt);
Start compiling an equation system: line must specify a "method"
(estimation method) and/or a name for the system. 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.
line : |
command line. |
opt : |
may include OPT_T for iterative estimation, if the
estimation method supports this.
|
| Returns : | pointer to a new equation system, or NULL on error.
|
int gretl_equation_system_append (gretl_equation_system *sys, const int *list);
Adds an equation (as represented by list) to sys.
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.
|
int system_parse_line (gretl_equation_system *sys, const char *line, const DATAINFO *pdinfo);
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).
sys : |
initialized equation system. |
line : |
command line. |
pdinfo : |
dataset information. |
| Returns : | 0 on success, non-zero on failure, in which case
sys is destroyed.
|
int gretl_equation_system_finalize (gretl_equation_system *sys, double ***pZ, DATAINFO *pdinfo, 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.
sys : |
pre-defined equation system. |
pZ : |
pointer to data array. |
pdinfo : |
dataset information. |
prn : |
printing struct. |
| Returns : | 0 on success, non-zero on error. If the system is mal-formed, it is destroyed. |
int gretl_equation_system_estimate (gretl_equation_system *sys, double ***pZ, DATAINFO *pdinfo, gretlopt opt, PRN *prn);
Estimate a pre-defined equation system and print the results
to prn.
sys : |
pre-defined equation system. |
pZ : |
pointer to data array. |
pdinfo : |
dataset information. |
opt : |
may include OPT_Q for relatively quiet operation.
|
prn : |
printing struct. |
| Returns : | 0 on success, non-zero on error. |
int estimate_named_system (const char *line,
double ***pZ,
DATAINFO *pdinfo,
gretlopt opt,
PRN *prn);
line : |
|
pZ : |
|
pdinfo : |
|
opt : |
|
prn : |
|
| Returns : |
void gretl_equation_system_destroy (gretl_equation_system *sys);
sys : |
const char* system_get_full_string (const gretl_equation_system *sys);
sys : |
|
| Returns : |
int system_n_restrictions (const gretl_equation_system *sys);
sys : |
|
| Returns : |
int system_max_indep_vars (const gretl_equation_system *sys);
sys : |
|
| Returns : |
int system_adjust_t1t2 (gretl_equation_system *sys, int *t1, int *t2, const double **Z);
sys : |
|
t1 : |
|
t2 : |
|
Z : |
|
| Returns : |
int* system_get_list (const gretl_equation_system *sys, int i);
sys : |
|
i : |
|
| Returns : |
int* compose_tsls_list (gretl_equation_system *sys, int i);
sys : |
|
i : |
|
| Returns : |
int system_get_depvar (const gretl_equation_system *sys, int i);
sys : |
|
i : |
|
| Returns : |
const char* gretl_system_short_string (const MODEL *pmod);
pmod : |
|
| Returns : |
void gretl_system_set_name (gretl_equation_system *sys, const char *name);
sys : |
|
name : |
int gretl_system_method_from_string (const char *s);
s : |
|
| Returns : |
const char* system_method_short_string (int method);
method : |
|
| Returns : |
int* system_get_endog_vars (const gretl_equation_system *sys);
sys : |
|
| Returns : |
int* system_get_instr_vars (const gretl_equation_system *sys);
sys : |
|
| Returns : |
void system_attach_uhat (gretl_equation_system *sys, gretl_matrix *uhat);
sys : |
|
uhat : |
void system_attach_sigma (gretl_equation_system *sys, gretl_matrix *sigma);
sys : |
|
sigma : |
void system_attach_coeffs (gretl_equation_system *sys, gretl_matrix *b);
sys : |
|
b : |
void system_attach_vcv (gretl_equation_system *sys, gretl_matrix *vcv);
sys : |
|
vcv : |
MODEL* system_get_model (const gretl_equation_system *sys, int i);
sys : |
|
i : |
|
| Returns : |
int system_get_overid_df (const gretl_equation_system *sys);
sys : |
|
| Returns : |
double system_vcv_denom (const gretl_equation_system *sys, int i, int j);
sys : |
|
i : |
|
j : |
|
| Returns : |
int rhs_var_in_identity (const gretl_equation_system *sys, int lhsvar, int rhsvar);
sys : |
|
lhsvar : |
|
rhsvar : |
|
| Returns : |
void print_equation_system_info (const gretl_equation_system *sys, const DATAINFO *pdinfo, gretlopt opt, PRN *prn);
Prints details of an equation system to prn.
sys : |
gretl equation system. |
pdinfo : |
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. |
void system_set_restriction_matrices (gretl_equation_system *sys, gretl_matrix *R, gretl_matrix *q);
sys : |
|
R : |
|
q : |
int system_normality_test (const gretl_equation_system *sys, PRN *prn);
sys : |
|
prn : |
|
| Returns : |
int gretl_system_add_resids_to_dataset
(gretl_equation_system *sys,
int eqnum,
double ***pZ,
DATAINFO *pdinfo);
sys : |
|
eqnum : |
|
pZ : |
|
pdinfo : |
|
| Returns : |
double* gretl_equation_system_get_series
(const gretl_equation_system *sys,
const DATAINFO *pdinfo,
int idx,
const char *key,
int *err);
sys : |
|
pdinfo : |
|
idx : |
|
key : |
|
err : |
|
| Returns : |
gretl_matrix* gretl_equation_system_get_matrix (const gretl_equation_system *sys, int idx, int *err);
sys : |
|
idx : |
|
err : |
|
| Returns : |
int highest_numbered_var_in_system (const gretl_equation_system *sys, const DATAINFO *pdinfo);
sys : |
|
pdinfo : |
|
| Returns : |
int gretl_system_serialize (gretl_equation_system *sys, SavedObjectFlags flags, FILE *fp);
sys : |
|
flags : |
|
fp : |
|
| Returns : |
void gretl_system_unset_save_flag (gretl_equation_system *sys);
sys : |
int gretl_system_save_flag_set (gretl_equation_system *sys);
sys : |
|
| Returns : |
gretl_equation_system* gretl_system_from_XML (xmlNodePtr node, xmlDocPtr doc, int *err);
node : |
|
doc : |
|
err : |
|
| Returns : |
| << nls | var >> |