forecast

forecast —

Synopsis




enum        ForecastMethod;
struct      FITRESID_;
void        free_fit_resid                  (FITRESID *fr);
FITRESID*   get_fit_resid                   (const MODEL *pmod,
                                             const double **Z,
                                             const DATAINFO *pdinfo);
FITRESID*   get_forecast                    (MODEL *pmod,
                                             int t0,
                                             int t1,
                                             int t2,
                                             double ***pZ,
                                             DATAINFO *pdinfo,
                                             gretlopt opt);
FITRESID*   get_VAR_forecast                (GRETL_VAR *var,
                                             int i,
                                             int t0,
                                             int t1,
                                             int t2,
                                             const double **Z,
                                             DATAINFO *pdinfo,
                                             gretlopt opt);
int         display_forecast                (const char *str,
                                             MODEL *pmod,
                                             double ***pZ,
                                             DATAINFO *pdinfo,
                                             gretlopt opt,
                                             PRN *prn);
int         add_forecast                    (const char *str,
                                             MODEL *pmod,
                                             double ***pZ,
                                             DATAINFO *pdinfo,
                                             gretlopt opt);
void        forecast_options_for_model      (MODEL *pmod,
                                             const double **Z,
                                             const DATAINFO *pdinfo,
                                             int *dyn_ok,
                                             int *add_obs_ok,
                                             int *dt2max,
                                             int *st2max);
FITRESID*   rolling_OLS_one_step_fcast      (MODEL *pmod,
                                             double ***pZ,
                                             DATAINFO *pdinfo,
                                             int t0,
                                             int t1,
                                             int t2);

Description

Details

enum ForecastMethod

typedef enum {
    FC_STATIC,
    FC_DYNAMIC,
    FC_AUTO,
    FC_ONESTEP
} ForecastMethod;


struct FITRESID_

struct FITRESID_ {
    int model_ID;
    int model_ci;
    int model_t1;
    int method;
    double *actual;
    double *fitted;
    double *sderr;
    double sigma;
    double tval;
    int pmax;
    int df;
    int t0, t1, t2;
    int nobs;
    int err;
    char depvar[VNAMELEN];
};


free_fit_resid ()

void        free_fit_resid                  (FITRESID *fr);

Frees all resources associated with fr, then frees the pointer itself.

fr : the pointer to be freed.

get_fit_resid ()

FITRESID*   get_fit_resid                   (const MODEL *pmod,
                                             const double **Z,
                                             const DATAINFO *pdinfo);

Allocates a FITRESID structure and fills it out with the actual and predicted values of the dependent variable in pmod.

pmod : the model for which actual and fitted values are wanted.
Z : data array using which pmod was estimated.
pdinfo : dataset information.
Returns : pointer to allocated structure, or NULL on failure.

get_forecast ()

FITRESID*   get_forecast                    (MODEL *pmod,
                                             int t0,
                                             int t1,
                                             int t2,
                                             double ***pZ,
                                             DATAINFO *pdinfo,
                                             gretlopt opt);

Allocates a FITRESID structure and fills it out with forecasts based on pmod, over the specified range of observations. For some sorts of models forecast standard errors are also computed (these appear in the sderr member of the structure to which a pointer is returned; otherwise the sderr member is NULL).

The calculation of forecast errors, where applicable, is based on Davidson and MacKinnon, Econometric Theory and Methods, chapter 3 (p. 104), which shows how the variance of forecast errors can be computed given the covariance matrix of the parameter estimates, provided the error term may be assumed to be serially uncorrelated.

pmod : the model from which forecasts are wanted.
t0 : start of data display range.
t1 : start of forecast range.
t2 : end of forecast range.
pZ : pointer to data array using which pmod was estimated.
pdinfo : dataset information.
opt : if OPT_D, force a dynamic forecast; if OPT_S, force a static forecast. By default, the forecast is static within the data range over which the model was estimated, and dynamic out of sample (in cases where a dynamic forecast is meaningful).
Returns : pointer to allocated structure, or NULL on failure. The err member of the returned object should be checked: a non-zero value indicates an error condition.

get_VAR_forecast ()

FITRESID*   get_VAR_forecast                (GRETL_VAR *var,
                                             int i,
                                             int t0,
                                             int t1,
                                             int t2,
                                             const double **Z,
                                             DATAINFO *pdinfo,
                                             gretlopt opt);

Allocates a FITRESID structure and fills it out with forecasts based on var, over the specified range of observations. If t0 is less than t1, the observations prior to t1 will not contain forecasts.

var : the VAR system from which forecasts are wanted.
i : 0-based index for the variable to forecast, within the VAR system (the dependent variable in the ith equation, counting from 0).
t0 : start of data display range.
t1 : start of forecast range.
t2 : end of forecast range.
Z : data array using which var was estimated.
pdinfo : dataset information.
opt : if OPT_D, force a dynamic forecast; if OPT_S, force a static forecast. By default, the forecast is static within the data range over which the model was estimated, and dynamic out of sample.
Returns : pointer to allocated structure, or NULL on failure. The err member of the returned object should be checked: a non-zero value indicates an error condition.

display_forecast ()

int         display_forecast                (const char *str,
                                             MODEL *pmod,
                                             double ***pZ,
                                             DATAINFO *pdinfo,
                                             gretlopt opt,
                                             PRN *prn);

Computes forecasts based on pmod, over the range of observations given in str. Forecast standard errors are also computed if possible. The results are printed to prn, and are also plotted if OPT_P is given.

str : string giving starting and ending observations, separated by a space.
pmod : the model from which forecasts are wanted.
pZ : pointer to data array using which pmod was estimated.
pdinfo : dataset information.
opt : if OPT_D, force a dynamic forecast; if OPT_S, force a static forecast. By default, the forecast is static within the data range over which the model was estimated, and dynamic out of sample (in cases where this distinction is meaningful).
prn : printing structure.
Returns : 0 on success, non-zero error code on error.

add_forecast ()

int         add_forecast                    (const char *str,
                                             MODEL *pmod,
                                             double ***pZ,
                                             DATAINFO *pdinfo,
                                             gretlopt opt);

Adds to the dataset a new variable containing predicted values for the dependent variable in pmod over the specified range of observations, or, by default, over the sample range currently defined in pdinfo.

In the case of "simple" models with an autoregressive error term (AR, CORC, HILU, PWE) the predicted values incorporate the forecastable portion of the error.

str : command string, giving a starting observation, ending observation, and variable name to use for the forecast values (the starting and ending observations may be omitted).
pmod : pointer to model.
pZ : pointer to data matrix.
pdinfo : pointer to data information struct.
opt : if OPT_D, force a dynamic forecast; if OPT_S, force a static forecast. By default, the forecast is static within the data range over which the model was estimated, and dynamic out of sample (in cases where this distinction is meaningful).
Returns : 0 on success, non-zero error code on failure.

forecast_options_for_model ()

void        forecast_options_for_model      (MODEL *pmod,
                                             const double **Z,
                                             const DATAINFO *pdinfo,
                                             int *dyn_ok,
                                             int *add_obs_ok,
                                             int *dt2max,
                                             int *st2max);

Examines pmod and determines which forecasting options are applicable.

pmod : the model from which forecasts are wanted.
Z : data array.
pdinfo : dataset information.
dyn_ok : location to receive 1 if the "dynamic" option is applicable, 0 otherwise.
add_obs_ok : location to receive 1 if it looks as if we can extend the forecast by adding blank observations, 0 otherwise.
dt2max : location to receive the last observation that can be supported for a dynamic forecast.
st2max : location to receive the last observation that can be supported for a static forecast.

rolling_OLS_one_step_fcast ()

FITRESID*   rolling_OLS_one_step_fcast      (MODEL *pmod,
                                             double ***pZ,
                                             DATAINFO *pdinfo,
                                             int t0,
                                             int t1,
                                             int t2);

pmod :
pZ :
pdinfo :
t0 :
t1 :
t2 :
Returns :