Top |
MODEL | lsq () |
MODEL | ar_model () |
MODEL | ar1_model () |
MODEL | lad_model () |
MODEL | quantreg () |
MODEL | arma () |
MODEL | garch () |
MODEL | mp_ols () |
MODEL | panel_model () |
MODEL | ivreg () |
MODEL | dpd_model () |
MODEL | hsk_model () |
MODEL | arch_model () |
int | whites_test () |
int | arch_test () |
int | array_arch_test () |
int | makevcv () |
int * | augment_regression_list () |
int | anova () |
Most libgretl functions that estimate regression models are collected here.
Please note that most of these functions return a MODEL struct -- literally a struct, not a pointer to one. To handle such a return value in C you should either (a) declare a MODEL and assign to it, or (b) allocate a MODEL "on the heap" and then assign to its content using the indirection operator. The code fragment below illustrates both approaches.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#include <gretl/libgretl.h> int ols_using_gretl (const int *list, DATASET *dset, PRN *prn) { MODEL model; MODEL *pmod; int err; // method (a) model = lsq(list, dset, OLS, OPT_NONE); err = model.errcode; if (!err) { printmodel(&model, dset, OPT_NONE, prn); } clear_model(&model); // method (b) pmod = gretl_model_new(); *pmod = lsq(list, dset, OLS, OPT_NONE); err = pmod->errcode; if (!err) { printmodel(pmod, dset, OPT_NONE, prn); } gretl_model_free(pmod); return err; } |
MODEL lsq (const int *list
,DATASET *dset
,GretlCmdIndex ci
,gretlopt opt
);
Computes least squares estimates of the model specified by list
,
using an estimator determined by the value of ci
.
list |
dependent variable plus list of regressors. |
|
dset |
dataset struct. |
|
ci |
one of the command indices in LSQ_MODEL. |
|
opt |
option flags: zero or more of the following -- OPT_R: compute robust standard errors; OPT_A: treat as auxiliary regression (don't bother checking for presence of lagged dependent var, don't augment model count); OPT_N: don't use degrees of freedom correction for standard error of regression; OPT_M: reject missing observations within sample range; OPT_Z: (internal use) suppress the automatic elimination of perfectly collinear variables. OPT_X: compute "variance matrix" as just (X'X)^{-1} OPT_I: compute Durbin-Watson p-value. OPT_U: treat null model as OK. OPT_P: (ar1 only): use Prais-Winsten. OPT_S: estimation as part of system. |
MODEL ar_model (const int *list
,DATASET *dset
,gretlopt opt
,PRN *prn
);
Estimate the model given in list
using the generalized
Cochrane-Orcutt procedure for autoregressive errors.
MODEL ar1_model (const int *list
,DATASET *dset
,gretlopt opt
,PRN *prn
);
MODEL lad_model (const int *list
,DATASET *dset
,gretlopt opt
);
Estimate the model given in list
using the method of Least
Absolute Deviation (LAD).
MODEL quantreg (const gretl_matrix *tau
,const int *list
,DATASET *dset
,gretlopt opt
,PRN *prn
);
Estimate the model given in list
using the method of
quantile regression.
MODEL arma (const int *list
,const int *pqlags
,DATASET *dset
,gretlopt opt
,PRN *prn
);
Calculates ARMA estimates. By default the estimator is
exact ML, implemented via gretl's Kalman filter in
conjunction with the BFGS maximizer. Other options:
if opt
includes OPT_L we use L-BFGS-B rather than standard
BFGS; OPT_C (incompatible with OPT_L) calls for use of
conditional ML (BHHH algorithm); and OPT_X requests estimation via
X-12-ARIMA rather than native code.
If pqlags
is non-NULL it should take the form of two
gretl sub-lists joined by LISTSEP: the first sub-list holds
a set of AR lags and the second a list of MA lags. If only
AR lags are specified, a single list may be given; if only
MA lags are specified, use LISTSEP with a null first sub-list.
If the model specification does not include a constant
this is added automatically, unless opt
includes OPT_N
("no constant").
When the estimation method is native exact ML, two (mutually
exclusive) flags in opt
may be used to control the estimator
of the covariance matrix: OPT_G specifies use of the outer
product of the gradient (OPG), while OPT_H specifies use of
the (numerical) Hessian. If neither of these flags is given, the
default is to use the Hessian by preference, but to fall back
to OPG if computation of the numerical Hessian fails. These
flags are ignored if estimation is not via native exact ML.
MODEL garch (const int *list
,DATASET *dset
,gretlopt opt
,PRN *prn
);
Calculate GARCH estimates.
MODEL mp_ols (const int *list
,DATASET *dset
,gretlopt opt
);
Estimate an OLS model using multiple-precision arithmetic via the GMP library.
MODEL panel_model (const int *list
,DATASET *dset
,gretlopt opt
,PRN *prn
);
Calculate estimates for a panel dataset, using fixed effects (the default), random effects, or weighted least squares based on the respective variances for the cross-sectional units.
list |
regression list (dependent variable plus independent variables). |
|
dset |
dataset struct. |
|
opt |
can include OPT_Q (quiet estimation), OPT_U (random effects model), OPT_H (weights based on the error variance for the respective cross-sectional units), OPT_I (iterate, only available in conjunction with OPT_H). |
|
prn |
printing struct (or NULL). |
MODEL ivreg (const int *list
,DATASET *dset
,gretlopt opt
);
Calculate IV estimates for a linear model, by default via two-stage least squares. The option flags can include OPT_Q for quiet operation, and either OPT_L to specify estimation via Limited Information Maximum Likelihood or OPT_G for estimation via Generalized method of Moments.
MODEL dpd_model (const int *list
,const int *laglist
,const char *ispec
,const DATASET *dset
,gretlopt opt
,PRN *prn
);
Implements the "dpanel" command.
MODEL hsk_model (const int *list
,DATASET *dset
,gretlopt opt
);
Estimate the model given in list
using a correction for
heteroskedasticity.
MODEL arch_model (const int *list
,int order
,DATASET *dset
,gretlopt opt
);
Estimate the model given in list
via weighted least squares,
with the weights based on the predicted error variances from
an auxiliary regression of the squared residuals on their lagged
values.
int whites_test (MODEL *pmod
,DATASET *dset
,gretlopt opt
,PRN *prn
);
Runs White's test for heteroskedasticity on the given model.
int arch_test (MODEL *pmod
,int order
,const DATASET *dset
,gretlopt opt
,PRN *prn
);
Tests pmod
for AutoRegressive Conditional Heteroskedasticity.
int makevcv (MODEL *pmod
,double sigma
);
Inverts the Cholesky-decomposed X'X and computes the coefficient covariance matrix.
int * augment_regression_list (const int *orig
,int aux
,DATASET *dset
,int *err
);
Augment the regression list orig
with auxiliary terms. If aux
is AUX_SQ
add the squares of the original regressors; if aux
is AUX_WHITE
add squares and cross-products, or if aux
is
AUX_LOG
add the natural logs of the original regressors.
If they are not already present, these variables are added
to the data array.