Descriptive statistics

Descriptive statistics — descriptive statistics plus some tests

Synopsis

#include <libgretl.h>

typedef             MahalDist;
                    Summary;
                    FreqDist;
                    Xtab;
int                 eval_ytest                          (double y,
                                                         GretlOp op,
                                                         double test);
int                 gretl_minmax                        (int t1,
                                                         int t2,
                                                         const double *x,
                                                         double *min,
                                                         double *max);
double              gretl_min                           (int t1,
                                                         int t2,
                                                         const double *x);
double              gretl_max                           (int t1,
                                                         int t2,
                                                         const double *x);
double              gretl_sum                           (int t1,
                                                         int t2,
                                                         const double *x);
double              gretl_mean                          (int t1,
                                                         int t2,
                                                         const double *x);
double              gretl_restricted_mean               (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y,
                                                         GretlOp yop,
                                                         double yval);
double              gretl_quantile                      (int t1,
                                                         int t2,
                                                         const double *x,
                                                         double p,
                                                         gretlopt opt,
                                                         int *err);
int                 gretl_array_quantiles               (double *a,
                                                         int n,
                                                         double *p,
                                                         int k);
double              gretl_array_quantile                (double *a,
                                                         int n,
                                                         double p);
double              gretl_median                        (int t1,
                                                         int t2,
                                                         const double *x);
double              gretl_sst                           (int t1,
                                                         int t2,
                                                         const double *x);
double              gretl_variance                      (int t1,
                                                         int t2,
                                                         const double *x);
double              gretl_restricted_variance           (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y,
                                                         GretlOp yop,
                                                         double yval);
double              gretl_stddev                        (int t1,
                                                         int t2,
                                                         const double *x);
double              gretl_restricted_stddev             (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y,
                                                         GretlOp yop,
                                                         double yval);
double              gretl_long_run_variance             (int t1,
                                                         int t2,
                                                         const double *x,
                                                         int m);
double              gretl_covar                         (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y,
                                                         int *missing);
double              gretl_corr                          (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y,
                                                         int *missing);
double              gretl_corr_rsq                      (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y);
double              gretl_skewness                      (int t1,
                                                         int t2,
                                                         const double *x);
double              gretl_kurtosis                      (int t1,
                                                         int t2,
                                                         const double *x);
int                 gretl_moments                       (int t1,
                                                         int t2,
                                                         const double *x,
                                                         double *xbar,
                                                         double *sd,
                                                         double *skew,
                                                         double *kurt,
                                                         int k);
double *            gretl_sorted_series                 (int v,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         int *n,
                                                         int *err);
void                free_freq                           (FreqDist *freq);
int                 freq_setup                          (int v,
                                                         const DATASET *dset,
                                                         int *pn,
                                                         double *pxmax,
                                                         double *pxmin,
                                                         int *nbins,
                                                         double *binwidth);
FreqDist *          get_freq                            (int varno,
                                                         const DATASET *dset,
                                                         double fmin,
                                                         double fwid,
                                                         int nbins,
                                                         int params,
                                                         gretlopt opt,
                                                         int *err);
FreqDist *          get_discrete_freq                   (int v,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         int *err);
int                 freqdist                            (int varno,
                                                         const DATASET *dset,
                                                         int *graph,
                                                         gretlopt opt,
                                                         PRN *prn);
gretl_matrix *      freqdist_matrix                     (const double *x,
                                                         int t1,
                                                         int t2,
                                                         int *err);
int                 crosstab                            (const int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 crosstab_from_matrix                (gretlopt opt,
                                                         PRN *prn);
int                 compare_xtab_rows                   (const void *a,
                                                         const void *b);
Xtab *              single_crosstab                     (const int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn,
                                                         int *err);
gretl_matrix *      xtab_to_matrix                      (const Xtab *tab);
void                free_xtab                           (Xtab *tab);
int                 model_error_dist                    (const MODEL *pmod,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 auto_acf_order                      (int T);
int                 auto_spectrum_order                 (int T,
                                                         gretlopt opt);
int                 corrgram                            (int varno,
                                                         int order,
                                                         int nparam,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 xcorrgram                           (const int *list,
                                                         int order,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 periodogram                         (int varno,
                                                         int width,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
gretl_matrix *      periodogram_matrix                  (const double *x,
                                                         int t1,
                                                         int t2,
                                                         int width,
                                                         int *err);
int                 fractint                            (int varno,
                                                         int order,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
Summary *           get_summary                         (const int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn,
                                                         int *err);
Summary *           get_summary_restricted              (const int *list,
                                                         const DATASET *dset,
                                                         const double *rv,
                                                         gretlopt opt,
                                                         PRN *prn,
                                                         int *err);
int                 list_summary                        (const int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
void                print_summary                       (const Summary *summ,
                                                         const DATASET *dset,
                                                         PRN *prn);
void                print_summary_single                (const Summary *s,
                                                         int digits,
                                                         int places,
                                                         const DATASET *dset,
                                                         PRN *prn);
int                 summary_has_missing_values          (const Summary *summ);
void                free_summary                        (Summary *summ);
VMatrix *           corrlist                            (int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         int *err);
VMatrix *           vmatrix_new                         (void);
void                free_vmatrix                        (VMatrix *vmat);
int                 gretl_corrmx                        (int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 means_test                          (const int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 vars_test                           (const int *list,
                                                         const DATASET *dset,
                                                         PRN *prn);
void                print_corrmat                       (VMatrix *corr,
                                                         const DATASET *dset,
                                                         PRN *prn);
double              doornik_chisq                       (double skew,
                                                         double xkurt,
                                                         int n);
int                 multivariate_normality_test         (const gretl_matrix *E,
                                                         const gretl_matrix *Sigma,
                                                         PRN *prn);
int                 mahalanobis_distance                (const int *list,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
MahalDist *         get_mahal_distances                 (const int *list,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn,
                                                         int *err);
void                free_mahal_dist                     (MahalDist *md);
const double *      mahal_dist_get_distances            (const MahalDist *md);
int                 mahal_dist_get_n                    (const MahalDist *md);
const int *         mahal_dist_get_varlist              (const MahalDist *md);
double              gretl_gini                          (int t1,
                                                         int t2,
                                                         const double *x);
int                 gini                                (int varno,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 shapiro_wilk                        (const double *x,
                                                         int t1,
                                                         int t2,
                                                         double *W,
                                                         double *pval);
int                 gretl_normality_test                (int varno,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);
gretl_matrix *      acf_matrix                          (const double *x,
                                                         int order,
                                                         const DATASET *dset,
                                                         int n,
                                                         int *err);
gretl_matrix *      xcf_vec                             (const double *x,
                                                         const double *y,
                                                         int p,
                                                         const DATASET *dset,
                                                         int n,
                                                         int *err);
double              ljung_box                           (int m,
                                                         int t1,
                                                         int t2,
                                                         const double *y,
                                                         int *err);

Description

Computation and printing of numerous descriptive statistics along with some hypothesis tests, for example regarding the normality of a data series.

Details

MahalDist

typedef struct MahalDist_ MahalDist;


Summary

typedef struct {
    gretlopt opt;
    int n;
    int *misscount;
    int *list;
    double *stats;
    double *mean;
    double *median;
    double *sd;
    double *skew; 
    double *xkurt;
    double *low;
    double *high;
    double *cv;
    double *perc05;
    double *perc95;
    double *iqr;
    double sw;
    double sb;
} Summary;


FreqDist

typedef struct {
    char varname[VNAMELEN];  /* for ID purposes */
    int discrete;            /* 1 if variable contains integers */
    int dist;                /* code for theoretical distribution */
    int numbins;             /* number of bins or intervals */
    double xbar, sdx;        /* mean and std dev of variable */
    double *midpt;           /* array of midpoints of intervals */
    double *endpt;           /* array of endpoints of intervals */
    int *f;                  /* frequencies in the intervals */
    double test;             /* either Chi-squared statistic for testing
                                for a Gaussian distribution, or z statistic
			        for testing for Gamma dist. */
    int n;
    int t1, t2;
} FreqDist;


Xtab

typedef struct {
    char rvarname[VNAMELEN]; 
    char cvarname[VNAMELEN]; 
    int rows, cols;
    double *rval, *cval;
    int *rtotal, *ctotal;
    int **f;
    int n, missing;
    int t1, t2;
    const char **rlabels, **clabels;
} Xtab;


eval_ytest ()

int                 eval_ytest                          (double y,
                                                         GretlOp op,
                                                         double test);

y :

reference numerical value.

op :

operator.

test :

numerical test value.

Returns :

1 if the expression y yop test (for example "y = 2" or "y <= 45") evaluates as true, else 0.

gretl_minmax ()

int                 gretl_minmax                        (int t1,
                                                         int t2,
                                                         const double *x,
                                                         double *min,
                                                         double *max);

Puts the minimum and maximum values of the series x, from obs t1 to obs t2, into the variables min and max.

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

min :

location to receive minimum value.

max :

location to receive maximum value.

Returns :

the number of valid observations in the given data range.

gretl_min ()

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

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

Returns :

the minimum value of x over the given range, or NADBL if no valid vaues are found.

gretl_max ()

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

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

Returns :

the maximum value of x over the given range, or NADBL if no valid vaues are found.

gretl_sum ()

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

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

Returns :

the sum of the series x from obs t1 to obs t2, skipping any missing values, or NADBL in case there are no valid observations.

gretl_mean ()

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

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

Returns :

the arithmetic mean of the series x from obs t1 to obs t2, skipping any missing values, or NADBL in case there are no valid observations.

gretl_restricted_mean ()

double              gretl_restricted_mean               (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y,
                                                         GretlOp yop,
                                                         double yval);

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

y :

criterion series.

yop :

criterion operator.

yval :

criterion value.

Returns :

the arithmetic mean of the series x in the range t1 to t2 (inclusive), but including only observations where the criterion variable y bears the relationship yop to the value yval -- or NADBL in case there are no observations that satisfy the restriction.

gretl_quantile ()

double              gretl_quantile                      (int t1,
                                                         int t2,
                                                         const double *x,
                                                         double p,
                                                         gretlopt opt,
                                                         int *err);

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

p :

probability.

opt :

may include OPT_Q to hush warning when sample is too small.

err :

location to receive error code.

Returns :

the p quantile of the series x from obs t1 to obs t2, skipping any missing values, or NADBL on failure.

gretl_array_quantiles ()

int                 gretl_array_quantiles               (double *a,
                                                         int n,
                                                         double *p,
                                                         int k);

Computes k quantiles (given by the elements of p) for the first n elements of the array a, which is re-ordered in the process. On successful exit, p contains the quantiles.

a :

data array (this gets re-ordered).

n :

length of array.

p :

array of probabilities (over-written by quantiles).

k :

number of probabilities.

Returns :

0 on success, non-zero code on error.

gretl_array_quantile ()

double              gretl_array_quantile                (double *a,
                                                         int n,
                                                         double p);

a :

array on which to operate.

n :

number of elements in a.

p :

probability.

Returns :

the p quantile of the first n elements in a, which is re-ordered in the process, or NADBL on failure.

gretl_median ()

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

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

Returns :

the median value of the series x from obs t1 to obs t2, skipping any missing values, or NADBL on failure.

gretl_sst ()

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

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

Returns :

the sum of squared deviations from the mean for the series x from obs t1 to obs t2, skipping any missing values, or NADBL on failure.

gretl_variance ()

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

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

Returns :

the variance of the series x from obs t1 to obs t2, skipping any missing values, or NADBL on failure.

gretl_restricted_variance ()

double              gretl_restricted_variance           (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y,
                                                         GretlOp yop,
                                                         double yval);

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

y :

criterion series.

yop :

criterion operator.

yval :

criterion value.

Returns :

the variance of the series x from obs t1 to obs t2, skipping any missing values and observations where the series y does not bear the relationship yop to the value yval, or NADBL on failure.

gretl_stddev ()

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

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

Returns :

the standard deviation of the series x from obs t1 to obs t2, skipping any missing values, or NADBL on failure.

gretl_restricted_stddev ()

double              gretl_restricted_stddev             (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y,
                                                         GretlOp yop,
                                                         double yval);

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

y :

criterion series.

yop :

criterion operator.

yval :

criterion value.

Returns :

the standard deviation of the series x from obs t1 to obs t2, skipping any missing values and observations where the series y does not bear the relationship yop to the value yval, or NADBL on failure.

gretl_long_run_variance ()

double              gretl_long_run_variance             (int t1,
                                                         int t2,
                                                         const double *x,
                                                         int m);

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

m :

bandwidth.

Returns :

the long-run variance of the series x from obs t1 to obs t2, using Bartlett kernel weights, or NADBL on failure (which includes encountering missing values).

gretl_covar ()

double              gretl_covar                         (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y,
                                                         int *missing);

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

y :

data series.

missing :

location to receive information on the number of missing observations that were skipped, or NULL.

Returns :

the covariance of the series x and y from obs t1 to obs t2, skipping any missing values, or NADBL on failure.

gretl_corr ()

double              gretl_corr                          (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y,
                                                         int *missing);

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

y :

data series.

missing :

location to receive information on the number of missing observations that were skipped, or NULL.

Returns :

the correlation coefficient for the series x and y from obs t1 to obs t2, skipping any missing values, or NADBL on failure.

gretl_corr_rsq ()

double              gretl_corr_rsq                      (int t1,
                                                         int t2,
                                                         const double *x,
                                                         const double *y);

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

y :

data series.

Returns :

the square of the correlation coefficient for the series x and y from obs t1 to obs t2, skipping any missing values, or NADBL on failure. Used as alternative value for R^2 in a regression without an intercept.

gretl_skewness ()

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


gretl_kurtosis ()

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


gretl_moments ()

int                 gretl_moments                       (int t1,
                                                         int t2,
                                                         const double *x,
                                                         double *xbar,
                                                         double *sd,
                                                         double *skew,
                                                         double *kurt,
                                                         int k);

Calculates sample moments for series x from obs t1 to obs t2.

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

xbar :

pointer to receive mean.

sd :

pointer to receive standard deviation.

skew :

pointer to receive skewness.

kurt :

pointer to receive excess kurtosis.

k :

degrees of freedom loss (generally 1).

Returns :

0 on success, 1 on error.

gretl_sorted_series ()

double *            gretl_sorted_series                 (int v,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         int *n,
                                                         int *err);

v :

ID number of input series.

dset :

dataset struct.

opt :

may include OPT_M to flag an error in case missing values are found.

n :

on input, the minimum acceptable number of non-missing observations; on output, the number of valid observations.

err :

location to receive error code.

Returns :

an array containing the valid values of the input series over the sample range given in dset, sorted from smallest to largest, or NULL on error. An error is flagged if the number of valid observations is less than that given in n on input, or if OPT_M is given and the input contains missing values.

free_freq ()

void                free_freq                           (FreqDist *freq);

Frees all resources associated with freq, and the pointer itself.

freq :

pointer to gretl frequency distribution struct

freq_setup ()

int                 freq_setup                          (int v,
                                                         const DATASET *dset,
                                                         int *pn,
                                                         double *pxmax,
                                                         double *pxmin,
                                                         int *nbins,
                                                         double *binwidth);


get_freq ()

FreqDist *          get_freq                            (int varno,
                                                         const DATASET *dset,
                                                         double fmin,
                                                         double fwid,
                                                         int nbins,
                                                         int params,
                                                         gretlopt opt,
                                                         int *err);

Calculates the frequency distribution for the specified variable.

varno :

ID number of variable to process.

dset :

dataset struct.

fmin :

lower limit of left-most bin (or NADBL for automatic).

fwid :

bin width (or NADBL for automatic).

nbins :

number of bins to use (or 0 for automatic).

params :

degrees of freedom loss (generally = 1 unless we're dealing with the residual from a regression).

opt :

if includes OPT_Z, set up for comparison with normal dist; if includes OPT_O, compare with gamma distribution; if includes OPT_Q, do not show a graph; if includes OPT_D, treat the variable as discrete; OPT_X indicates that this function is called as part of a cross-tabulation.

err :

location to receive error code.

Returns :

pointer to struct containing the distribution.

get_discrete_freq ()

FreqDist *          get_discrete_freq                   (int v,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         int *err);


freqdist ()

int                 freqdist                            (int varno,
                                                         const DATASET *dset,
                                                         int *graph,
                                                         gretlopt opt,
                                                         PRN *prn);


freqdist_matrix ()

gretl_matrix *      freqdist_matrix                     (const double *x,
                                                         int t1,
                                                         int t2,
                                                         int *err);


crosstab ()

int                 crosstab                            (const int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);


crosstab_from_matrix ()

int                 crosstab_from_matrix                (gretlopt opt,
                                                         PRN *prn);


compare_xtab_rows ()

int                 compare_xtab_rows                   (const void *a,
                                                         const void *b);


single_crosstab ()

Xtab *              single_crosstab                     (const int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn,
                                                         int *err);


xtab_to_matrix ()

gretl_matrix *      xtab_to_matrix                      (const Xtab *tab);


free_xtab ()

void                free_xtab                           (Xtab *tab);

Frees all resources associated with tab, and the pointer itself.

tab :

pointer to gretl crosstab struct.

model_error_dist ()

int                 model_error_dist                    (const MODEL *pmod,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);


auto_acf_order ()

int                 auto_acf_order                      (int T);


auto_spectrum_order ()

int                 auto_spectrum_order                 (int T,
                                                         gretlopt opt);


corrgram ()

int                 corrgram                            (int varno,
                                                         int order,
                                                         int nparam,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);

Computes the autocorrelation function and plots the correlogram for the variable specified by varno.

varno :

ID number of variable to process.

order :

integer order for autocorrelation function.

nparam :

number of estimated parameters (e.g. for the case of ARMA), used to correct the degrees of freedom for Q test.

dset :

dataset struct.

opt :

if includes OPT_R, variable in question is a model residual generated "on the fly"; OPT_U can be used to specify a plot option.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

xcorrgram ()

int                 xcorrgram                           (const int *list,
                                                         int order,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);

Computes the cross-correlation function and plots the cross-correlogram for the specified variables.

list :

should contain ID numbers of two variables.

order :

integer order for autocorrelation function.

dset :

dataset struct.

opt :

may include OPT_U for plot options.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

periodogram ()

int                 periodogram                         (int varno,
                                                         int width,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);

Computes and displays the periodogram for the series specified by varno.

varno :

ID number of variable to process.

width :

width of window.

dset :

dataset struct.

opt :

if includes OPT_O, use Bartlett lag window for periodogram; if includes OPT_R, the variable is a model residual; OPT_L, use log scale.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

periodogram_matrix ()

gretl_matrix *      periodogram_matrix                  (const double *x,
                                                         int t1,
                                                         int t2,
                                                         int width,
                                                         int *err);

Implements the userspace gretl pergm function, which can be used on either a series from the dataset or a gretl vector.

x :

the series to process.

t1 :

starting observation in x.

t2 :

ending observation in x.

width :

width of Bartlett window, or -1 for plain sample periodogram.

err :

location to receive error code.

Returns :

allocated matrix on success, NULL on failure.

fractint ()

int                 fractint                            (int varno,
                                                         int order,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);

Computes and prints a test for fractional integration of the series specified by varno. By default the test uses the Local Whittle Estimator but if opt includes OPT_G then the Geweke and Porter-Hudak test is done instead, or if OPT_A then both tests are shown. If OPT_Q is given the test results are not printed, just recorded (with preference given to the LWE in case of OPT_A).

varno :

ID number of variable to process.

order :

lag order / window size.

dset :

dataset struct.

opt :

option flags.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

get_summary ()

Summary *           get_summary                         (const int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn,
                                                         int *err);

Calculates descriptive summary statistics for the specified variables.

list :

list of variables to process.

dset :

dataset struct.

opt :

may include OPT_S for "simple" version.

prn :

gretl printing struct.

err :

location to receive error code.

Returns :

Summary object containing the summary statistics, or NULL on failure.

get_summary_restricted ()

Summary *           get_summary_restricted              (const int *list,
                                                         const DATASET *dset,
                                                         const double *rv,
                                                         gretlopt opt,
                                                         PRN *prn,
                                                         int *err);

Calculates descriptive summary statistics for the specified variables, with the observations restricted to those for which rv has a non-zero (and non-missing) value. The series rv must be of full length (dset->n).

list :

list of variables to process.

dset :

dataset struct.

rv :

series to use as restriction dummy.

opt :

may include OPT_S for "simple" version.

prn :

gretl printing struct.

err :

location to receive error code.

Returns :

Summary object containing the summary statistics, or NULL on failure.

list_summary ()

int                 list_summary                        (const int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);

Prints descriptive statistics for the listed variables.

list :

list of series to process.

dset :

dataset struct.

opt :

may include OPT_S for "simple" version.

prn :

gretl printing struct.

Returns :

0 on success, non-zero code on error.

print_summary ()

void                print_summary                       (const Summary *summ,
                                                         const DATASET *dset,
                                                         PRN *prn);

Prints the summary statistics for a given variable.

summ :

pointer to gretl summary statistics struct.

dset :

information on the data set.

prn :

gretl printing struct.

print_summary_single ()

void                print_summary_single                (const Summary *s,
                                                         int digits,
                                                         int places,
                                                         const DATASET *dset,
                                                         PRN *prn);


summary_has_missing_values ()

int                 summary_has_missing_values          (const Summary *summ);


free_summary ()

void                free_summary                        (Summary *summ);

Frees all resources associated with summ, and the pointer itself.

summ :

pointer to gretl summary statistics struct

corrlist ()

VMatrix *           corrlist                            (int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         int *err);

Computes pairwise correlation coefficients for the variables specified in list, skipping any constants. If the option flags contain OPT_U, a uniform sample is ensured: only those observations for which all the listed variables have valid values are used. If OPT_C is included, we actually calculate covariances rather than correlations.

list :

list of variables to process, by ID number.

dset :

dataset struct.

opt :

option flags.

err :

location to receive error code.

Returns :

gretl correlation matrix struct, or NULL on failure.

vmatrix_new ()

VMatrix *           vmatrix_new                         (void);

Returns :

an allocated and initialized VMatrix, or NULL on failure.

free_vmatrix ()

void                free_vmatrix                        (VMatrix *vmat);

Frees all resources associated with vmat, and the pointer itself.

vmat :

pointer to gretl correlation matrix struct

gretl_corrmx ()

int                 gretl_corrmx                        (int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);

Computes and prints the correlation matrix for the specified list of variables.

list :

gives the ID numbers of the variables to process.

dset :

dataset struct.

opt :

option flags: OPT_U = use uniform sample size.

prn :

gretl printing struct.

Returns :

0 on successful completion, 1 on error.

means_test ()

int                 means_test                          (const int *list,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);

Carries out test of the null hypothesis that the means of two variables are equal.

list :

gives the ID numbers of the variables to compare.

dset :

dataset struct.

opt :

if OPT_O, assume population variances are different.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

vars_test ()

int                 vars_test                           (const int *list,
                                                         const DATASET *dset,
                                                         PRN *prn);

Carries out test of the null hypothesis that the variances of two variables are equal.

list :

gives the ID numbers of the variables to compare.

dset :

dataset struct.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

print_corrmat ()

void                print_corrmat                       (VMatrix *corr,
                                                         const DATASET *dset,
                                                         PRN *prn);

Prints a gretl correlation matrix to prn.

corr :

gretl correlation matrix.

dset :

dataset information.

prn :

gretl printing struct.

doornik_chisq ()

double              doornik_chisq                       (double skew,
                                                         double xkurt,
                                                         int n);

Calculates the Chi-square test for normality as set out by Doornik and Hansen, "An Omnibus Test for Normality", 1994. This is a modified version of the test proposed by Bowman and Shenton (Biometrika, 1975).

skew :

skewness.

xkurt :

excess kurtosis.

n :

number of observations.

Returns :

the Chi-square value, which has 2 degrees of freedom.

multivariate_normality_test ()

int                 multivariate_normality_test         (const gretl_matrix *E,
                                                         const gretl_matrix *Sigma,
                                                         PRN *prn);


mahalanobis_distance ()

int                 mahalanobis_distance                (const int *list,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);


get_mahal_distances ()

MahalDist *         get_mahal_distances                 (const int *list,
                                                         DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn,
                                                         int *err);


free_mahal_dist ()

void                free_mahal_dist                     (MahalDist *md);


mahal_dist_get_distances ()

const double *      mahal_dist_get_distances            (const MahalDist *md);


mahal_dist_get_n ()

int                 mahal_dist_get_n                    (const MahalDist *md);


mahal_dist_get_varlist ()

const int *         mahal_dist_get_varlist              (const MahalDist *md);


gretl_gini ()

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

t1 :

starting observation.

t2 :

ending observation.

x :

data series.

Returns :

the Gini coefficient for the series x from obs t1 to obs t2, skipping any missing values, or NADBL on failure.

gini ()

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

Graphs the Lorenz curve for variable vnum and prints the Gini coefficient.

varno :

ID number of variable to examine.

dset :

dataset struct.

opt :

unused at present.

prn :

gretl printing struct.

Returns :

0 on successful completion, error code on error.

shapiro_wilk ()

int                 shapiro_wilk                        (const double *x,
                                                         int t1,
                                                         int t2,
                                                         double *W,
                                                         double *pval);

Computes the Shapiro-Wilk W statistic as a test for normality of the data x, and also the p-value for the test. These are written into the pointer arguments W and pval.

x :

data array.

t1 :

starting observation.

t2 :

ending observation.

W :

location to receive test statistic.

pval :

location to receive p-value.

Returns :

0 on success, non-zero on failure.

gretl_normality_test ()

int                 gretl_normality_test                (int varno,
                                                         const DATASET *dset,
                                                         gretlopt opt,
                                                         PRN *prn);

Performs, and prints the results of, the specified test(s) randomness for the variable specified by v.

varno :

ID number of the variable to process.

dset :

dataset struct.

opt :

OPT_A: all tests; OPT_D: Doornik-Hansen; OPT_W: Shapiro-Wilk; OPT_J: Jarque-Bera; OPT_L: Lilliefors; default is Doornik-Hansen. Also use OPT_Q for quiet.

prn :

gretl printing struct.

Returns :

0 on successful completion, non-zero on error.

acf_matrix ()

gretl_matrix *      acf_matrix                          (const double *x,
                                                         int order,
                                                         const DATASET *dset,
                                                         int n,
                                                         int *err);

Computes the autocorrelation function for series x with maximum lag order.

x :

series to analyse.

order :

maximum lag for autocorrelation function.

dset :

information on the data set, or NULL.

n :

length of series (required if dset is NULL).

err :

location to receive error code.

Returns :

two-column matrix containing the values of the ACF and PACF at the successive lags, or NULL on error.

xcf_vec ()

gretl_matrix *      xcf_vec                             (const double *x,
                                                         const double *y,
                                                         int p,
                                                         const DATASET *dset,
                                                         int n,
                                                         int *err);

Computes the cross-correlation function for series x with series y up to maximum lag order.

x :

first series.

y :

second series.

p :

maximum lag for cross-correlation function.

dset :

information on the data set, or NULL.

n :

length of series (required only if dset is NULL).

err :

location to receive error code.

Returns :

column vector containing the values of the cross-correlation function, or NULL on error.

ljung_box ()

double              ljung_box                           (int m,
                                                         int t1,
                                                         int t2,
                                                         const double *y,
                                                         int *err);

m :

maximum lag.

t1 :

starting observation.

t2 :

ending observation.

y :

data series.

err :

location to receive error code.

Returns :

the Ljung-Box statistic for lag order m for the series y over the sample t1 to t2, or NADBL on failure.