gretl_model

gretl_model —

Synopsis




enum        ModelDataType;
enum        ArmaFlags;
typedef     CoeffIntervals;
struct      CoeffIntervals_;
#define     AR_MODEL                        (c)
#define     AR1_MODEL                       (c)
#define     SIMPLE_AR_MODEL                 (c)
#define     ML_ESTIMATOR                    (c)
#define     LIMDEP                          (c)
#define     LSQ_MODEL                       (c)
#define     ASYMPTOTIC_MODEL                (c)
#define     is_model_ref_cmd                (c)
enum        ModelTestType;
int         attach_model_tests_from_xml     (MODEL *pmod,
                                             xmlNodePtr node);
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        gretl_model_free_on_exit        (MODEL *pmod);
int         gretl_model_set_data_with_destructor
                                            (MODEL *pmod,
                                             const char *key,
                                             void *ptr,
                                             ModelDataType type,
                                             size_t size,
                                             void (*destructor) (void *));
int         gretl_model_set_data            (MODEL *pmod,
                                             const char *key,
                                             void *ptr,
                                             ModelDataType type,
                                             size_t size);
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);
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         gretl_model_get_depvar          (const MODEL *pmod);
int*        gretl_model_get_x_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         gretl_model_new_vcv             (MODEL *pmod,
                                             int *nelem);
VMatrix*    gretl_model_get_vcv             (MODEL *pmod,
                                             const DATAINFO *pdinfo);
int         gretl_model_add_arinfo          (MODEL *pmod,
                                             int nterms);
MODEL*      gretl_model_copy                (const MODEL *pmod);
void        swap_models                     (MODEL *targ,
                                             MODEL *src);
int         is_model_cmd                    (const char *line);
int         is_quiet_model_test             (int ci,
                                             gretlopt opt);
int         command_ok_for_model            (int test_ci,
                                             gretlopt opt,
                                             int model_ci);
int         model_test_ok                   (int ci,
                                             gretlopt opt,
                                             const MODEL *pmod,
                                             const DATAINFO *pdinfo);
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        reset_model_count               (void);
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_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         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,
                                             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);
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,
                                             int *err);
double*     gretl_model_get_series          (const 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);
MODEL*      gretl_model_from_XML            (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *err);

Description

Details

enum ModelDataType

typedef enum {
    MODEL_DATA_NONE,
    MODEL_DATA_INT,
    MODEL_DATA_LIST,
    MODEL_DATA_DOUBLE,
    MODEL_DATA_INT_ARRAY,
    MODEL_DATA_DOUBLE_ARRAY,
    MODEL_DATA_STRING,
    MODEL_DATA_CHAR_ARRAY,
    MODEL_DATA_CMPLX_ARRAY,
    MODEL_DATA_STRUCT
} ModelDataType;


enum ArmaFlags

typedef enum {
    ARMA_SEAS  = 1 << 0, /* includes seasonal component */
    ARMA_DSPEC = 1 << 1, /* input list includes differences */
    ARMA_X12A  = 1 << 2, /* using X-12-ARIMA to generate estimates */
    ARMA_EXACT = 1 << 3, /* using exact ML */
    ARMA_VECH  = 1 << 4  /* using vech representation when computing
			    variance matrix of state for Kalman filter
			 */
} ArmaFlags;


CoeffIntervals

typedef struct CoeffIntervals_ CoeffIntervals;


struct CoeffIntervals_

struct CoeffIntervals_ {
    int asy;
    int ncoeff;
    double t;
    char **names;
    double *coeff;
    double *maxerr;
    int df;
    int ifc;
};


AR_MODEL()

#define     AR_MODEL(c)

c :

AR1_MODEL()

#define     AR1_MODEL(c)

c :

SIMPLE_AR_MODEL()

#define     SIMPLE_AR_MODEL(c)

c :

ML_ESTIMATOR()

#define     ML_ESTIMATOR(c)

c :

LIMDEP()

#define     LIMDEP(c)

c :

LSQ_MODEL()

#define     LSQ_MODEL(c)

c :

ASYMPTOTIC_MODEL()

#define     ASYMPTOTIC_MODEL(c)

c :

is_model_ref_cmd()

#define     is_model_ref_cmd(c)

c :

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_TSLS_HAUSMAN,
    GRETL_TEST_PANEL_HAUSMAN,
    GRETL_TEST_PANEL_F,
    GRETL_TEST_PANEL_BP,
    GRETL_TEST_PANEL_TIMEDUM,
    GRETL_TEST_MAX
} ModelTestType;


attach_model_tests_from_xml ()

int         attach_model_tests_from_xml     (MODEL *pmod,
                                             xmlNodePtr node);

pmod :
node :
Returns :

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);

models :
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.

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.

gretl_model_set_data_with_destructor ()

int         gretl_model_set_data_with_destructor
                                            (MODEL *pmod,
                                             const char *key,
                                             void *ptr,
                                             ModelDataType 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,
                                             ModelDataType 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_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().

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_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);

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.

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

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);

pmod :
phi0 :
pp :
Returns :

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

is_model_cmd ()

int         is_model_cmd                    (const char *line);

line :
Returns :

is_quiet_model_test ()

int         is_quiet_model_test             (int ci,
                                             gretlopt opt);

ci :
opt :
Returns :

command_ok_for_model ()

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

test_ci : index of command to be tested.
opt : option for command to be tested.
model_ci : command index of a gretl model (for example, OLS, WLS or CORC).
Returns : 1 if the model-related command in question is meaningful and acceptable in the context of the specific sort of model indentified by model_ci, 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_arima_model ()

int         gretl_is_arima_model            (const MODEL *pmod);

pmod :
Returns :

get_first_model_stat ()

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

word :
desc :
Returns :

get_next_model_stat ()

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

word :
desc :
Returns :

get_model_count ()

int         get_model_count                 (void);

Returns :

reset_model_count ()

void        reset_model_count               (void);


model_count_plus ()

int         model_count_plus                (void);

Returns :

model_count_minus ()

void        model_count_minus               (void);


set_model_id ()

void        set_model_id                    (MODEL *pmod);

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);

test :
ts :

model_test_set_order ()

void        model_test_set_order            (ModelTest *test,
                                             int order);

test :
order :

model_test_set_dfn ()

void        model_test_set_dfn              (ModelTest *test,
                                             int df);

test :
df :

model_test_set_dfd ()

void        model_test_set_dfd              (ModelTest *test,
                                             int df);

test :
df :

model_test_set_value ()

void        model_test_set_value            (ModelTest *test,
                                             double val);

test :
val :

model_test_set_pvalue ()

void        model_test_set_pvalue           (ModelTest *test,
                                             double pval);

test :
pval :

model_test_set_param ()

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

test :
s :

model_test_set_allocated_param ()

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

test :
s :

model_test_set_crit_and_alpha ()

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

test :
crit :
alpha :

gretl_model_test_print ()

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

pmod :
i :
prn :

gretl_model_print_last_test ()

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

pmod :
prn :

gretl_model_test_print_direct ()

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

test :
heading :
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);

list :
buf :

highest_numbered_var_in_model ()

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

pmod :
pdinfo :
Returns :

mle_criteria ()

int         mle_criteria                    (MODEL *pmod,
                                             int addk);

pmod :
addk :
Returns :

coeff_pval ()

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

ci :
x :
df :
Returns :

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,
                                             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 AR order.
q : non-seasonal MA order.
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_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);

pmod :
name :

gretl_model_get_name ()

const char* gretl_model_get_name            (const MODEL *pmod);

pmod :
Returns :

gretl_model_get_scalar ()

double      gretl_model_get_scalar          (const MODEL *pmod,
                                             ModelDataIndex idx,
                                             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.
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          (const 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 :
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);

pmod :
idx :
s :
pdinfo :
err :
Returns :

gretl_model_serialize ()

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

pmod :
flags :
fp :
Returns :

gretl_model_from_XML ()

MODEL*      gretl_model_from_XML            (xmlNodePtr node,
                                             xmlDocPtr doc,