genfuncs

genfuncs

Functions

int sort_series ()
int gretl_sort_by ()
int rank_series ()
gretl_matrix * rank_vector ()
int diff_series ()
int interpolate_series ()
int standardize_series ()
int orthdev_series ()
int cum_series ()
int resample_series ()
int block_resample_series ()
int fracdiff_series ()
int boxcox_series ()
gretl_matrix * boxcox_matrix ()
int filter_series ()
gretl_matrix * filter_matrix ()
int exponential_movavg_series ()
int movavg_series ()
int seasonally_adjust_series ()
int tramo_linearize_series ()
int panel_statistic ()
gretl_matrix * panel_shrink ()
int panel_expand ()
int hp_filter ()
int oshp_filter ()
int bkbp_filter ()
int butterworth_filter ()
int poly_trend ()
int weighted_poly_trend ()
void poly_weights ()
gretl_matrix * hp_gain ()
gretl_matrix * butterworth_gain ()
int gen_seasonal_dummies ()
int * seasonals_list ()
int gen_panel_dummies ()
int gen_unit ()
int panel_unit_first_obs ()
int gen_time ()
int gen_wkday ()
const double * gretl_plotx ()
double * get_fit_or_resid ()
int get_observation_number ()
int get_t_from_obs_string ()
int list_linear_combo ()
gretl_matrix * midas_weights ()
gretl_matrix * midas_gradient ()
gretl_matrix * midas_multipliers ()
int midas_linear_combo ()
int * vector_to_midas_list ()
double imhof ()
double dw_pval ()
gretl_matrix * multi_acf ()
gretl_matrix * multi_xcf ()
gretl_matrix * forecast_stats ()
gretl_matrix * matrix_fc_stats ()
gretl_matrix * duration_func ()
double gretl_round ()
double gretl_sgn ()
double gretl_bessel ()
double gretl_npv ()
double gretl_irr ()
double logistic_cdf ()
int list_ok_dollar_vars ()
int nadaraya_watson ()
int gretl_loess ()
double series_get_nobs ()
double series_sum_all ()
gretl_matrix * aggregate_by ()
int fill_dataset_dates_series ()
int fill_day_of_week_array ()
int fill_isoweek_array ()
gretl_matrix * empirical_cdf ()
int sample_span ()
gretl_matrix * gretl_matrix_vector_stat ()
int fill_permutation_vector ()
int substitute_values ()
int * list_from_matrix ()
gretl_matrix * omega_from_R ()
gretl_matrix * R_from_omega ()
gretl_matrix * felogit_rec_loglik ()
int * maybe_get_values_map ()
DATASET * matrix_dset_plus_lists ()

Description

Functions

sort_series ()

int
sort_series (const double *x,
             double *y,
             int f,
             const DATASET *dset);

gretl_sort_by ()

int
gretl_sort_by (const double *x,
               const double *y,
               double *z,
               const DATASET *dset);

rank_series ()

int
rank_series (const double *x,
             double *y,
             int f,
             const DATASET *dset);

rank_vector ()

gretl_matrix *
rank_vector (const gretl_matrix *x,
             int f,
             int *err);

diff_series ()

int
diff_series (const double *x,
             double *y,
             int f,
             const DATASET *dset);

Calculates the differenced counterpart to the input series x . If f = F_SDIFF, the seasonal difference is computed; if f = F_LDIFF, the log difference, and if f = F_DIFF, the ordinary first difference.

Parameters

x

array of original data.

 

y

array into which to write the result.

 

f

function, F_DIFF, F_SDIFF or F_LDIFF.

 

dset

data set information.

 

Returns

0 on success, non-zero error code on failure.


interpolate_series ()

int
interpolate_series (const double *x,
                    double *y,
                    const DATASET *dset);

Performs linear interpolation of missing values in x , writing the result into y . Panel data are handled: interpolation is strictly in the time-series dimension. No extrapolation is performed.

Parameters

x

array of original data.

 

y

array into which to write the result.

 

dset

data set information.

 

Returns

0 on success, non-zero error code on failure.


standardize_series ()

int
standardize_series (const double *x,
                    double *y,
                    int dfc,
                    const DATASET *dset);

By default calculates the standardized counterpart to the input series x , but if dfc < 0 the result is just centered.

Parameters

x

array of original data.

 

y

array into which to write the result.

 

dfc

degrees of freedom correction.

 

dset

data set information.

 

Returns

0 on success, non-zero error code on failure.


orthdev_series ()

int
orthdev_series (const double *x,
                double *y,
                const DATASET *dset);

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

Parameters

x

array of original data.

 

y

array into which to write the result.

 

dset

data set information.

 

Returns

0 on success, non-zero error code on failure.


cum_series ()

int
cum_series (const double *x,
            double *y,
            const DATASET *dset);

resample_series ()

int
resample_series (const double *x,
                 double *y,
                 const DATASET *dset);

block_resample_series ()

int
block_resample_series (const double *x,
                       double *y,
                       int blocklen,
                       const DATASET *dset);

fracdiff_series ()

int
fracdiff_series (const double *x,
                 double *y,
                 double d,
                 int diff,
                 int obs,
                 const DATASET *dset);

Calculates the fractionally differenced or lagged counterpart to the input series x . The fractional difference operator is defined as (1-L)^d, while the fractional lag operator 1-(1-L)^d.

Parameters

x

array of original data.

 

y

array into which to write the result.

 

d

fraction by which to difference.

 

diff

boolean variable 1 for fracdiff, 0 for fraclag

 

obs

used for autoreg calculation, -1 if whole series should be calculated otherwise just the observation for obs is calculated

 

dset

data set information.

 

Returns

0 on success, non-zero error code on failure.


boxcox_series ()

int
boxcox_series (const double *x,
               double *y,
               double d,
               const DATASET *dset);

Calculates in y the Box-Cox transformation for the input series x .

Parameters

x

array of original data.

 

y

array into which to write the result.

 

d

lambda parameter.

 

dset

data set information.

 

Returns

0 on success, non-zero error code on failure.


boxcox_matrix ()

gretl_matrix *
boxcox_matrix (const gretl_matrix *m,
               double d,
               int *err);

Parameters

m

matrix of original data.

 

d

lambda parameter.

 

Returns

0 on success, non-zero error code on failure.


filter_series ()

int
filter_series (const double *x,
               double *y,
               const DATASET *dset,
               gretl_matrix *A,
               gretl_matrix *C,
               double y0,
               gretl_matrix *x0);

Filters x according to y_t = C(L)/A(L) x_t. If the intended AR order is p, A should be a vector of length p. If the intended MA order is q, C should be vector of length (q+1), the first entry giving the coefficient at lag 0. However, if C is NULL this is taken to mean that the lag-0 MA coefficient is unity (and all others are zero).

Parameters

x

array of original data.

 

y

array into which to write the result.

 

dset

data set information.

 

A

vector for autoregressive polynomial.

 

C

vector for moving average polynomial.

 

y0

initial value of output series.

 

x0

prior values of x.

 

Returns

0 on success, non-zero error code on failure.


filter_matrix ()

gretl_matrix *
filter_matrix (gretl_matrix *X,
               gretl_vector *A,
               gretl_vector *C,
               double y0,
               gretl_matrix *x0,
               int *err);

Filters the columns of x according to y_t = C(L)/A(L) x_t. If the intended AR order is p, A should be a vector of length p. If the intended MA order is q, C should be vector of length (q+1), the first entry giving the coefficient at lag 0. However, if C is NULL this is taken to mean that the lag-0 MA coefficient is unity (and all others are zero).

Parameters

X

matrix of original data, r x c.

 

A

vector for autoregressive polynomial.

 

C

vector for moving average polynomial.

 

y0

initial value of output series.

 

x0

prior values of x.

 

err

location to receive error code.

 

Returns

r x c matrix of filtered values, or NULL on failure.


exponential_movavg_series ()

int
exponential_movavg_series (const double *x,
                           double *y,
                           const DATASET *dset,
                           double d,
                           int n,
                           double y0);

Parameters

x

array of original data.

 

y

array into which to write the result.

 

dset

dataset information.

 

d

coefficient on lagged x .

 

n

number of x observations to average to give the initial y value.

 

y0

optional initial value for EMA (or NADBL).

 

Returns

0 on success, non-zero error code on failure.


movavg_series ()

int
movavg_series (const double *x,
               double *y,
               const DATASET *dset,
               int k,
               int center);

Parameters

x

array of original data.

 

y

array into which to write the result.

 

dset

data set information.

 

k

number of terms in MA.

 

center

if non-zero, produce centered MA.

 

Returns

0 on success, non-zero error code on failure.


seasonally_adjust_series ()

int
seasonally_adjust_series (const double *x,
                          double *y,
                          const char *vname,
                          DATASET *dset,
                          int tramo,
                          gretl_bundle *b,
                          PRN *prn);

tramo_linearize_series ()

int
tramo_linearize_series (const double *x,
                        double *y,
                        DATASET *dset);

panel_statistic ()

int
panel_statistic (const double *x,
                 double *y,
                 const DATASET *dset,
                 int k,
                 const double *mask);

Given the data in x , constructs in y a series containing a panel-data statistic.

Parameters

x

source data.

 

y

target into which to write.

 

dset

data set information.

 

k

code representing the desired statistic: F_PNOBS, F_PMIN, F_PMAX, F_PSUM, F_PMEAN, F_PXSUM, F_PSD, F_PXNOBS or F_PXSUM.

 

mask

either NULL or a series with 0s for observations to be excluded from the calculations, non-zero values at other observations.

 

Returns

0 on success, non-zero on error.


panel_shrink ()

gretl_matrix *
panel_shrink (const double *x,
              int skip,
              const DATASET *dset,
              int *err);

By default, constructs a column vector holding the first non-missing observation of x for each panel unit within the current sample range (hence skipping any units that have no valid observations). However, if noskip is non-zero, the vector contains an NA for units with all missing values.

Parameters

x

panel-data source series.

 

noskip

keep NAs in output.

 

dset

pointer to dataset.

 

err

location to receive error code.

 

Returns

a new column vector, or NULL on error.


panel_expand ()

int
panel_expand (const gretl_matrix *x,
              double *y,
              gretlopt opt,
              const DATASET *dset);

Constructs a series by repeating the values in x , by default across time (in which case the source vector must have as many values as there are individuals in the current sample range).

Parameters

x

source vector. y target array.

 

dset

pointer to dataset.

 

opt

OPT_X to repeat across individuals instead of across time.

 

Returns

zero on success, non-zero code on error.


hp_filter ()

int
hp_filter (const double *x,
           double *hp,
           const DATASET *dset,
           double lambda,
           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.

Parameters

x

array of original data.

 

hp

array in which filtered series is computed.

 

dset

pointer to dataset.

 

lambda

smoothing parameter (or NADBL to use the default value).

 

opt

if OPT_T, return the trend rather than the cycle.

 

Returns

0 on success, non-zero error code on failure.


oshp_filter ()

int
oshp_filter (const double *x,
             double *hp,
             const DATASET *dset,
             double lambda,
             gretlopt opt);

Calculates the "cycle" component of the time series in array x , using the a one-sided Hodrick-Prescott filter. The implementation uses the Kalman filter.

Parameters

x

array of original data.

 

hp

array in which filtered series is computed.

 

dset

pointer to dataset.

 

lambda

smoothing parameter (or NADBL to use the default value).

 

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 *x,
             double *bk,
             const DATASET *dset,
             int bkl,
             int bku,
             int k);

Calculates the Baxter and King bandpass filter. If bku exceeds the number of available observations, then the "low-pass" version will be computed (weights sum to 1). Otherwise, the ordinary bandpass filter will be applied (weights sum to 0).

Parameters

x

array of original data.

 

bk

array into which to write the filtered series.

 

dset

data set information.

 

bkl

lower frequency bound (or 0 for automatic).

 

bku

upper frequency bound (or 0 for automatic).

 

k

approximation order (or 0 for automatic).

 

Returns

0 on success, non-zero error code on failure.


butterworth_filter ()

int
butterworth_filter (const double *x,
                    double *bw,
                    const DATASET *dset,
                    int n,
                    double cutoff);

Calculates the Butterworth filter. The code that does this is based on D.S.G. Pollock's IDEOLOG -- see http://www.le.ac.uk/users/dsgp1/

Parameters

x

array of original data.

 

bw

array into which to write the filtered series.

 

dset

data set information.

 

n

desired lag order.

 

cutoff

desired angular cutoff in degrees (0, 180).

 

Returns

0 on success, non-zero error code on failure.


poly_trend ()

int
poly_trend (const double *x,
            double *fx,
            const DATASET *dset,
            int order);

Calculates a trend via the method of orthogonal polynomials. Based on C code for D.S.G. Pollock's DETREND program.

Parameters

x

array of original data.

 

fx

array into which to write the fitted series.

 

dset

data set information.

 

order

desired polynomial order.

 

Returns

0 on success, non-zero error code on failure.


weighted_poly_trend ()

int
weighted_poly_trend (const double *x,
                     double *fx,
                     const DATASET *dset,
                     int order,
                     gretlopt opt,
                     double wratio,
                     double midfrac);

Calculates a trend via the method of orthogonal polynomials, using the specified weighting scheme. Based on C code for D.S.G. Pollock's DETREND program.

Parameters

x

array of original data.

 

fx

array into which to write the fitted series.

 

dset

data set information.

 

order

desired polynomial order.

 

opt

weighting option (OPT_Q = quadratic, OPT_B = cosine bell, OPT_C = crenelated).

 

wratio

ratio of maximum to minimum weight.

 

midfrac

proportion of the data to be treated specially, in the middle.

 

Returns

0 on success, non-zero error code on failure.


poly_weights ()

void
poly_weights (double *w,
              int T,
              double wmax,
              double midfrac,
              gretlopt opt);

Calculates a set of weights; intended for use with polynomial trend fitting.

Parameters

w

array into which the weights will be written.

 

T

the length of w .

 

wmax

the ratio of maximum to minimum weight.

 

midfrac

the size of the central section that should be given the minimum weight.

 

opt

weighting scheme option (OPT_Q = quadratic, OPT_B = cosine bell, OPT_C = crenelated).

 

hp_gain ()

gretl_matrix *
hp_gain (double lambda,
         int hipass);

Parameters

lambda

H-P parameter.

 

hipass

1 for high-pass filter, 0 for low-pass.

 

Returns

a matrix holding omega values from 0 to \pi in column 0, and the corresponding filter gain in column 1.


butterworth_gain ()

gretl_matrix *
butterworth_gain (int n,
                  double cutoff,
                  int hipass);

Parameters

n

order of the filter.

 

cutoff

angular cutoff in radians.

 

hipass

1 for high-pass filter, 0 for low-pass.

 

Returns

a matrix holding omega values from 0 to \pi in column 0, and the corresponding filter gain in column 1.


gen_seasonal_dummies ()

int
gen_seasonal_dummies (DATASET *dset,
                      int ref,
                      int center);

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

Parameters

dset

dataset struct.

 

ref

1-based reference period, or 0 for none.

 

center

if non-zero subtract the population mean from each of the generated dummies.

 

Returns

0 on success, non-zero on error.


seasonals_list ()

int *
seasonals_list (DATASET *dset,
                int ref,
                int center,
                int *err);

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

Parameters

dset

dataset struct.

 

ref

1-based reference period, or 0 for none.

 

center

if non-zero, subtract the population mean from each of the generated dummies.

 

err

location to receive error code.

 

Returns

list holding the ID numbers of the seasonal dummies, or NULL on error.


gen_panel_dummies ()

int
gen_panel_dummies (DATASET *dset,
                   gretlopt opt,
                   PRN *prn);

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

Parameters

dset

dataset struct.

 

opt

OPT_T for time dummies, otherwise unit dummies.

 

prn

printer for warning, or NULL.

 

Returns

0 on successful completion, error code on error.


gen_unit ()

int
gen_unit (DATASET *dset,
          int *vnum);

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

Parameters

dset

dataset struct.

 

vnum

location to receive ID number of series, or NULL.

 

Returns

0 on successful completion, error code on error.


panel_unit_first_obs ()

int
panel_unit_first_obs (int t,
                      const DATASET *dset);

Parameters

t

zero-based observation number.

 

dset

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 (DATASET *dset,
          int tm,
          int *vnum);

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.

Parameters

dset

dataset struct.

 

tm

if non-zero, an actual time trend is wanted, otherwise just an index of observations.

 

vnum

location to receive ID number of series, or NULL.

 

Returns

0 on success, non-zero on error.


gen_wkday ()

int
gen_wkday (DATASET *dset,
           int *vnum);

gretl_plotx ()

const double *
gretl_plotx (const DATASET *dset,
             gretlopt opt);

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 dset , and will be appropriately configured for the data frequency. Do not try to free this variable.

Parameters

dset

data information struct.

 

opt

can include OPT_P for panel time-series plot; OPT_T to use gnuplot time (seconds of unix epoch); OPT_S to indicate that the context is the "scatters" command.

 

Returns

pointer to plot x-variable, or NULL on failure.


get_fit_or_resid ()

double *
get_fit_or_resid (const MODEL *pmod,
                  DATASET *dset,
                  ModelDataIndex idx,
                  char *vname,
                  gchar **pdesc,
                  int *err);

Creates a full-length array holding the specified model data, and writes name and description into the vname and vlabel .

Parameters

pmod

pointer to source model.

 

dset

information on the data set.

 

idx

M_UHAT, M_UHAT2, M_YHAT, M_AHAT or M_H.

 

vname

location to write series name (length VNAMELEN)

 

pdesc

location to receive copy of series description.

 

err

location to receive error code.

 

Returns

allocated array on success or NULL on failure.


get_observation_number ()

int
get_observation_number (const char *s,
                        const DATASET *dset);

get_t_from_obs_string ()

int
get_t_from_obs_string (const char *s,
                       const DATASET *dset);

list_linear_combo ()

int
list_linear_combo (double *y,
                   const int *list,
                   const gretl_vector *b,
                   const DATASET *dset);

midas_weights ()

gretl_matrix *
midas_weights (int p,
               const gretl_matrix *m,
               int method,
               int *err);

midas_gradient ()

gretl_matrix *
midas_gradient (int p,
                const gretl_matrix *m,
                int method,
                int *err);

midas_multipliers ()

gretl_matrix *
midas_multipliers (gretl_bundle *mb,
                   int cumulate,
                   int idx,
                   int *err);

midas_linear_combo ()

int
midas_linear_combo (double *y,
                    const int *list,
                    const gretl_matrix *theta,
                    int method,
                    const DATASET *dset);

vector_to_midas_list ()

int *
vector_to_midas_list (const gretl_matrix *v,
                      int f_ratio,
                      const char *prefix,
                      DATASET *dset,
                      int *err);

imhof ()

double
imhof (const gretl_matrix *m,
       double arg,
       int *err);

dw_pval ()

double
dw_pval (const gretl_matrix *u,
         const gretl_matrix *X,
         double *pDW,
         int *err);

multi_acf ()

gretl_matrix *
multi_acf (const gretl_matrix *m,
           const int *list,
           const DATASET *dset,
           int p,
           int *err);

multi_xcf ()

gretl_matrix *
multi_xcf (const void *px,
           int xtype,
           const void *py,
           int ytype,
           const DATASET *dset,
           int p,
           int *err);

forecast_stats ()

gretl_matrix *
forecast_stats (const double *y,
                const double *f,
                int t1,
                int t2,
                int *n_used,
                gretlopt opt,
                int *err);

matrix_fc_stats ()

gretl_matrix *
matrix_fc_stats (const double *y,
                 const gretl_matrix *F,
                 gretlopt opt,
                 int *err);

duration_func ()

gretl_matrix *
duration_func (const double *y,
               const double *cens,
               int t1,
               int t2,
               gretlopt opt,
               int *err);

gretl_round ()

double
gretl_round (double x);

gretl_sgn ()

double
gretl_sgn (double x);

gretl_bessel ()

double
gretl_bessel (char type,
              double v,
              double x,
              int *err);

gretl_npv ()

double
gretl_npv (int t1,
           int t2,
           const double *x,
           double r,
           int pd,
           int *err);

gretl_irr ()

double
gretl_irr (const double *x,
           int n,
           int pd,
           int *err);

logistic_cdf ()

double
logistic_cdf (double x);

list_ok_dollar_vars ()

int
list_ok_dollar_vars (DATASET *dset,
                     PRN *prn);

nadaraya_watson ()

int
nadaraya_watson (const double *y,
                 const double *x,
                 double h,
                 DATASET *dset,
                 int LOO,
                 double trim,
                 double *m);

Implements the Nadaraya-Watson nonparametric estimator for the conditional mean of y given x via the formula

\widehat{m}_h(x)=\frac{\sum_{i=1}^n K_h(x-X_i) Y_i}{\sum_{i=1}^nK_h(x-X_i)}

and computes it for all elements of x . Note that, in principle, the kernel K(X_i-X_j) must be computed for every combination of i and j, but since the function K() is assumed to be symmetric, we compute it once to save time.

The scalar h holds the kernel bandwidth; if LOO is non-zero the "leave-one-out" variant of the estimator (essentially a jackknife estimator; see Pagan and Ullah, Nonparametric Econometrics, p. 119) is computed.

A rudimentary form of trimming is implemented: the kernel function is set to 0 when the product of the trim parameter times the bandwidth h exceeds |X_i - X_j|, so as to speed computation and enhance numerical stability.

Parameters

y

array with "dependent variable"

 

x

array with "explanatory variable"

 

h

double, bandwidth (may be negative; see below)

 

dset

data set information.

 

LOO

Boolean flag (see below)

 

trim

trim parameter (see below)

 

m

array to hold results

 

Returns

0 on successful completion, non-zero code on error.


gretl_loess ()

int
gretl_loess (const double *y,
             const double *x,
             int poly_order,
             double bandwidth,
             gretlopt opt,
             DATASET *dset,
             double *m);

series_get_nobs ()

double
series_get_nobs (int t1,
                 int t2,
                 const double *x);

series_sum_all ()

double
series_sum_all (int t1,
                int t2,
                const double *x);

aggregate_by ()

gretl_matrix *
aggregate_by (const double *x,
              const double *y,
              const int *xlist,
              const int *ylist,
              const char *fncall,
              const DATASET *dset,
              int *err);

Aggregates one or more data series (x) "by" the values of one or more discrete series (y). In general either x or xlist should be non-NULL, and one of y or ylist should be non-NULL. (If xlist is non-NULL then x is ignored, and similarly for ylist and y ). For an account of the matrix that is returned, see the help for gretl's "aggregate" command.

Parameters

x

data array.

 

y

discrete variable.

 

xlist

list of x series or NULL.

 

ylist

list of y series or NULL.

 

fncall

the name of the aggregation function.

 

dset

data set information.

 

err

location to receive error code.

 

Returns

allocated matrix, or NULL on failure.


fill_dataset_dates_series ()

int
fill_dataset_dates_series (const DATASET *dset,
                           double *x);

fill_day_of_week_array ()

int
fill_day_of_week_array (double *dow,
                        const double *y,
                        const double *m,
                        const double *d,
                        const DATASET *dset);

fill_isoweek_array ()

int
fill_isoweek_array (double *wknum,
                    const double *y,
                    const double *m,
                    const double *d,
                    const DATASET *dset);

empirical_cdf ()

gretl_matrix *
empirical_cdf (const double *y,
               int n,
               int *err);

Calculates the empirical CDF of y , skipping any missing values.

Parameters

y

array to process

 

n

length of y .

 

err

location to receive error code on failure.

 

Returns

on successful completion, a matrix with row dimension equal to the number of unique values in y , and two columns, the first containing the unique values of y and the second the cumulative relative frequency. On failure, returns NULL.


sample_span ()

int
sample_span (const char *stobs,
             const char *endobs,
             int pd,
             int *err);

gretl_matrix_vector_stat ()

gretl_matrix *
gretl_matrix_vector_stat (const gretl_matrix *m,
                          GretlVecStat vs,
                          int rowwise,
                          int skip_na,
                          int *err);

fill_permutation_vector ()

int
fill_permutation_vector (gretl_vector *v,
                         int n);

substitute_values ()

int
substitute_values (double *dest,
                   const double *src,
                   int n,
                   const double *v0,
                   int n0,
                   const double *v1,
                   int n1);

For each of the n elements in src , determine if it appears in v0 : if so, write to targ the corresponding element of v1 , otherwise write the src element to targ . The method employed is either "naive" lookup, or if the problem is of sufficient size a binary tree.

Parameters

dest

target array.

 

src

source array.

 

n

length of src and dest .

 

v0

array of "find" values.

 

n0

length of v0 .

 

v1

array of "replace" values.

 

n1

length of v1 .

 

Returns

0 on successful completion, non-zero code on error.


list_from_matrix ()

int *
list_from_matrix (const gretl_matrix *m,
                  const char *prefix,
                  DATASET *dset,
                  int *err);

Constructs a series from each column of m and returns a list of the series.

Parameters

m

source matrix.

 

prefix

prefix for series names or NULL.

 

dset

pointer to dataset.

 

err

location to receive error code.

 

Returns

list on successful completion, NULL otherwise.


omega_from_R ()

gretl_matrix *
omega_from_R (const gretl_matrix *R,
              int *err);

Expresses the (n x n) correlation matrix R in spherical coordinates, via m angles, where m = n*(n-1)/2.

Parameters

R

correlation matrix.

 

err

location to receive error code.

 

Returns

an m-element vector if successful, NULL on failure.


R_from_omega ()

gretl_matrix *
R_from_omega (const gretl_matrix *omega,
              int cholesky,
              gretl_matrix *J,
              int *err);

Returns an (n x n) correlation matrix R given its spherical-coordinates representation omega, which should contain m numbers between 0 and M_PI, where m = n*(n-1)/2.

Parameters

omega

angle vector.

 

cholesky

boolean, compute cholesky factor instead of correlation matrix.

 

J

location to receive Jacobian matrix if wanted, or NULL.

 

err

location to receive error code.

 

Returns

an n x n symmetric matrix if successful, NULL on failure.


felogit_rec_loglik ()

gretl_matrix *
felogit_rec_loglik (int t,
                    int T,
                    const gretl_matrix *U,
                    const gretl_matrix *xi);

t : int, number of ones T : int, number of observations U : matrix with the index function X : matrix with the covariates

Computes recursively the denominator of the fixed-effect logit likelihood for one unit with T observations and t ones, as well as its first derivative wrt the parameter vector beta. The matrix U is a vector containing the values of the index function for each time period and X is the corresponding matrix of covariates, so that U[i] = exp(X[i,]*beta).

The first element of the output vector is the likelihood denominator (B in Gail et al's notation) and the subsequent k elements contain the derivative of B wrt beta.

The algorithm is described in Gail et al. (1981), "Likelihood Calculations for Matched Case-Control Studies and Survival Studies with Tied Death Times", Biometrika, Vol. 68 (3), pp. 703-707

Returns

a (k+1)-vector if successful, NULL on failure.


maybe_get_values_map ()

int *
maybe_get_values_map (const double *x,
                      int n,
                      int *pnv,
                      int *err);

matrix_dset_plus_lists ()

DATASET *
matrix_dset_plus_lists (const gretl_matrix *m1,
                        const gretl_matrix *m2,
                        int **plist1,
                        int **plist2,
                        int *err);