genfuncs

genfuncs —

Synopsis




int         sort_series                     (const double *x,
                                             double *y,
                                             int f,
                                             const DATAINFO *pdinfo);
int         diff_series                     (const double *x,
                                             double *y,
                                             int f,
                                             const DATAINFO *pdinfo);
int         orthdev_series                  (const double *x,
                                             double *y,
                                             const DATAINFO *pdinfo);
int         cum_series                      (const double *x,
                                             double *y,
                                             const DATAINFO *pdinfo);
int         resample_series                 (const double *x,
                                             double *y,
                                             const DATAINFO *pdinfo);
int         fracdiff_series                 (const double *x,
                                             double *y,
                                             double d,
                                             const DATAINFO *pdinfo);
int         panel_mean_series               (const double *x,
                                             double *y,
                                             const DATAINFO *pdinfo);
int         panel_sd_series                 (const double *x,
                                             double *y,
                                             const DATAINFO *pdinfo);
int         hp_filter                       (const double *x,
                                             double *hp,
                                             const DATAINFO *pdinfo,
                                             gretlopt opt);
int         bkbp_filter                     (const double *y,
                                             double *bk,
                                             const DATAINFO *pdinfo);
int         dummy                           (double ***pZ,
                                             DATAINFO *pdinfo,
                                             int center);
int         panel_dummies                   (double ***pZ,
                                             DATAINFO *pdinfo,
                                             gretlopt opt);
int         gen_unit                        (double ***pZ,
                                             DATAINFO *pdinfo);
int         panel_unit_first_obs            (int t,
                                             const DATAINFO *pdinfo);
int         gen_time                        (double ***pZ,
                                             DATAINFO *pdinfo,
                                             int tm);
int         gen_wkday                       (double ***pZ,
                                             DATAINFO *pdinfo);
int         plotvar_code                    (const DATAINFO *pdinfo);
const double* gretl_plotx                   (const DATAINFO *pdinfo);
int         genr_fit_resid                  (const MODEL *pmod,
                                             double ***pZ,
                                             DATAINFO *pdinfo,
                                             int code,
                                             int undo);
int         get_observation_number          (const char *s,
                                             const DATAINFO *pdinfo);
int         get_t_from_obs_string           (const char *s,
                                             const double **Z,
                                             const DATAINFO *pdinfo);

Description

Details

sort_series ()

int         sort_series                     (const double *x,
                                             double *y,
                                             int f,
                                             const DATAINFO *pdinfo);

x :
y :
f :
pdinfo :
Returns :

diff_series ()

int         diff_series                     (const double *x,
                                             double *y,
                                             int f,
                                             const DATAINFO *pdinfo);

Calculates the differenced counterpart to the input series x. If f = SDIF, the seasonal difference is computed; if f = LDIF, the log difference, and if f = DIF, the ordinary first difference.

x : array of original data.
y : array into which to write the result.
f : function, DIF, SDIF or LDIF.
pdinfo : data set information.
Returns : 0 on success, non-zero error code on failure.

orthdev_series ()

int         orthdev_series                  (const double *x,
                                             double *y,
                                             const DATAINFO *pdinfo);

Calculates in y the forward orthogonal deviations of the input series x. That is, y[t+1] is the scaled difference between x[t] and the mean of the subsequent observations on x.

x : array of original data.
y : array into which to write the result.
pdinfo : data set information.
Returns : 0 on success, non-zero error code on failure.

cum_series ()

int         cum_series                      (const double *x,
                                             double *y,
                                             const DATAINFO *pdinfo);

x :
y :
pdinfo :
Returns :

resample_series ()

int         resample_series                 (const double *x,
                                             double *y,
                                             const DATAINFO *pdinfo);

x :
y :
pdinfo :
Returns :

fracdiff_series ()

int         fracdiff_series                 (const double *x,
                                             double *y,
                                             double d,
                                             const DATAINFO *pdinfo);

Calculates the fractionally differenced counterpart to the input series x.

x : array of original data.
y : array into which to write the result.
d : fraction by which to difference.
pdinfo : data set information.
Returns : 0 on success, non-zero error code on failure.

panel_mean_series ()

int         panel_mean_series               (const double *x,
                                             double *y,
                                             const DATAINFO *pdinfo);

x :
y :
pdinfo :
Returns :

panel_sd_series ()

int         panel_sd_series                 (const double *x,
                                             double *y,
                                             const DATAINFO *pdinfo);

x :
y :
pdinfo :
Returns :

hp_filter ()

int         hp_filter                       (const double *x,
                                             double *hp,
                                             const DATAINFO *pdinfo,
                                             gretlopt opt);

Calculates the "cycle" component of the time series in array x, using the Hodrick-Prescott filter. Adapted from the original FORTRAN code by E. Prescott. Very few changes.

x : array of original data.
hp : array in which filtered series is computed.
pdinfo : data set information.
opt : if OPT_T, return the trend rather than the cycle.
Returns : 0 on success, non-zero error code on failure.

bkbp_filter ()

int         bkbp_filter                     (const double *y,
                                             double *bk,
                                             const DATAINFO *pdinfo);

Calculates the Baxter & King bandpass filter.

y : array of original data.
bk : array into which to write the filtered series.
pdinfo : data set information.
Returns : 0 on success, non-zero error code on failure.

dummy ()

int         dummy                           (double ***pZ,
                                             DATAINFO *pdinfo,
                                             int center);

Adds to the data set (if these variables are not already present) a set of periodic (usually seasonal) dummy variables.

pZ : pointer to data matrix.
pdinfo : data information struct.
center : if greater than zero subtract the population mean from each of the generated dummies; if less than zero, do not subtract the mean but generate dummies with labels on the same pattern as centered dummies (for internal use in VECMs). Usually this argument is set to zero.
Returns : the ID number of the first dummy variable on success, or 0 on error.

panel_dummies ()

int         panel_dummies                   (double ***pZ,
                                             DATAINFO *pdinfo,
                                             gretlopt opt);

Adds to the data set a set of dummy variables corresponding to either the cross-sectional units in a panel, or the time periods.

pZ : pointer to data matrix.
pdinfo : data information struct.
opt : OPT_T for time dummies, otherwise unit dummies.
Returns : 0 on successful completion, error code on error.

gen_unit ()

int         gen_unit                        (double ***pZ,
                                             DATAINFO *pdinfo);

(For panel data only) adds to the data set an index variable that uniquely identifies the cross-sectional units.

pZ : pointer to data matrix.
pdinfo : data information struct.
Returns : 0 on successful completion, error code on error.

panel_unit_first_obs ()

int         panel_unit_first_obs            (int t,
                                             const DATAINFO *pdinfo);

t : zero-based observation number.
pdinfo : data information struct.
Returns : 1 if observation t is the first time-series observation on a given cross-sectional unit in a panel dataset, else 0.

gen_time ()

int         gen_time                        (double ***pZ,
                                             DATAINFO *pdinfo,
                                             int tm);

Generates (and adds to the dataset, if it's not already present) a time-trend or index variable. This function is panel-data aware: if the dataset is a panel and tm is non-zero, the trend will not simply run consecutively over the entire range of the data, but will correctly represent the location in time of each observation. The index is 1-based.

pZ : pointer to data array.
pdinfo : data information struct.
tm : if non-zero, an actual time trend is wanted, otherwise just an index of observations.
Returns : 0 on success, non-zero code on error.

gen_wkday ()

int         gen_wkday                       (double ***pZ,
                                             DATAINFO *pdinfo);

pZ :
pdinfo :
Returns :

plotvar_code ()

int         plotvar_code                    (const DATAINFO *pdinfo);

pdinfo :
Returns :

gretl_plotx ()

const double* gretl_plotx                   (const DATAINFO *pdinfo);

Finds or creates a special dummy variable for use on the x-axis in plotting; this will have the full length of the data series as given in pdinfo, and will be appropriately configured for the data frequency. Do not try to free this variable.

pdinfo : data information struct.
Returns : pointer to plot x-variable, or NULL on failure.

genr_fit_resid ()

int         genr_fit_resid                  (const MODEL *pmod,
                                             double ***pZ,
                                             DATAINFO *pdinfo,
                                             int code,
                                             int undo);

Adds residuals or fitted values or squared residuals from a given model to the data set.

pmod : pointer to model to be tested.
pZ : pointer to data matrix.
pdinfo : information on the data set.
code : GENR_RESID or GENR_FITTED or GENR_RESID2.
undo : if non-zero, don't bother labeling the variables
Returns : 0 on successful completion, error code on error.

get_observation_number ()

int         get_observation_number          (const char *s,
                                             const DATAINFO *pdinfo);

s :
pdinfo :
Returns :

get_t_from_obs_string ()

int         get_t_from_obs_string           (const char *s,
                                             const double **Z,
                                             const DATAINFO *pdinfo);

s :
Z :
pdinfo :
Returns :