Transformations

Transformations — standard transformations of series in the dataset

Functions

int default_lag_order ()
int standard_lag_of ()
int is_standard_diff ()
int diffgenr ()
int laggenr ()
int loggenr ()
int invgenr ()
int xpxgenr ()
int list_diffgenr ()
int list_orthdev ()
int list_laggenr ()
int * laggenr_from_to ()
int list_loggenr ()
int list_xpxgenr ()
int list_dumgenr ()
int dumgenr_with_oddval ()
int list_makediscrete ()
void gretl_transforms_cleanup ()

Object Hierarchy


Includes

#include <libgretl.h>

Description

Functions to generate standard transformations (logs, lags, first differences and so on) of series in the dataset.

Functions

default_lag_order ()

int
default_lag_order (const DATASET *dset);

Parameters

dset

data information struct.

 

Returns

the default lag order for generating lags, performing autocorrelation test, and so on.


standard_lag_of ()

int
standard_lag_of (int v,
                 int parent,
                 const DATASET *dset);

Parameters

v

ID number of series to test.

 

parent

ID of potential parent series.

 

dset

dataset information.

 

Returns

the lag order of series v , if it is marked as a lag of parent , otherwise 0.


is_standard_diff ()

int
is_standard_diff (int v,
                  const DATASET *dset,
                  int *parent);

Parameters

v

ID number of variable to test.

 

dset

dataset information.

 

parent

location to receive ID number of parent variable, or NULL.

 

Returns

1 if the variable v is marked as being the first difference of some "parent" variable in the dataset, otherwise 0.


diffgenr ()

int
diffgenr (int v,
          int ci,
          DATASET *dset);

Creates the first difference (or log- or seasonal difference, depending on the value of ci ) of variable v , if the differenced variable does not already exist.

Parameters

v

ID number in dataset of source variable.

 

ci

DIFF (first difference), LDIFF (log difference) or SDIFF (seasonal difference).

 

dset

dataset struct.

 

Returns

the ID number of the differenced variable, or -1 on error.


laggenr ()

int
laggenr (int v,
         int lag,
         DATASET *dset);

Creates the specified lag of variable v if this variable does not already exist.

Parameters

v

ID number in dataset of source variable.

 

lag

the order of the lag to create.

 

dset

dataset struct.

 

Returns

the ID number of the lagged variable, or -1 on error.


loggenr ()

int
loggenr (int v,
         DATASET *dset);

Creates the natural log of variable v if this variable does not already exist.

Parameters

v

ID number in dataset of source variable.

 

dset

dataset struct.

 

Returns

the ID number of the log variable, or -1 on error.


invgenr ()

int
invgenr (int v,
         DATASET *dset);

Creates the reciprocal of variable v if this variable does not already exist.

Parameters

v

ID number in dataset of source variable.

 

dset

dataset struct.

 

Returns

the ID number of the reciprocal, or -1 on error.


xpxgenr ()

int
xpxgenr (int vi,
         int vj,
         DATASET *dset);

Creates the cross product of variables vi and vj if this variable does not already exist.

Parameters

vi

ID number in dataset of first source variable.

 

vj

ID number in dataset of second source variable.

 

dset

dataset struct.

 

Returns

the ID number of the cross-product variable, or -1 on error.


list_diffgenr ()

int
list_diffgenr (int *list,
               int ci,
               DATASET *dset);

Generate differences of the variables in list , and add them to the data set. If ci is DIFF these are ordinary first differences; if ci is LDIFF they are log differences; and if ci is SDIFF they are seasonal differences.

Parameters

list

on entry, list of variables to process; on exit, ID numbers of the generated variables.

 

ci

must be DIFF, LDIFF or SDIFF.

 

dset

dataset struct.

 

Returns

0 on successful completion, 1 on error.


list_orthdev ()

int
list_orthdev (int *list,
              DATASET *dset);

Generate orthogonal deviations of the variables in list , and add them to the data set.

Parameters

list

list of variables to process.

 

dset

dataset struct.

 

Returns

0 on success, error code on error.


list_laggenr ()

int
list_laggenr (int **plist,
              int order,
              DATASET *dset,
              gretlopt opt);

Generates and adds to the data set order lagged values of the variables given in the list pointed to by plist .

Parameters

plist

on entry, pointer to list of variables to process. On exit the list holds the ID numbers of the lag variables.

 

order

number of lags to generate (or 0 for automatic).

 

dset

dataset struct.

 

opt

may contain OPT_L to order the list by lag rather than by variable.

 

Returns

0 on successful completion, 1 on error.


laggenr_from_to ()

int *
laggenr_from_to (int v,
                 int minlag,
                 int maxlag,
                 DATASET *dset,
                 int *err);

Creates the specified lags of variable v if they do not already exist.

Parameters

v

ID number in dataset of source variable.

 

minlag

minimum lag order.

 

maxlag

maximum lag order.

 

dset

dataset struct.

 

err

location to receive error code.

 

Returns

list of lag variables, or NULL or on error.


list_loggenr ()

int
list_loggenr (int *list,
              DATASET *dset);

Generates and adds to the data set the natural logs of the variables given in list .

Parameters

list

on entry, list of variables to process; on exit, holds the ID numbers of the generated variables.

 

dset

dataset struct.

 

Returns

0 on success, error code on error.


list_xpxgenr ()

int
list_xpxgenr (int **plist,
              DATASET *dset,
              gretlopt opt);

Generates and adds to the data set squares and (if opt is OPT_O) cross-products of the variables given in the list pointed to by plist .

Parameters

plist

pointer to list of variables to process. On exit the list holds the ID numbers of the squares (and possibly cross-products).

 

dset

dataset struct.

 

opt

If OPT_O, both squares and cross-products are generated, otherwise only squares.

 

Returns

0 on success, error code on error.


list_dumgenr ()

int
list_dumgenr (int **plist,
              DATASET *dset,
              gretlopt opt);

For each of the variables given in the list to which plist points, generates and adds to the data set k dummy variables coding for the k distinct values of the variable in question. All these variables must have already been marked as discrete. If the OPT_F or OPT_L option is given, either the first or the last value of each variable is taken as the "base" and is not given a dummy encoding (that is, only k - 1 dummies are added for each variable).

Parameters

plist

pointer to list of variables to process; on exit the list holds the ID numbers of the generated dummies.

 

dset

dataset struct.

 

opt

can include OPT_F to drop the first value, OPT_L to drop the last value.

 

Returns

0 on success, error code on error.


dumgenr_with_oddval ()

int
dumgenr_with_oddval (int **plist,
                     DATASET *dset,
                     double oddval);

For each of the variables given in the list to which plist points, generates and adds to the data set k dummy variables coding for the k distinct values of the variable in question. All these variables must have already been marked as discrete. if oddval is not NADBL, it is treated as the omitted category and only k - 1 dummies are added for each variable).

Parameters

plist

pointer to list of variables to process; on exit the list holds the ID numbers of the generated dummies.

 

dset

dataset struct.

 

oddval

value which should be skipped when encoding the input values as dummies.

 

Returns

0 on success, error code on error.


list_makediscrete ()

int
list_makediscrete (const int *list,
                   DATASET *dset,
                   gretlopt opt);

Sets the variables given in list as discrete, unless opt is OPT_R, in which case the variables are set as continuous.

Parameters

list

list of variables to process.

 

dset

data information struct.

 

opt

if OPT_R, reverse the operation.

 

Returns

0 on success, error code on error.


gretl_transforms_cleanup ()

void
gretl_transforms_cleanup (void);

Called by libgretl_cleanup(). Frees any memory allocated as workspace for the creation of transformed variables.

Types and Values