"Fossies" - the Fresh Open Source Software Archive

Member "gretl-2020b/lib/src/genmain.h" (17 Mar 2020, 9191 Bytes) of package /linux/misc/gretl-2020b.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "genmain.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2020a_vs_2020b.

    1 /* 
    2  *  gretl -- Gnu Regression, Econometrics and Time-series Library
    3  *  Copyright (C) 2001 Allin Cottrell and Riccardo "Jack" Lucchetti
    4  * 
    5  *  This program is free software: you can redistribute it and/or modify
    6  *  it under the terms of the GNU General Public License as published by
    7  *  the Free Software Foundation, either version 3 of the License, or
    8  *  (at your option) any later version.
    9  * 
   10  *  This program is distributed in the hope that it will be useful,
   11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13  *  GNU General Public License for more details.
   14  * 
   15  *  You should have received a copy of the GNU General Public License
   16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
   17  * 
   18  */
   19 
   20 #ifndef GENMAIN_H
   21 #define GENMAIN_H
   22 
   23 #include "gretl_matrix.h"
   24 
   25 typedef enum {
   26     R_NOBS = 1,   /* number of observations in current sample range */
   27     R_NVARS,      /* number of variables in dataset (including the constant) */
   28     R_PD,         /* periodicity of dataset */
   29     R_T1,         /* start of current sample range */
   30     R_T2,         /* end of current sample range */
   31     R_TMAX,       /* maximum value for t2 */
   32     R_DATATYPE,   /* dataset structure (x-section, time-series, panel) */
   33     R_WINDOWS,    /* running on MS Windows (1) or not (0) */
   34     R_VERSION,    /* gretl version number */
   35     R_ERRNO,      /* internal gretl error code */
   36     R_SEED,       /* RNG seed */
   37     R_HUGE,       /* conventional "huge" number, like eg 1.0e100 */
   38     R_DSET_MAX,   /* separator */
   39     R_TEST_LNL,   /* log-likelihood from last test (if applicable) */
   40     R_STOPWATCH,  /* stopwatch */
   41     R_TEST_BRK,   /* obs at which break occurs (QLR test) */
   42     R_SCALAR_MAX, /* separator: scalars vs series */
   43     R_INDEX,      /* consecutive observations index */
   44     R_PUNIT,      /* 1-based panel unit index */
   45     R_OBSMAJ,     /* major component of observation (e.g. year) */
   46     R_OBSMIN,     /* minor component of observation (e.g. quarter, month) */
   47     R_OBSMIC,     /* micro component of observation (e.g. day) */
   48     R_DATES,      /* ISO 8601 "basic" dates series */
   49     R_SERIES_MAX, /* separator: series vs variants */
   50     R_TEST_STAT,  /* last test statistic(s) (scalar or matrix) */
   51     R_TEST_PVAL,  /* last test p-value(s) (scalar or matrix) */
   52     R_NOW,        /* current date/time (matrix) */
   53     R_RESULT,     /* result of a "result-compatible" command */
   54     R_MAX
   55 } RetrievalIndex;
   56 
   57 /**
   58  * ModelDataIndex:
   59  * 
   60  * Symbolic names for variables that can be retrieved 
   61  * from gretl models.
   62  */
   63 
   64 typedef enum {
   65     M_ESS = R_MAX + 1, /* error sum of squares */
   66     M_T,          /* observations used */
   67     M_RSQ,        /* R-squared */
   68     M_SIGMA,      /* standard error of residuals */
   69     M_DF,         /* degrees of freedom */
   70     M_NCOEFF,     /* total number of estimated coefficients */
   71     M_LNL,        /* log-likelihood */
   72     M_GMMCRIT,    /* GMM criterion */
   73     M_AIC,        /* Akaike info criterion */
   74     M_BIC,        /* Bayesian info criterion */
   75     M_HQC,        /* Hannan-Quinn criterion */
   76     M_TRSQ,       /* T * R-squared, last model */
   77     M_DW,         /* Durbin-Watson statistic */
   78     M_DWPVAL,     /* Durbin-Watson p-value, last model */
   79     M_FSTT,       /* overall F-statistic, last model */
   80     M_CHISQ,      /* overall chi-square stat, last model */
   81     M_DIAGTEST,   /* system test for diagonal covariance matrix */
   82     M_DIAGPVAL,   /* p-value for the above */
   83     M_SCALAR_MAX, /*** SEPARATOR, scalars/series ***/
   84     M_UHAT,       /* residuals */
   85     M_YHAT,       /* fitted values */
   86     M_LLT,        /* per-observation loglikelihood */
   87     M_AHAT,       /* individual effects in panel model */
   88     M_H,          /* GARCH predicted variances */
   89     M_SAMPLE,     /* observations used in estimation */
   90     M_UHAT2,      /* squared residuals */
   91     M_SERIES_MAX, /*** SEPARATOR, series/matrices ***/
   92     M_COEFF,      /* parameter estimates */
   93     M_SE,         /* parameter standard errors */
   94     M_VCV,        /* parameter covariance matrix */
   95     M_RHO,        /* autoregressive coefficients */
   96     M_COMPAN,     /* VAR companion matrix */
   97     M_XTXINV,     /* VARs, VECMs: X'X^{-1} */
   98     M_VECG,       /* VECMs: the Gamma matrices */
   99     M_EVALS,      /* VECMs: eigenvalues */
  100     M_JALPHA,     /* Johansen's alpha */
  101     M_JBETA,      /* Johansen's beta */
  102     M_JVBETA,     /* Covariance matrix for Johansen's normalized beta */
  103     M_JS00,       /* VECM residual covariance matrix (1st differences) */
  104     M_JS11,       /* VECM residual covariance matrix (levels) */
  105     M_JS01,       /* VECM residual cross-product matrix */
  106     M_HAUSMAN,    /* Hausman test after tsls or fixed effects */
  107     M_SARGAN,     /* Sargan over-identification test after tsls */
  108     M_SYSGAM,     /* Parameter matrix Gamma (simultaneous systems) */
  109     M_SYSA,       /* Parameter matrix A (simultaneous systems) */
  110     M_SYSB,       /* Parameter matrix B (simultaneous systems) */
  111     M_FCAST,      /* last forecast generated via fcast command */
  112     M_FCSE,       /* standard errors associated with M_FCAST */
  113     M_COEFF_CI,   /* (asymmetric) confidence intervals for coeffs */
  114     M_EHAT,       /* ARMA: vector of estimated innovations */
  115     M_PMANTEAU,   /* VAR portmanteau test plus 's' value */
  116     M_MATRIX_MAX, /*** SEPARATOR, end of matrices ***/
  117     M_EC,         /* VECM error-correction terms */
  118     M_VMA,        /* VARs, VECMs: vector moving average representation */
  119     M_FEVD,       /* VAR variance decomposition */
  120     M_MNLPROBS,   /* case probabilities for multinomial logit */
  121     M_MBUILD_MAX, /*** SEPARATOR, end of matrix-builders ***/
  122     M_XLIST,      /* list of regressors */
  123     M_YLIST,      /* list of endogenous variables */
  124     M_LIST_MAX,   /*** SEPARATOR, end of lists ***/
  125     M_COMMAND,    /* model command word */
  126     M_DEPVAR,     /* name of dependent variable */
  127     M_PARNAMES,   /* array of parameter names */
  128     M_MAX         /* sentinel */
  129 } ModelDataIndex;
  130 
  131 typedef enum {
  132     B_MODEL = M_MAX + 1, /* last model as bundle */
  133     B_SYSTEM,            /* last VAR/VECM/system as bundle */
  134     B_SYSINFO            /* system information */
  135 } BundleDataIndex;
  136 
  137 #define model_data_scalar(i) (i > R_MAX && i < M_SCALAR_MAX)
  138 #define model_data_series(i) (i > M_SCALAR_MAX && i < M_SERIES_MAX)
  139 #define model_data_matrix(i) (i > M_SERIES_MAX && i < M_MATRIX_MAX)
  140 #define model_data_matrix_builder(i) (i > M_MATRIX_MAX && i < M_MBUILD_MAX)
  141 #define model_data_list(i)   (i > M_MBUILD_MAX && i < M_LIST_MAX)
  142 #define model_data_string(i) (i > M_LIST_MAX && i < M_PARNAMES)
  143 #define model_data_array(i) (i == M_PARNAMES)
  144 
  145 typedef struct parser_ GENERATOR;
  146 
  147 int generate (const char *line, DATASET *dset, 
  148           GretlType gtype, gretlopt opt,
  149           PRN *prn);
  150 
  151 GENERATOR *genr_compile (const char *s, DATASET *dset, 
  152              GretlType gtype, gretlopt opt,
  153              PRN *prn, int *err);
  154 
  155 int execute_genr (GENERATOR *genr, DATASET *dset, PRN *prn);
  156 
  157 void destroy_genr (GENERATOR *genr);
  158 
  159 int genr_get_output_type (const GENERATOR *genr);
  160 
  161 int genr_get_output_varnum (const GENERATOR *genr);
  162 
  163 double genr_get_output_scalar (const GENERATOR *genr);
  164 
  165 int genr_get_last_output_type (void);
  166 
  167 gretl_matrix *genr_get_output_matrix (GENERATOR *genr);
  168 
  169 int series_index (const DATASET *dset, const char *varname);
  170 
  171 int series_greatest_index (const DATASET *dset, const char *varname);
  172 
  173 int current_series_index (const DATASET *dset, const char *vname);
  174 
  175 int extract_varname (char *targ, const char *src, int *len);
  176 
  177 int genr_fit_resid (const MODEL *pmod, DATASET *dset,
  178             ModelDataIndex idx);
  179 
  180 double evaluate_scalar_genr (GENERATOR *genr, DATASET *dset,
  181                  PRN *prn, int *err);
  182 
  183 double evaluate_if_cond (GENERATOR *genr, DATASET *dset,
  184              PRN *prn, int *err);
  185 
  186 double generate_scalar (const char *s, DATASET *dset, int *err);
  187 
  188 double generate_boolean (const char *s, DATASET *dset,
  189              PRN *prn, int *err);
  190 
  191 int generate_int (const char *s, DATASET *dset, int *err);
  192 
  193 int generate_void (const char *s, DATASET *dset, PRN *prn);
  194 
  195 double *generate_series (const char *s, DATASET *dset, PRN *prn,
  196              int *err);
  197 
  198 gretl_matrix *generate_matrix (const char *s, DATASET *dset, 
  199                    int *err);
  200 
  201 char *generate_string (const char *s, DATASET *dset, int *err);
  202 
  203 int *generate_list (const char *s, DATASET *dset, int *err);
  204 
  205 int gretl_is_series (const char *name, const DATASET *dset);
  206 
  207 int gretl_reserved_word (const char *str);
  208 
  209 int genr_special_word (const char *s);
  210 
  211 int genr_function_word (const char *s);
  212 
  213 int genr_no_assign (const GENERATOR *p);
  214 
  215 int genr_is_autoregressive (const GENERATOR *p);
  216 
  217 void genr_set_na_check (GENERATOR *genr);
  218 
  219 void genr_unset_na_check (GENERATOR *genr);
  220 
  221 void genr_reset_uvars (GENERATOR *genr);
  222 
  223 int function_from_string (const char *s);
  224 
  225 int function_lookup (const char *s);
  226 
  227 int is_function_alias (const char *s);
  228 
  229 int const_lookup (const char *s);
  230 
  231 double get_const_by_name (const char *name, int *err);
  232 
  233 const char *gretl_function_complete (const char *s);
  234 
  235 void gretl_function_hash_cleanup (void);
  236 
  237 void set_mpi_rank_and_size (int rank, int size);
  238 
  239 #endif /* GENMAIN_H */
  240