forecast

forecast

Synopsis

enum                ForecastMethod;
enum                ForecastFlags;
void                free_fit_resid                      (FITRESID *fr);
FITRESID *          get_fit_resid                       (const MODEL *pmod,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         int *err);
FITRESID *          get_forecast                        (MODEL *pmod,
                                                         int t1,
                                                         int t2,
                                                         int pre_n,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         int *err);
FITRESID *          get_system_forecast                 (void *p,
                                                         int ci,
                                                         int i,
                                                         int t1,
                                                         int t2,
                                                         int pre_n,
                                                         const double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         int *err);
int                 do_forecast                         (const char *str,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
void                forecast_options_for_model          (MODEL *pmod,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         int *flags,
                                                         int *dt2max,
                                                         int *st2max);
gretl_matrix *      get_forecast_matrix                 (int idx,
                                                         int *err);
FITRESID *          rolling_OLS_k_step_fcast            (MODEL *pmod,
                                                         double **Z,
                                                         DATAINFO *pdinfo,
                                                         int t1,
                                                         int t2,
                                                         int k,
                                                         int pre_n,
                                                         int *err);
void                fcast_get_continuous_range          (const FITRESID *fr,
                                                         int *pt1,
                                                         int *pt2);
void                forecast_matrix_cleanup             (void);

Description

Details

enum ForecastMethod

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


enum ForecastFlags

typedef enum {
    FC_AUTO_OK      = 1 << 0,
    FC_DYNAMIC_OK   = 1 << 1,
    FC_ADDOBS_OK    = 1 << 2,
    FC_INTEGRATE_OK = 1 << 3,
    FC_MEAN_OK      = 1 << 4
} ForecastFlags;


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,
                                                         int *err);

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.

err :

location to receive error code.

Returns :

pointer to allocated structure, or NULL on failure.

get_forecast ()

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

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.

t1 :

start of forecast range.

t2 :

end of forecast range.

pre_n :

number of pre-forecast observations to include.

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). If opt includes OPT_I, integrate the forecast (only relevant if the dependent variable in the model in question is recognized as the first difference of another variable).

err :

location to receive error code.

Returns :

pointer to allocated structure, or NULL on failure, in which case an error code is assigned via err.

get_system_forecast ()

FITRESID *          get_system_forecast                 (void *p,
                                                         int ci,
                                                         int i,
                                                         int t1,
                                                         int t2,
                                                         int pre_n,
                                                         const double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         int *err);

Allocates a FITRESID structure and fills it out with forecasts based on the system at location p, over the specified range of observations.

p :

pointer to the VAR or equation system from which forecasts are wanted.

ci :

command index for system (VAR, VECM or SYSTEM)

i :

0-based index for the variable to forecast, within the equation system.

t1 :

start of forecast range.

t2 :

end of forecast range.

pre_n :

number of pre-forecast observations to include.

Z :

data array on which system 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.

err :

location to receive error code.

Returns :

pointer to allocated structure, or NULL on failure.

do_forecast ()

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

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

str :

command string, which may include a starting observation and ending observation, and/or the name of a variable for saving the forecast values.

pZ :

pointer to data array.

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). OPT_R: do rolling/recursive forecast. OPT_Q: suppress printing of the forecast; OPT_P: ensure that the values are printed. OPT_U: produce gnuplot plot.

prn :

gretl printing struct.

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 *flags,
                                                         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.

flags :

location to receive flags from among ForecastFlags.

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.

get_forecast_matrix ()

gretl_matrix *      get_forecast_matrix                 (int idx,
                                                         int *err);


rolling_OLS_k_step_fcast ()

FITRESID *          rolling_OLS_k_step_fcast            (MODEL *pmod,
                                                         double **Z,
                                                         DATAINFO *pdinfo,
                                                         int t1,
                                                         int t2,
                                                         int k,
                                                         int pre_n,
                                                         int *err);


fcast_get_continuous_range ()

void                fcast_get_continuous_range          (const FITRESID *fr,
                                                         int *pt1,
                                                         int *pt2);


forecast_matrix_cleanup ()

void                forecast_matrix_cleanup             (void);