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 FORECAST_H
21 #define FORECAST_H
22 
23 #ifdef  __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef enum {
28     FC_AUTO_OK      = 1 << 0,
29     FC_DYNAMIC_OK   = 1 << 1,
30     FC_ADDOBS_OK    = 1 << 2,
31     FC_INTEGRATE_OK = 1 << 3,
32     FC_MEAN_OK      = 1 << 4
33 } ForecastFlags;
34 
35 struct _FITRESID {
36     int model_ID;   /* ID of model on which forecast is based */
37     int asymp;      /* 0/1 flag for asymptotic estimator */
38     int std;        /* 0/1 flag for standardized residuals */
39     int model_t1;   /* start of model estimation range */
40     int method;     /* one of the ForecastMethod options */
41     double *actual; /* array of values of dependent variable */
42     double *fitted; /* array of fitted values */
43     double *resid;  /* array of residuals */
44     double *sderr;  /* array of forecast standard errors (or NULL) */
45     double sigma;   /* standard error of regression */
46     double alpha;   /* for confidence intervals */
47     int pmax;       /* if positive, suggested number of decimal places
48                        for use in printing */
49     int df;         /* degrees of freedom for model */
50     int t0;         /* start of pre-forecast data range */
51     int t1;         /* start of forecast range */
52     int t2;         /* end of forecast range */
53     int k;          /* number of steps ahead (method = FC_KSTEP only) */
54     int nobs;       /* length of the arrays actual, fitted, resid */
55     char depvar[VNAMELEN]; /* name of dependent variable */
56 };
57 
58 void free_fit_resid (FITRESID *fr);
59 
60 FITRESID *get_fit_resid (const MODEL *pmod, const DATASET *dset,
61 			 int *err);
62 
63 FITRESID *get_forecast (MODEL *pmod, int t1, int t2, int pre_n,
64 			DATASET *dset, gretlopt opt, int *err);
65 
66 FITRESID *get_system_forecast (void *p, int ci, int i,
67 			       int t1, int t2, int pre_n,
68 			       DATASET *dset, gretlopt opt,
69 			       int *err);
70 
71 int do_forecast (const char *str, DATASET *dset,
72 		 gretlopt opt, PRN *prn);
73 
74 void forecast_options_for_model (MODEL *pmod, const DATASET *dset,
75 				 int *flags, int *dt2max, int *st2max);
76 
77 gretl_matrix *get_forecast_matrix (int idx, int *err);
78 
79 FITRESID *
80 recursive_OLS_k_step_fcast (MODEL *pmod, DATASET *dset,
81 			    int t1, int t2, int k, int pre_n,
82 			    int *err);
83 
84 void fcast_get_continuous_range (const FITRESID *fr, int *pt1, int *pt2);
85 
86 void forecast_matrix_cleanup (void);
87 
88 #ifdef  __cplusplus
89 }
90 #endif
91 
92 #endif /* FORECAST_H */
93 
94 
95