gretl_bfgs

gretl_bfgs —

Synopsis

#define             RSTEPS
double              (*BFGS_CRIT_FUNC)                   (const double *,
                                                         void *);
int                 (*BFGS_GRAD_FUNC)                   (double *,
                                                         double *,
                                                         ...,
                                                         BFGS_CRIT_FUNC ,
                                                         void *);
double *            (*BFGS_SCORE_FUNC)                  (const double *,
                                                         ...,
                                                         void *);
int                 BFGS_max                            (double *b,
                                                         int n,
                                                         int maxit,
                                                         double reltol,
                                                         int *fncount,
                                                         int *grcount,
                                                         BFGS_CRIT_FUNC cfunc,
                                                         int crittype,
                                                         BFGS_GRAD_FUNC gradfunc,
                                                         void *data,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 LBFGS_max                           (double *b,
                                                         int n,
                                                         int maxit,
                                                         double reltol,
                                                         int *fncount,
                                                         int *grcount,
                                                         BFGS_CRIT_FUNC cfunc,
                                                         int crittype,
                                                         BFGS_GRAD_FUNC gradfunc,
                                                         void *data,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 BFGS_numeric_gradient               (double *b,
                                                         double *g,
                                                         int n,
                                                         BFGS_CRIT_FUNC func,
                                                         void *data);
gretl_matrix *      build_OPG_matrix                    (double *b,
                                                         int k,
                                                         int T,
                                                         BFGS_SCORE_FUNC scorefun,
                                                         void *data,
                                                         int *err);
double *            numerical_hessian                   (const double *b,
                                                         int n,
                                                         BFGS_CRIT_FUNC func,
                                                         void *data,
                                                         int *err);
double              user_BFGS                           (gretl_matrix *b,
                                                         const char *fncall,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         PRN *prn,
                                                         int *err);
gretl_matrix *      fdjac                               (gretl_matrix *theta,
                                                         const char *fncall,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         int *err);

Description

Details

RSTEPS

#define RSTEPS 4


BFGS_CRIT_FUNC ()

double              (*BFGS_CRIT_FUNC)                   (const double *,
                                                         void *);

Param1 :
Param2 :
Returns :

BFGS_GRAD_FUNC ()

int                 (*BFGS_GRAD_FUNC)                   (double *,
                                                         double *,
                                                         ...,
                                                         BFGS_CRIT_FUNC ,
                                                         void *);

Param1 :
Param2 :
... :
Param4 :
Param5 :
Returns :

BFGS_SCORE_FUNC ()

double *            (*BFGS_SCORE_FUNC)                  (const double *,
                                                         ...,
                                                         void *);

Param1 :
... :
Param3 :
Returns :

BFGS_max ()

int                 BFGS_max                            (double *b,
                                                         int n,
                                                         int maxit,
                                                         double reltol,
                                                         int *fncount,
                                                         int *grcount,
                                                         BFGS_CRIT_FUNC cfunc,
                                                         int crittype,
                                                         BFGS_GRAD_FUNC gradfunc,
                                                         void *data,
                                                         gretlopt opt,
                                                         PRN *prn);

Obtains the set of values for b which jointly maximize the criterion value as calculated by cfunc. Uses the BFGS variable-metric method. Based on Pascal code in J. C. Nash, "Compact Numerical Methods for Computers," 2nd edition, converted by p2c then re-crafted by B. D. Ripley for gnu R. Revised for gretl by Allin Cottrell.

b : array of adjustable coefficients.
n : number elements in array b.
maxit : the maximum number of iterations to allow.
reltol : relative tolerance for terminating iteration.
fncount : location to receive count of function evaluations.
grcount : location to receive count of gradient evaluations.
cfunc : pointer to function used to calculate maximand.
crittype : code for type of the maximand/minimand: should be C_LOGLIK, C_GMM or C_OTHER. Used only in printing iteration info.
gradfunc : pointer to function used to calculate the gradient, or NULL for default numerical calculation.
data : pointer that will be passed as the last parameter to the callback functions cfunc and gradfunc.
opt : may contain OPT_V for verbose operation.
prn : printing struct (or NULL). Only used if opt includes OPT_V.
Returns : 0 on successful completion, non-zero error code on error.

LBFGS_max ()

int                 LBFGS_max                           (double *b,
                                                         int n,
                                                         int maxit,
                                                         double reltol,
                                                         int *fncount,
                                                         int *grcount,
                                                         BFGS_CRIT_FUNC cfunc,
                                                         int crittype,
                                                         BFGS_GRAD_FUNC gradfunc,
                                                         void *data,
                                                         gretlopt opt,
                                                         PRN *prn);

b :
n :
maxit :
reltol :
fncount :
grcount :
cfunc :
crittype :
gradfunc :
data :
opt :
prn :
Returns :

BFGS_numeric_gradient ()

int                 BFGS_numeric_gradient               (double *b,
                                                         double *g,
                                                         int n,
                                                         BFGS_CRIT_FUNC func,
                                                         void *data);

b :
g :
n :
func :
data :
Returns :

build_OPG_matrix ()

gretl_matrix *      build_OPG_matrix                    (double *b,
                                                         int k,
                                                         int T,
                                                         BFGS_SCORE_FUNC scorefun,
                                                         void *data,
                                                         int *err);

b :
k :
T :
scorefun :
data :
err :
Returns :

numerical_hessian ()

double *            numerical_hessian                   (const double *b,
                                                         int n,
                                                         BFGS_CRIT_FUNC func,
                                                         void *data,
                                                         int *err);

b :
n :
func :
data :
err :
Returns :

user_BFGS ()

double              user_BFGS                           (gretl_matrix *b,
                                                         const char *fncall,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         PRN *prn,
                                                         int *err);

b :
fncall :
pZ :
pdinfo :
prn :
err :
Returns :

fdjac ()

gretl_matrix *      fdjac                               (gretl_matrix *theta,
                                                         const char *fncall,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         int *err);

theta :
fncall :
pZ :
pdinfo :
err :
Returns :