gretl_model

gretl_model

Synopsis

enum                ArmaFlags;
typedef             CoeffIntervals;
enum                VCVMajorType;
enum                MLVCVType;
enum                HACKernel;
enum                PanelVCVType;
enum                RQVCVType;
typedef             VCVInfo;
#define             MODEL_COMMAND                       (c)
#define             AR_MODEL                            (c)
#define             SIMPLE_AR_MODEL                     (c)
#define             ML_ESTIMATOR                        (c)
#define             LIMDEP                              (c)
#define             COUNT_MODEL                         (c)
#define             LSQ_MODEL                           (c)
#define             ASYMPTOTIC_MODEL                    (c)
#define             NONLIST_MODEL                       (c)
#define             is_model_ref_cmd                    (c)
#define             RQ_SPECIAL_MODEL                    (m)
#define             POOLED_MODEL                        (m)
enum                ModelTestType;
MODEL *             gretl_model_new                     (void);
void                gretl_model_init                    (MODEL *pmod);
int                 gretl_model_allocate_storage        (MODEL *pmod);
MODEL **            gretl_model_array_new               (int n);
MODEL **            allocate_working_models             (int n);
void                gretl_model_array_destroy           (MODEL **models,
                                                         int n);
void                destroy_working_models              (MODEL **models,
                                                         int n);
void                gretl_model_smpl_init               (MODEL *pmod,
                                                         const DATAINFO *pdinfo);
void                impose_model_smpl                   (const MODEL *pmod,
                                                         DATAINFO *pdinfo);
void                gretl_model_set_auxiliary           (MODEL *pmod,
                                                         ModelAuxCode aux);
void                clear_model                         (MODEL *pmod);
void                gretl_model_free                    (MODEL *pmod);
void                clear_model_xpx                     (MODEL *pmod);
void                gretl_model_free_on_exit            (MODEL *pmod);
void                display_model_data_items            (const MODEL *pmod);
int                 gretl_model_set_data_with_destructor
                                                        (MODEL *pmod,
                                                         const char *key,
                                                         void *ptr,
                                                         GretlType type,
                                                         size_t size,
                                                         void (*destructor) (void *));
int                 gretl_model_set_data                (MODEL *pmod,
                                                         const char *key,
                                                         void *ptr,
                                                         GretlType type,
                                                         size_t size);
int                 gretl_model_set_matrix_as_data      (MODEL *pmod,
                                                         const char *key,
                                                         gretl_matrix *m);
int                 gretl_model_set_list_as_data        (MODEL *pmod,
                                                         const char *key,
                                                         int *list);
int                 gretl_model_set_string_as_data      (MODEL *pmod,
                                                         const char *key,
                                                         char *str);
int                 gretl_model_destroy_data_item       (MODEL *pmod,
                                                         const char *key);
int                 gretl_model_detach_data_item        (MODEL *pmod,
                                                         const char *key);
int                 gretl_model_set_int                 (MODEL *pmod,
                                                         const char *key,
                                                         int val);
int                 gretl_model_set_double              (MODEL *pmod,
                                                         const char *key,
                                                         double val);
int                 gretl_model_set_full_vcv_info       (MODEL *pmod,
                                                         int vmaj,
                                                         int vmin,
                                                         int order,
                                                         int flags,
                                                         double bw);
int                 gretl_model_set_vcv_info            (MODEL *pmod,
                                                         int vmaj,
                                                         int vmin);
void *              gretl_model_get_data                (const MODEL *pmod,
                                                         const char *key);
void *              gretl_model_get_data_and_size       (const MODEL *pmod,
                                                         const char *key,
                                                         size_t *sz);
int                 gretl_model_get_int                 (const MODEL *pmod,
                                                         const char *key);
double              gretl_model_get_double              (const MODEL *pmod,
                                                         const char *key);
int *               gretl_model_get_list                (const MODEL *pmod,
                                                         const char *key);
char *              gretl_model_get_param_name          (const MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         int i,
                                                         char *targ);
int                 gretl_model_get_param_number        (const MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         const char *s);
void                free_coeff_intervals                (CoeffIntervals *cf);
CoeffIntervals *    gretl_model_get_coeff_intervals     (const MODEL *pmod,
                                                         const DATAINFO *pdinfo);
int                 reset_coeff_intervals               (CoeffIntervals *cf,
                                                         double alpha);
int                 gretl_model_get_depvar              (const MODEL *pmod);
const char *        gretl_model_get_depvar_name         (const MODEL *pmod,
                                                         const DATAINFO *pdinfo);
int *               gretl_model_get_x_list              (const MODEL *pmod);
int *               gretl_model_get_secondary_list      (const MODEL *pmod);
int                 arma_model_nonseasonal_AR_order     (const MODEL *pmod);
int                 arma_model_nonseasonal_MA_order     (const MODEL *pmod);
int                 arma_model_max_AR_lag               (const MODEL *pmod);
int                 arma_model_max_MA_lag               (const MODEL *pmod);
int                 arma_model_integrated_AR_MA_coeffs  (const MODEL *pmod,
                                                         double **phi_star,
                                                         double **theta_star);
int                 regarma_model_AR_coeffs             (const MODEL *pmod,
                                                         double **phi0,
                                                         int *pp);
const double *      arma_model_get_x_coeffs             (const MODEL *pmod);
int                 regarima_model_get_AR_coeffs        (const MODEL *pmod,
                                                         double **phi0,
                                                         int *pp);
int *               arima_delta_coeffs                  (int d,
                                                         int D,
                                                         int s);
int                 gretl_model_set_coeff_separator     (MODEL *pmod,
                                                         const char *s,
                                                         int pos);
int                 gretl_model_get_coeff_separator     (const MODEL *pmod,
                                                         const char **ps,
                                                         int *ppos);
int                 gretl_model_new_vcv                 (MODEL *pmod,
                                                         int *nelem);
int                 gretl_model_write_vcv               (MODEL *pmod,
                                                         const gretl_matrix *V,
                                                         int k);
VMatrix *           gretl_model_get_vcv                 (MODEL *pmod,
                                                         const DATAINFO *pdinfo);
int                 gretl_model_write_coeffs            (MODEL *pmod,
                                                         double *b,
                                                         int k);
int                 gretl_model_add_arinfo              (MODEL *pmod,
                                                         int nterms);
MODEL *             gretl_model_copy                    (const MODEL *pmod);
void                swap_models                         (MODEL *targ,
                                                         MODEL *src);
int                 command_ok_for_model                (int test_ci,
                                                         gretlopt opt,
                                                         int mci);
int                 model_test_ok                       (int ci,
                                                         gretlopt opt,
                                                         const MODEL *pmod,
                                                         const DATAINFO *pdinfo);
int                 gretl_is_simple_OLS                 (const MODEL *pmod);
int                 gretl_is_arima_model                (const MODEL *pmod);
int                 get_first_model_stat                (const char **word,
                                                         const char **desc);
int                 get_next_model_stat                 (const char **word,
                                                         const char **desc);
int                 get_model_count                     (void);
void                set_model_count                     (int c);
int                 model_count_plus                    (void);
void                model_count_minus                   (void);
void                set_model_id                        (MODEL *pmod);
ModelTest *         model_test_new                      (ModelTestType ttype);
void                model_test_free                     (ModelTest *test);
int                 maybe_add_test_to_model             (MODEL *pmod,
                                                         ModelTest *test);
void                model_test_set_teststat             (ModelTest *test,
                                                         unsigned char ts);
void                model_test_set_order                (ModelTest *test,
                                                         int order);
void                model_test_set_dfn                  (ModelTest *test,
                                                         int df);
void                model_test_set_dfd                  (ModelTest *test,
                                                         int df);
void                model_test_set_value                (ModelTest *test,
                                                         double val);
void                model_test_set_pvalue               (ModelTest *test,
                                                         double pval);
void                model_test_set_param                (ModelTest *test,
                                                         const char *s);
void                model_test_set_opt                  (ModelTest *test,
                                                         gretlopt opt);
void                model_test_set_allocated_param      (ModelTest *test,
                                                         char *s);
void                model_test_set_crit_and_alpha       (ModelTest *test,
                                                         double crit,
                                                         double alpha);
void                gretl_model_test_print              (const MODEL *pmod,
                                                         int i,
                                                         PRN *prn);
void                gretl_model_print_last_test         (const MODEL *pmod,
                                                         PRN *prn);
void                gretl_model_test_print_direct       (const ModelTest *test,
                                                         int heading,
                                                         PRN *prn);
void                gretl_model_destroy_tests           (MODEL *pmod);
void                model_list_to_string                (int *list,
                                                         char *buf);
int                 highest_numbered_var_in_model       (const MODEL *pmod,
                                                         const DATAINFO *pdinfo);
int                 mle_criteria                        (MODEL *pmod,
                                                         int addk);
double              coeff_pval                          (int ci,
                                                         double x,
                                                         int df);
int                 exact_fit_check                     (const MODEL *pmod,
                                                         PRN *prn);
int                 gretl_model_allocate_params         (MODEL *pmod,
                                                         int k);
int                 gretl_model_add_arma_varnames       (MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         int yno,
                                                         int p,
                                                         int q,
                                                         const char *pmask,
                                                         const char *qmask,
                                                         int P,
                                                         int Q,
                                                         int r);
int                 gretl_model_add_panel_varnames      (MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         const int *ulist);
void                gretl_model_add_allocated_varnames  (MODEL *pmod,
                                                         char **vnames);
int                 gretl_model_add_y_median            (MODEL *pmod,
                                                         const double *y);
int                 gretl_model_add_normality_test      (MODEL *pmod,
                                                         double X2);
int                 gretl_model_get_normality_test      (const MODEL *pmod,
                                                         PRN *prn);
char *              gretl_model_get_fitted_formula      (const MODEL *pmod,
                                                         int xvar,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo);
void                gretl_model_set_name                (MODEL *pmod,
                                                         const char *name);
const char *        gretl_model_get_name                (const MODEL *pmod);
double              gretl_model_get_scalar              (const MODEL *pmod,
                                                         ModelDataIndex idx,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         int *err);
double *            gretl_model_get_series              (MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         ModelDataIndex idx,
                                                         int *err);
gretl_matrix *      gretl_model_get_matrix              (MODEL *pmod,
                                                         ModelDataIndex idx,
                                                         int *err);
double              gretl_model_get_data_element        (MODEL *pmod,
                                                         int idx,
                                                         const char *s,
                                                         const DATAINFO *pdinfo,
                                                         int *err);
int                 gretl_model_serialize               (const MODEL *pmod,
                                                         SavedObjectFlags flags,
                                                         FILE *fp);
int                 attach_model_tests_from_xml         (MODEL *pmod,
                                                         xmlNodePtr node);
MODEL *             gretl_model_from_XML                (xmlNodePtr node,
                                                         xmlDocPtr doc,
                                                         const DATAINFO *pdinfo,
                                                         int *err);

Description

Details

enum ArmaFlags

typedef enum {
    ARMA_X12A  = 1 << 0, /* using X-12-ARIMA to generate estimates */
    ARMA_EXACT = 1 << 1, /* using exact ML */
    ARMA_LS    = 1 << 2, /* using conditional ML, and O/NLS == CML */
    ARMA_OLS   = 1 << 3  /* OLS == MLE */
} ArmaFlags;


CoeffIntervals

typedef struct CoeffIntervals_ CoeffIntervals;


enum VCVMajorType

typedef enum {
    VCV_CLASSICAL,
    VCV_HC,
    VCV_HAC,
    VCV_ML,
    VCV_PANEL,
    VCV_RQ
} VCVMajorType;


enum MLVCVType

typedef enum {
    VCV_UNSET,
    VCV_HESSIAN,
    VCV_IM,
    VCV_OP,
    VCV_QML,
    VCV_BW,
    VCV_MAX
} MLVCVType;


enum HACKernel

typedef enum {
    KERNEL_BARTLETT,
    KERNEL_PARZEN,
    KERNEL_QS,
    KERNEL_MAX
} HACKernel;


enum PanelVCVType

typedef enum {
    PANEL_HAC,
    PANEL_BK   /* Beck-Katz */
} PanelVCVType;


enum RQVCVType

typedef enum {
    RQ_ASY,
    RQ_NID    /* sandwich */
} RQVCVType;


VCVInfo

typedef struct VCVInfo_ VCVInfo;


MODEL_COMMAND()

#define             MODEL_COMMAND(c)


AR_MODEL()

#define             AR_MODEL(c)


SIMPLE_AR_MODEL()

#define SIMPLE_AR_MODEL(c) (c == AR || c == AR1)


ML_ESTIMATOR()

#define             ML_ESTIMATOR(c)


LIMDEP()

#define             LIMDEP(c)


COUNT_MODEL()

#define COUNT_MODEL(c) (c == POISSON || c == NEGBIN)


LSQ_MODEL()

#define             LSQ_MODEL(c)


ASYMPTOTIC_MODEL()

#define             ASYMPTOTIC_MODEL(c)


NONLIST_MODEL()

#define NONLIST_MODEL(c) (c == NLS || c == MLE || c == GMM)


is_model_ref_cmd()

#define             is_model_ref_cmd(c)


RQ_SPECIAL_MODEL()

#define             RQ_SPECIAL_MODEL(m)


POOLED_MODEL()

#define             POOLED_MODEL(m)


enum ModelTestType

typedef enum {
    GRETL_TEST_ADD,
    GRETL_TEST_ARCH,
    GRETL_TEST_AUTOCORR,
    GRETL_TEST_CHOW,
    GRETL_TEST_CUSUM,
    GRETL_TEST_QLR,
    GRETL_TEST_GROUPWISE,
    GRETL_TEST_LOGS,
    GRETL_TEST_NORMAL,
    GRETL_TEST_OMIT,
    GRETL_TEST_RESET,
    GRETL_TEST_SQUARES,
    GRETL_TEST_WHITES,
    GRETL_TEST_SARGAN,
    GRETL_TEST_IV_HAUSMAN,
    GRETL_TEST_PANEL_HAUSMAN,
    GRETL_TEST_PANEL_F,
    GRETL_TEST_PANEL_BP,
    GRETL_TEST_PANEL_TIMEDUM,
    GRETL_TEST_HET_1,
    GRETL_TEST_BP,
    GRETL_TEST_CHOWDUM,
    GRETL_TEST_COMFAC,
    GRETL_TEST_INDEP,
    GRETL_TEST_MAX
} ModelTestType;


gretl_model_new ()

MODEL *             gretl_model_new                     (void);

Allocates memory for a gretl MODEL struct and initializes the struct, using gretl_model_init().

Returns :

pointer to model (or NULL if allocation fails).

gretl_model_init ()

void                gretl_model_init                    (MODEL *pmod);

Initializes a gretl MODEL, including setting its pointer members to NULL. This initialization should be done if the caller has declared a MODEL struct directly, rather than obtaining a pointer to MODEL using gretl_model_new() (in which case the initialization is done automatically).

pmod :

pointer to model.

gretl_model_allocate_storage ()

int                 gretl_model_allocate_storage        (MODEL *pmod);

Allocates space for coefficients and standard errors, residuals and fitted values in pmod. The sizes of the arrays are based on the ncoeff and full_n members of pmod, which must be set first. The residuals and fitted values are initialized to gretl's missing value.

pmod :

pointer to model.

Returns :

0 on success, E_ALLOC on error.

gretl_model_array_new ()

MODEL **            gretl_model_array_new               (int n);

Allocates memory for an array of n gretl MODEL structs and initializes each model using gretl_model_init().

n :

number of models in array.

Returns :

pointer to models array (or NULL if allocation fails).

allocate_working_models ()

MODEL **            allocate_working_models             (int n);

Allocates memory for an array of n gretl MODEL structs and initializes each model using gretl_model_init(). The models are "protected" against deletion.

n :

number of models in array.

Returns :

pointer to models array (or NULL if allocation fails).

gretl_model_array_destroy ()

void                gretl_model_array_destroy           (MODEL **models,
                                                         int n);

Frees all resources associated with an array of models, which should have been obtained via gretl_model_array_new().

models :

array of gretl models.

n :

number of models in array.

destroy_working_models ()

void                destroy_working_models              (MODEL **models,
                                                         int n);


gretl_model_smpl_init ()

void                gretl_model_smpl_init               (MODEL *pmod,
                                                         const DATAINFO *pdinfo);

Records the start and end of the current sample range in the model pmod, which may be necessary for future reference if a hypothesis test is to be performed. Note that this sample range may not be the same as the data range over which the model is actually estimated (for example, in the case of autoregressive models where observations have to be dropped to allow for lags).

pmod :

pointer to model.

pdinfo :

dataset information.

impose_model_smpl ()

void                impose_model_smpl                   (const MODEL *pmod,
                                                         DATAINFO *pdinfo);

Sets on pdinfo the sample range (starting and ending observations) that was in effect when pmod was estimated. This is not always the same as the data range over which pmod was actually estimated (e.g. in case of autoregressive models, where observations are dropped to allow for lags).

pmod :

pointer to model.

pdinfo :

dataset information.

gretl_model_set_auxiliary ()

void                gretl_model_set_auxiliary           (MODEL *pmod,
                                                         ModelAuxCode aux);

Sets an auxiliary code on pmod, which may be relevant for how the model is printed.

pmod :

pointer to model.

aux :

code indicating a model's function in an auxiliary role (typically, in relation to a hypothesis test on another model).

clear_model ()

void                clear_model                         (MODEL *pmod);

Clears a gretl MODEL, freeing all allocated storage and setting pointer members to NULL. Also frees any data pointers attached via gretl_model_set_data(). The model pointer itself is not freed, so this function may be called on a MODEL which has been declared directly by the caller (by passing the address of the MODEL).

pmod :

pointer to model.

gretl_model_free ()

void                gretl_model_free                    (MODEL *pmod);

Free allocated content of pmod then the pointer itself.

pmod :

pointer to MODEL.

clear_model_xpx ()

void                clear_model_xpx                     (MODEL *pmod);


gretl_model_free_on_exit ()

void                gretl_model_free_on_exit            (MODEL *pmod);

Free allocated content of pmod then the pointer itself, without regard to the model's reference count.

pmod :

pointer to MODEL.

display_model_data_items ()

void                display_model_data_items            (const MODEL *pmod);


gretl_model_set_data_with_destructor ()

int                 gretl_model_set_data_with_destructor
                                                        (MODEL *pmod,
                                                         const char *key,
                                                         void *ptr,
                                                         GretlType type,
                                                         size_t size,
                                                         void (*destructor) (void *));

Attaches data to pmod: the data can be retrieved later using gretl_model_get_data(). Note that the data are not "physically" copied to the model; simply, ptr is recorded on the model. This means that the data referenced by the pointer now in effect belong to pmod. When pmod is cleared with clear_model(), destructor will be invoked with ptr as its single argument. If a simple "free" is OK for freeing the data, you can use gretl_model_set_data() instead.

The size is needed in case the model is copied with copy_model(), in which case the target of the copying operation receives a newly allocated copy of the data in question.

pmod :

pointer to MODEL.

key :

key string for data, used in retrieval.

ptr :

data-pointer to be attached to model.

type :

type of data to set.

size :

size of data in bytes.

destructor :

pointer to function that should be used to free the data-pointer in question.

Returns :

0 on success, 1 on failure.

gretl_model_set_data ()

int                 gretl_model_set_data                (MODEL *pmod,
                                                         const char *key,
                                                         void *ptr,
                                                         GretlType type,
                                                         size_t size);

Attaches data to pmod: the data can be retrieved later using gretl_model_get_data(). Note that the data are not "physically" copied to the model; simply, ptr is recorded on the model. This means that the data referenced by the pointer now in effect belong to pmod. The data pointer will be freed when pmod is cleared with clear_model(). If the data has deep structure that requires special treatment on freeing, use gretl_model_set_data_with_destructor() instead.

The size is needed in case the model is copied with copy_model(), in which case the target of the copying operation receives a newly allocated copy of the data in question.

pmod :

pointer to MODEL.

key :

key string for data, used in retrieval.

ptr :

data-pointer to be attached to model.

type :

type of the data to set.

size :

size of data in bytes.

Returns :

0 on success, 1 on failure.

gretl_model_set_matrix_as_data ()

int                 gretl_model_set_matrix_as_data      (MODEL *pmod,
                                                         const char *key,
                                                         gretl_matrix *m);

Attaches m to pmod as data, recoverable via the key key using gretl_model_get_data().

pmod :

pointer to MODEL.

key :

key string, used in retrieval.

m :

matrix to attach.

Returns :

0 on success, 1 on failure.

gretl_model_set_list_as_data ()

int                 gretl_model_set_list_as_data        (MODEL *pmod,
                                                         const char *key,
                                                         int *list);

Attaches list to pmod as data, recoverable via the key key using gretl_model_get_data(). Note that the model takes ownership of the supplied list.

pmod :

pointer to MODEL.

key :

key string, used in retrieval.

list :

list to attach.

Returns :

0 on success, 1 on failure.

gretl_model_set_string_as_data ()

int                 gretl_model_set_string_as_data      (MODEL *pmod,
                                                         const char *key,
                                                         char *str);

Attaches str to pmod as data, recoverable via the key key using gretl_model_get_data().

pmod :

pointer to MODEL.

key :

key string, used in retrieval.

str :

string to attach.

Returns :

0 on success, 1 on failure.

gretl_model_destroy_data_item ()

int                 gretl_model_destroy_data_item       (MODEL *pmod,
                                                         const char *key);

Looks up the data pointer, attached to pmod, that is identified by key, and if a pointer is found, frees it (or applies the destructor function that was set for the item, if any) and removes it from the model's list of data items. If you want to remove the item from the model's list without freeing the underlying data pointer, use gretl_model_detach_data_item().

pmod :

pointer to model.

key :

key string.

Returns :

0 on success, 1 on failure (pointer not found).

gretl_model_detach_data_item ()

int                 gretl_model_detach_data_item        (MODEL *pmod,
                                                         const char *key);

Looks up the data item, attached to pmod, that is identified by key, and if an item is found, removes it from the model's list of such items. The data pointer associated with key is not touched. If you want the underlying resources associated with key to be freed, use gretl_model_destroy_data_item().

pmod :

pointer to model.

key :

key string.

Returns :

0 on success, 1 on failure (key not found).

gretl_model_set_int ()

int                 gretl_model_set_int                 (MODEL *pmod,
                                                         const char *key,
                                                         int val);

Records an integer value on a model: the value can be retrieved later using gretl_model_get_int(), using the appropriate key.

pmod :

pointer to MODEL.

key :

key string, used in retrieval.

val :

integer value to set.

Returns :

0 on success, 1 on failure.

gretl_model_set_double ()

int                 gretl_model_set_double              (MODEL *pmod,
                                                         const char *key,
                                                         double val);

Records a floating-point value on pmod: the value can be retrieved later using gretl_model_get_double() with the appropriate key.

pmod :

pointer to model.

key :

key string, used in retrieval.

val :

double-precision value to set.

Returns :

0 on success, 1 on failure.

gretl_model_set_full_vcv_info ()

int                 gretl_model_set_full_vcv_info       (MODEL *pmod,
                                                         int vmaj,
                                                         int vmin,
                                                         int order,
                                                         int flags,
                                                         double bw);

Returns :

0 on success, 1 on failure.

gretl_model_set_vcv_info ()

int                 gretl_model_set_vcv_info            (MODEL *pmod,
                                                         int vmaj,
                                                         int vmin);

pmod :

pointer to model.

Returns :

0 on success, 1 on failure.

gretl_model_get_data ()

void *              gretl_model_get_data                (const MODEL *pmod,
                                                         const char *key);

pmod :

pointer to model.

key :

key string.

Returns :

the data pointer identified by key, or NULL on failure.

gretl_model_get_data_and_size ()

void *              gretl_model_get_data_and_size       (const MODEL *pmod,
                                                         const char *key,
                                                         size_t *sz);

pmod :

pointer to model.

key :

key string.

sz :

location to receive the size of the data.

Returns :

the data pointer identified by key, or NULL on failure.

gretl_model_get_int ()

int                 gretl_model_get_int                 (const MODEL *pmod,
                                                         const char *key);

pmod :

pointer to model.

key :

key string.

Returns :

the integer value identified by key, or 0 on failure.

gretl_model_get_double ()

double              gretl_model_get_double              (const MODEL *pmod,
                                                         const char *key);

pmod :

pointer to model.

key :

key string.

Returns :

the double-precision value identified by key, or NADBL on failure.

gretl_model_get_list ()

int *               gretl_model_get_list                (const MODEL *pmod,
                                                         const char *key);

pmod :

pointer to model.

key :

key string.

Returns :

the list of integers identified by key, or NULL on failure.

gretl_model_get_param_name ()

char *              gretl_model_get_param_name          (const MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         int i,
                                                         char *targ);

Writes the appropriate parameter name into targ, which should be at least VNAMELEN bytes long. Usually this is the name of a variable in the dataset, but sometimes it is a special string (e.g. for nonlinear models).

pmod :

pointer to model.

pdinfo :

dataset information.

i :

index number for parameter, zero-based, corresponding to position in the coeff array in pmod.

targ :

string into which to write param name.

Returns :

targ.

gretl_model_get_param_number ()

int                 gretl_model_get_param_number        (const MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         const char *s);

pmod :

pointer to model.

pdinfo :

dataset information.

s :

name of model parameter.

Returns :

the zero-based index of the coefficient in pmod corresponding to s, or -1 if s is not the name of a parameter.

free_coeff_intervals ()

void                free_coeff_intervals                (CoeffIntervals *cf);


gretl_model_get_coeff_intervals ()

CoeffIntervals *    gretl_model_get_coeff_intervals     (const MODEL *pmod,
                                                         const DATAINFO *pdinfo);

Save the 95 percent confidence intervals for the parameter estimates in pmod.

pmod :

pointer to gretl model.

pdinfo :

dataset information.

Returns :

pointer to CONFINT struct containing the results.

reset_coeff_intervals ()

int                 reset_coeff_intervals               (CoeffIntervals *cf,
                                                         double alpha);

Recomputes the intervals in cf using the given value of alpha.

cf :

pointer to confidence intervals struct.

alpha :

nominal non-coverage, as decimal.

Returns :

0 on success, non-zero if alpha is out of bounds.

gretl_model_get_depvar ()

int                 gretl_model_get_depvar              (const MODEL *pmod);

pmod :

pointer to gretl model.

Returns :

the ID number of the dependent variable in pmod.

gretl_model_get_depvar_name ()

const char *        gretl_model_get_depvar_name         (const MODEL *pmod,
                                                         const DATAINFO *pdinfo);

pmod :

pointer to gretl model.

pdinfo :

dataset information.

Returns :

the name of the dependent variable in pmod.

gretl_model_get_x_list ()

int *               gretl_model_get_x_list              (const MODEL *pmod);

pmod :

pointer to gretl model.

Returns :

an allocated copy of the list of independent variables included in pmod, or NULL on failure.

gretl_model_get_secondary_list ()

int *               gretl_model_get_secondary_list      (const MODEL *pmod);

Retrieve an allocated copy of the secondary list from pmod: e.g. the list of instruments in the case of IVREG, or the selection equation list for HECKIT.

pmod :

model to examine.

Returns :

allocated list or NULL on error.

arma_model_nonseasonal_AR_order ()

int                 arma_model_nonseasonal_AR_order     (const MODEL *pmod);

pmod :

pointer to gretl model.

Returns :

the non-seasonal autoregressive order of pmod, or 0 if pmod is not an ARMA model.

arma_model_nonseasonal_MA_order ()

int                 arma_model_nonseasonal_MA_order     (const MODEL *pmod);

pmod :

pointer to gretl model.

Returns :

the non-seasonal moving-average order of pmod, or 0 if pmod is not an ARMA model.

arma_model_max_AR_lag ()

int                 arma_model_max_AR_lag               (const MODEL *pmod);

pmod :

pointer to gretl model.

Returns :

the maximum autoregressive lag in pmod, or 0 if pmod is not an ARMA model. The maximum AR lag takes into account any differencing (seasonal and/or non-seasonal) in an ARIMA model.

arma_model_max_MA_lag ()

int                 arma_model_max_MA_lag               (const MODEL *pmod);

pmod :

pointer to gretl model.

Returns :

the maximum moving-average lag in pmod, or 0 if pmod is not an ARMA model.

arma_model_integrated_AR_MA_coeffs ()

int                 arma_model_integrated_AR_MA_coeffs  (const MODEL *pmod,
                                                         double **phi_star,
                                                         double **theta_star);

Creates consolidated versions of the AR and MA coefficient vectors from pmod. If pmod includes seasonal ARMA terms, the vectors are suitably expanded to include the interactions between seasonal and non-seasonal terms. If the dependent variable has been differenced, the AR coefficients are integrated to account for the differencing. These are the \Phi^* and \Theta^* as used by Box and Jenkins for forecasting.

The length of these vectors can be determined using gretl_arma_model_get_max_AR_lag() and gretl_arma_model_get_max_MA_lag() respectively.

pmod :

pointer to gretl model.

phi_star :

pointer to receive AR coeff vector.

theta_star :

pointer to receive MA coeff vector.

Returns :

0 on success, non-zero on error.

regarma_model_AR_coeffs ()

int                 regarma_model_AR_coeffs             (const MODEL *pmod,
                                                         double **phi0,
                                                         int *pp);

Creates a consolidated version of the AR coefficients from pmod. If pmod includes seasonal AR terms the vector is suitably expanded to include the interactions between seasonal and non-seasonal terms, but it is not integrated with respect to any differencing of the dependent variable.

pmod :

pointer to gretl model.

phi0 :

pointer to receive AR coeff vector.

pp :

pointer to receive length of phi0.

Returns :

0 on success, non-zero on error.

arma_model_get_x_coeffs ()

const double *      arma_model_get_x_coeffs             (const MODEL *pmod);

pmod :

pointer to gretl model.

Returns :

pointer to the array of coefficients on the exogenous regressors in pmod, or NULL if the model is not ARMA or if there are no such regressors.

regarima_model_get_AR_coeffs ()

int                 regarima_model_get_AR_coeffs        (const MODEL *pmod,
                                                         double **phi0,
                                                         int *pp);


arima_delta_coeffs ()

int *               arima_delta_coeffs                  (int d,
                                                         int D,
                                                         int s);

d :

order of non-seasonal differencing (<= 2)

D :

order of seasonal differencing (<= 2)

s :

seasonal periodicity

Returns :

array of d + s * D coefficients of the lag operator in the expansion of (1-L)^d * (1-L^s)^D. These are given in the negative; for example, if d = 1 then c[0] = 1.

gretl_model_set_coeff_separator ()

int                 gretl_model_set_coeff_separator     (MODEL *pmod,
                                                         const char *s,
                                                         int pos);

Arranges for the insertion of the given string (or a blank line if s is NULL) at the given position in the array of coefficients, when the model is printed. The extra line is printed before coefficient pos, where pos is interpreted as a zero-based index.

pmod :

pointer to model.

s :

informative string (or NULL).

pos :

position in the array of coefficients.

Returns :

0 on success, E_ALLOC on failure.

gretl_model_get_coeff_separator ()

int                 gretl_model_get_coeff_separator     (const MODEL *pmod,
                                                         const char **ps,
                                                         int *ppos);

Retrieves information that has been set on pmod regarding the insertion of an extra line when printing the coefficients, if any.

pmod :

pointer to model.

ps :

location to receive string, if any.

ppos :

location to receive position, if any.

Returns :

1 if such information is present, 0 otherwise.

gretl_model_new_vcv ()

int                 gretl_model_new_vcv                 (MODEL *pmod,
                                                         int *nelem);

Allocates space for a packed coefficient covariance matrix in pmod (if such space is not already allocated). Sets all entries in the array to zero.

pmod :

pointer to model.

nelem :

pointer to receive number of elements in the packed array, or NULL;

Returns :

0 on success, E_ALLOC on error.

gretl_model_write_vcv ()

int                 gretl_model_write_vcv               (MODEL *pmod,
                                                         const gretl_matrix *V,
                                                         int k);

Write the covariance matrix V into the model pmod, using the special packed format that is required by the MODEL struct, and set the standard errors to the square root of the diagonal elements of this matrix.

In case k is less than the dimension of V, only the first k rows and columns will be used (except that if an k value of -1 is given, this says to use all of V).

pmod :

pointer to model.

V :

full covariance matrix.

k :

the number of parameters to include, or -1 for all.

Returns :

0 on success, non-zero code on error.

gretl_model_get_vcv ()

VMatrix *           gretl_model_get_vcv                 (MODEL *pmod,
                                                         const DATAINFO *pdinfo);

Supplies the caller with a copy of the variance-covariance matrix for the parameter estimates in pmod, in a format suitable for printing. See also free_vcv(). To get the covariance matrix as a gretl_matrix, see gretl_vcv_matrix_from_model().

pmod :

pointer to model.

pdinfo :

dataset information.

Returns :

VMatrix struct or NULL on error.

gretl_model_write_coeffs ()

int                 gretl_model_write_coeffs            (MODEL *pmod,
                                                         double *b,
                                                         int k);

Write the coefficients b into the model pmod, whose coefficient array is resized appropriately if need be.

pmod :

pointer to model.

b :

array of coefficients.

k :

number of elements in b.

Returns :

0 on success, non-zero code on error.

gretl_model_add_arinfo ()

int                 gretl_model_add_arinfo              (MODEL *pmod,
                                                         int nterms);

Performs initial setup for structure to hold info on autoregressive coefficients.

pmod :

pointer to model.

nterms :

number of autoregressive coefficients.

Returns :

0 on success, 1 on error.

gretl_model_copy ()

MODEL *             gretl_model_copy                    (const MODEL *pmod);

Does a deep copy of pmod: allocates a new MODEL pointer which has its own allocated copies of all the pointer members of pmod. The only feature of pmod that is not duplicated is the reference count, which is set to zero in the copy.

pmod :

pointer to MODEL to copy.

Returns :

the copied model, or NULL on failure.

swap_models ()

void                swap_models                         (MODEL *targ,
                                                         MODEL *src);

Swaps the content of the two model pointers.

targ :

pointer to target MODEL.

src :

pointer to source MODEL.

command_ok_for_model ()

int                 command_ok_for_model                (int test_ci,
                                                         gretlopt opt,
                                                         int mci);

Check to see if the model-related command in question is meaningful and acceptable in the context of the estimator identified by the command index mci. Note, though, that this function may give a "false positive": to be quite sure, we may need to know more about the model (e.g. specific options used). See also model_test_ok().

test_ci :

index of command to be tested.

opt :

option for command to be tested.

mci :

command index of a gretl model (for example, OLS, WLS or AR1).

Returns :

1 if the command seems OK, otherwise 0.

model_test_ok ()

int                 model_test_ok                       (int ci,
                                                         gretlopt opt,
                                                         const MODEL *pmod,
                                                         const DATAINFO *pdinfo);

A more rigorous version of command_ok_for_model(). Use this function if the extra information is available.

ci :

index of a model test command.

opt :

option associated with test command, if any.

pmod :

the model to be tested.

pdinfo :

dataset information.

Returns :

1 if the test command ci (with possible option opt) is acceptable in the context of the model pmod, and the dataset described by pdinfo, otherwise 0.

gretl_is_simple_OLS ()

int                 gretl_is_simple_OLS                 (const MODEL *pmod);


gretl_is_arima_model ()

int                 gretl_is_arima_model                (const MODEL *pmod);


get_first_model_stat ()

int                 get_first_model_stat                (const char **word,
                                                         const char **desc);


get_next_model_stat ()

int                 get_next_model_stat                 (const char **word,
                                                         const char **desc);


get_model_count ()

int                 get_model_count                     (void);


set_model_count ()

void                set_model_count                     (int c);


model_count_plus ()

int                 model_count_plus                    (void);


model_count_minus ()

void                model_count_minus                   (void);


set_model_id ()

void                set_model_id                        (MODEL *pmod);


model_test_new ()

ModelTest *         model_test_new                      (ModelTestType ttype);

ttype :

type of test to add.

Returns :

new ModelTest pointer, or NULL on failure.

model_test_free ()

void                model_test_free                     (ModelTest *test);

test :

object to free.

maybe_add_test_to_model ()

int                 maybe_add_test_to_model             (MODEL *pmod,
                                                         ModelTest *test);

Adds a ModelTest to pmod, if the test in question has not already been performed and recorded. Note that this function takes care of freeing test.

pmod :

pointer to model.

test :

model test to be added.

Returns :

1 if the test was added, otherwise 0.

model_test_set_teststat ()

void                model_test_set_teststat             (ModelTest *test,
                                                         unsigned char ts);


model_test_set_order ()

void                model_test_set_order                (ModelTest *test,
                                                         int order);


model_test_set_dfn ()

void                model_test_set_dfn                  (ModelTest *test,
                                                         int df);


model_test_set_dfd ()

void                model_test_set_dfd                  (ModelTest *test,
                                                         int df);


model_test_set_value ()

void                model_test_set_value                (ModelTest *test,
                                                         double val);


model_test_set_pvalue ()

void                model_test_set_pvalue               (ModelTest *test,
                                                         double pval);


model_test_set_param ()

void                model_test_set_param                (ModelTest *test,
                                                         const char *s);


model_test_set_opt ()

void                model_test_set_opt                  (ModelTest *test,
                                                         gretlopt opt);


model_test_set_allocated_param ()

void                model_test_set_allocated_param      (ModelTest *test,
                                                         char *s);


model_test_set_crit_and_alpha ()

void                model_test_set_crit_and_alpha       (ModelTest *test,
                                                         double crit,
                                                         double alpha);


gretl_model_test_print ()

void                gretl_model_test_print              (const MODEL *pmod,
                                                         int i,
                                                         PRN *prn);


gretl_model_print_last_test ()

void                gretl_model_print_last_test         (const MODEL *pmod,
                                                         PRN *prn);


gretl_model_test_print_direct ()

void                gretl_model_test_print_direct       (const ModelTest *test,
                                                         int heading,
                                                         PRN *prn);


gretl_model_destroy_tests ()

void                gretl_model_destroy_tests           (MODEL *pmod);

Clears any hypothesis test structs that have been attached to pmod.

pmod :

pointer to model.

model_list_to_string ()

void                model_list_to_string                (int *list,
                                                         char *buf);


highest_numbered_var_in_model ()

int                 highest_numbered_var_in_model       (const MODEL *pmod,
                                                         const DATAINFO *pdinfo);


mle_criteria ()

int                 mle_criteria                        (MODEL *pmod,
                                                         int addk);


coeff_pval ()

double              coeff_pval                          (int ci,
                                                         double x,
                                                         int df);


exact_fit_check ()

int                 exact_fit_check                     (const MODEL *pmod,
                                                         PRN *prn);


gretl_model_allocate_params ()

int                 gretl_model_allocate_params         (MODEL *pmod,
                                                         int k);

Allocate an array of k strings to hold the names given to the associated coefficients, in a model where these strings are not simply given by the names of the independent variables.

pmod :

pointer to target model.

k :

number of strings to allocate.

Returns :

0 on success, non-zero on error.

gretl_model_add_arma_varnames ()

int                 gretl_model_add_arma_varnames       (MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         int yno,
                                                         int p,
                                                         int q,
                                                         const char *pmask,
                                                         const char *qmask,
                                                         int P,
                                                         int Q,
                                                         int r);

Composes a set of names to be given to the regressors in an ARMA model.

pmod :

pointer to target model.

pdinfo :

dataset information.

yno :

ID number of dependent variable.

p :

non-seasonal (max) AR order.

q :

non-seasonal (max) MA order.

pmask :

for masking out specific AR lags.

qmask :

for masking out specific MA lags.

P :

seasonal AR order.

Q :

seasonal MA order.

r :

number of exogenous regressors (excluding the constant).

Returns :

0 on success, non-zero on error.

gretl_model_add_panel_varnames ()

int                 gretl_model_add_panel_varnames      (MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         const int *ulist);

Composes a set of names to be given to the regressors in an panel model.

pmod :

pointer to target model.

pdinfo :

dataset information.

ulist :

list of index numbers of cross-sectional units included in the model.

Returns :

0 on success, non-zero on error.

gretl_model_add_allocated_varnames ()

void                gretl_model_add_allocated_varnames  (MODEL *pmod,
                                                         char **vnames);

Attaches an allocated set of variable names to be used when printing model results, for use in special cases where we can't just reference names from the list of regressors attached to the model. The number of strings must match the number of coefficients, given by the ncoeff member of pmod.

Note that pmod "takes charge" of the array vnames: this will be freed when the model is destroyed.

pmod :

pointer to target model.

vnames :

array of names of independent variables.

gretl_model_add_y_median ()

int                 gretl_model_add_y_median            (MODEL *pmod,
                                                         const double *y);

Calculates the median of y using the valid observations with the model's sample range and attaches the median to the model as data under the key ymedian.

pmod :

pointer to target model.

y :

array containing the dependent variable.

Returns :

0 on success or error code on error.

gretl_model_add_normality_test ()

int                 gretl_model_add_normality_test      (MODEL *pmod,
                                                         double X2);


gretl_model_get_normality_test ()

int                 gretl_model_get_normality_test      (const MODEL *pmod,
                                                         PRN *prn);


gretl_model_get_fitted_formula ()

char *              gretl_model_get_fitted_formula      (const MODEL *pmod,
                                                         int xvar,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo);

If pmod is a simple linear, quadratic or logistic model, and if xvar is in fact the "x" variable from the model, returns a string representing the formula for generating the fitted values as a function of x. This formula may be used in the context of a fitted versus actual plot.

pmod :

pointer to target model.

xvar :

ID number of variable that _may_ be "x" in the model.

Z :

data array.

pdinfo :

dataset information.

Returns :

formula for fitted values, or NULL if this is not available.

gretl_model_set_name ()

void                gretl_model_set_name                (MODEL *pmod,
                                                         const char *name);

Sets the name of the given model; this is used in printing the model and in displaying it in the gretl GUI. Note that a model's name must be no more than MAXSAVENAME bytes in length, including the terminating NUL byte; name is truncated if it is too long.

pmod :

pointer to target model.

name :

the name to give the model.

gretl_model_get_name ()

const char *        gretl_model_get_name                (const MODEL *pmod);

pmod :

pointer to gretl model.

Returns :

the name that has been set for pmod, if any. Note that the value returned may be NULL.

gretl_model_get_scalar ()

double              gretl_model_get_scalar              (const MODEL *pmod,
                                                         ModelDataIndex idx,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         int *err);

Retrieves a specified scalar statistic from pmod: idx must be less than M_SCALAR_MAX.

pmod :

pointer to target model.

idx :

index for the scalar value that is wanted.

pZ :

pointer to data array.

pdinfo :

dataset information.

err :

location to receive error code (required).

Returns :

the requested statistic, or NADBL on failure, in which case err will contain a non-zero error code.

gretl_model_get_series ()

double *            gretl_model_get_series              (MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         ModelDataIndex idx,
                                                         int *err);

Retrieves from pmod a copy of a specified series (for example, regression residuals); idx must be greater than M_ELEM_MAX and less than M_SERIES_MAX.

pmod :

pointer to target model.

pdinfo :

dataset information.

idx :

index for the series that is wanted.

err :

location to receive error code (required).

Returns :

the allocated series, or NULL on failure, in which case err will contain a non-zero error code.

gretl_model_get_matrix ()

gretl_matrix *      gretl_model_get_matrix              (MODEL *pmod,
                                                         ModelDataIndex idx,
                                                         int *err);

Retrieves from pmod a copy of a specified matrix (for example, regression residuals); idx must be greater than M_ELEM_MAX and less than M_MAX.

pmod :

pointer to target model.

idx :

index for the matrix that is wanted.

err :

location to receive error code (required).

Returns :

the allocated matrix, or NULL on failure, in which case err will contain a non-zero error code.

gretl_model_get_data_element ()

double              gretl_model_get_data_element        (MODEL *pmod,
                                                         int idx,
                                                         const char *s,
                                                         const DATAINFO *pdinfo,
                                                         int *err);


gretl_model_serialize ()

int                 gretl_model_serialize               (const MODEL *pmod,
                                                         SavedObjectFlags flags,
                                                         FILE *fp);


attach_model_tests_from_xml ()

int                 attach_model_tests_from_xml         (MODEL *pmod,
                                                         xmlNodePtr node);


gretl_model_from_XML ()

MODEL *             gretl_model_from_XML                (xmlNodePtr node,
                                                         xmlDocPtr doc,
                                                         const DATAINFO *pdinfo,
                                                         int *err);

Reads info on a gretl model from the given XML node and doc, and reconstitutes the model in memory.

node :

XML node from which to read.

doc :

pointer to XML document.

pdinfo :

dataset information.

err :

location to receive error code.

Returns :

allocated model, or NULL on failure.