| Libgretl Reference Manual |
|---|
describedescribe — |
typedef Summary; typedef FreqDist; typedef Xtab; typedef MahalDist; struct Summary_; struct FreqDist_; struct 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); 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); 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_acf (int k, int t1, int t2, const double *y); double gretl_xcf (int k, int t1, int t2, const double *x, const double *y); int gretl_moments (int t1, int t2, const double *x, double *xbar, double *sd, double *skew, double *kurt, int k); void free_freq (FreqDist *freq); int freq_setup (int v, const double **Z, const DATAINFO *pdinfo, int *pn, double *pxmax, double *pxmin, int *nbins, double *binwidth); FreqDist* get_freq (int varno, const double **Z, const DATAINFO *pdinfo, double fmin, double fwid, int nbins, int params, gretlopt opt, int *err); int freqdist (int varno, const double **Z, const DATAINFO *pdinfo, int graph, gretlopt opt, PRN *prn); int crosstab (const int *list, const double **Z, const DATAINFO *pdinfo, gretlopt opt, PRN *prn); int model_error_dist (const MODEL *pmod, double ***pZ, DATAINFO *pdinfo, PRN *prn); int auto_acf_order (int pd, int nobs); int auto_spectrum_order (int T, gretlopt opt); int corrgram (int varno, int order, int nparam, double ***pZ, DATAINFO *pdinfo, PRN *prn, gretlopt opt); int xcorrgram (const int *list, int order, double ***pZ, DATAINFO *pdinfo, PRN *prn, gretlopt opt); int periodogram (int varno, int width, double ***pZ, const DATAINFO *pdinfo, gretlopt opt, PRN *prn); Summary* summary (const int *list, const double **Z, const DATAINFO *pdinfo, PRN *prn); void print_summary (const Summary *summ, const DATAINFO *pdinfo, PRN *prn); void free_summary (Summary *summ); VMatrix* corrlist (int *list, const double **Z, const DATAINFO *pdinfo, gretlopt opt, int *err); VMatrix* vmatrix_new (void); void free_vmatrix (VMatrix *vmat); int gretl_corrmx (int *list, const double **Z, const DATAINFO *pdinfo, gretlopt opt, PRN *prn); int means_test (const int *list, const double **Z, const DATAINFO *pdinfo, gretlopt opt, PRN *prn); int vars_test (const int *list, const double **Z, const DATAINFO *pdinfo, PRN *prn); void print_corrmat (VMatrix *corr, const DATAINFO *pdinfo, PRN *prn); double dh_root_b1_to_z1 (double rb1, double n); double dh_b2_to_z2 (double b1, double b2, double n); double doornik_chisq (double skew, double xkurt, int n); int gretl_system_normality_test (const gretl_matrix *E, const gretl_matrix *Sigma, PRN *prn); int mahalanobis_distance (const int *list, double ***pZ, DATAINFO *pdinfo, gretlopt opt, PRN *prn); MahalDist* get_mahal_distances (const int *list, double ***pZ, DATAINFO *pdinfo, gretlopt opt, PRN *prn); 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 vnum, const double **Z, DATAINFO *pdinfo, gretlopt opt, PRN *prn);
struct Summary_ {
int n;
int missing;
int *list;
double *stats;
double *mean;
double *median;
double *sd;
double *skew;
double *xkurt;
double *low;
double *high;
double *cv;
double sw;
double sb;
};
struct FreqDist_ {
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;
};
struct Xtab_ {
char rvarname[VNAMELEN];
char cvarname[VNAMELEN];
int rows, cols;
double *rval, *cval;
int *rtotal, *ctotal;
int **f;
int n, missing;
int t1, t2;
};
int eval_ytest (double y,
GretlOp op,
double test);
y : |
reference value. |
op : |
operator. |
test : |
test value. |
| Returns : | 1 if the expression y yop test (for example
"y = 2" or "y <= 45") evaluates as true, else 0.
|
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 : |
pointer to receive minimum value. |
max : |
pointer to receive maximum value. |
| Returns : | 0 on success, 1 on failure. |
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.
|
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.
|
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.
|
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.
|
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.
|
double gretl_quantile (int t1,
int t2,
const double *x,
double p);
t1 : |
starting observation. |
t2 : |
ending observation. |
x : |
data series. |
p : |
required quantile. |
| Returns : | the p-quantile value of the series x from obs
t1 to obs t2, skipping any missing values, or NADBL
on failure.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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).
|
double gretl_covar (int t1,
int t2,
const double *x,
const double *y);
t1 : |
starting observation. |
t2 : |
ending observation. |
x : |
data series. |
y : |
data series. |
| Returns : | the covariance of the series x and y from obs
t1 to obs t2, skipping any missing values, or NADBL
on failure.
|
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.
|
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.
|
double gretl_acf (int k,
int t1,
int t2,
const double *y);
k : |
lag order. |
t1 : |
starting observation. |
t2 : |
ending observation. |
y : |
data series. |
| Returns : | the autocorrelation at lag k for the series y over
the range t1 to t2, or NADBL on failure.
|
double gretl_xcf (int k,
int t1,
int t2,
const double *x,
const double *y);
k : |
lag order (or lead order if < 0). |
t1 : |
starting observation. |
t2 : |
ending observation. |
x : |
first data series. |
y : |
second data series. |
| Returns : | the cross-correlation at lag (or lead) k for the
series x and y over the range t1 to t2, or NADBL on failure.
|
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. |
void free_freq (FreqDist *freq);
Frees all malloced elements of the struct.
freq : |
gretl frequency distribution struct |
int freq_setup (int v,
const double **Z,
const DATAINFO *pdinfo,
int *pn,
double *pxmax,
double *pxmin,
int *nbins,
double *binwidth);
v : |
|
Z : |
|
pdinfo : |
|
pn : |
|
pxmax : |
|
pxmin : |
|
nbins : |
|
binwidth : |
|
| Returns : |
FreqDist* get_freq (int varno, const double **Z, const DATAINFO *pdinfo, 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. |
Z : |
data array. |
pdinfo : |
information on the data set. |
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 histogram; 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. |
int freqdist (int varno,
const double **Z,
const DATAINFO *pdinfo,
int graph,
gretlopt opt,
PRN *prn);
varno : |
|
Z : |
|
pdinfo : |
|
graph : |
|
opt : |
|
prn : |
|
| Returns : |
int crosstab (const int *list,
const double **Z,
const DATAINFO *pdinfo,
gretlopt opt,
PRN *prn);
list : |
|
Z : |
|
pdinfo : |
|
opt : |
|
prn : |
|
| Returns : |
int model_error_dist (const MODEL *pmod, double ***pZ, DATAINFO *pdinfo, PRN *prn);
pmod : |
|
pZ : |
|
pdinfo : |
|
prn : |
|
| Returns : |
int corrgram (int varno,
int order,
int nparam,
double ***pZ,
DATAINFO *pdinfo,
PRN *prn,
gretlopt opt);
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. |
pZ : |
pointer to data matrix. |
pdinfo : |
information on the data set. |
prn : |
gretl printing struct. |
opt : |
if includes OPT_A, use ASCII graphics; if includes
OPT_R, variable in question is a model residual generated
"on the fly".
|
| Returns : | 0 on successful completion, error code on error. |
int xcorrgram (const int *list,
int order,
double ***pZ,
DATAINFO *pdinfo,
PRN *prn,
gretlopt opt);
Computes the cross-cocorrelation function and plots the cross-correlogram for the specified variables.
list : |
should contain ID numbers of two variables. |
order : |
integer order for autocorrelation function. |
pZ : |
pointer to data matrix. |
pdinfo : |
information on the data set. |
prn : |
gretl printing struct. |
opt : |
if includes OPT_A, use ASCII graphics.
|
| Returns : | 0 on successful completion, error code on error. |
int periodogram (int varno,
int width,
double ***pZ,
const DATAINFO *pdinfo,
gretlopt opt,
PRN *prn);
Computes and displays the periodogram for the variable specified
by varno.
varno : |
ID number of variable to process. |
width : |
width of window. |
pZ : |
pointer to data matrix. |
pdinfo : |
information on the data set. |
opt : |
if includes OPT_O, use Bartlett lag window for periodogram;
if includes OPT_N, don't display gnuplot graph; 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. |
Summary* summary (const int *list, const double **Z, const DATAINFO *pdinfo, PRN *prn);
Calculates descriptive summary statistics for the specified variables.
list : |
list of variables to process. |
Z : |
data matrix. |
pdinfo : |
information on the data set. |
prn : |
gretl printing struct. |
| Returns : | struct containing the summary statistics. |
void print_summary (const Summary *summ, const DATAINFO *pdinfo, PRN *prn);
Prints the summary statistics for a given variable.
summ : |
gretl summary statistics struct. |
pdinfo : |
information on the data set. |
prn : |
gretl printing struct. |
void free_summary (Summary *summ);
Frees all malloced elements of the struct.
summ : |
gretl summary statistics struct |
VMatrix* corrlist (int *list, const double **Z, const DATAINFO *pdinfo, gretlopt opt, int *err);
Computes pairwise correlation coefficients for the variables
specified in list, skipping any constants.
list : |
list of variables to process, by ID number. |
Z : |
data matrix. |
pdinfo : |
data information struct. |
opt : |
option flags. |
err : |
location to receive error code. |
| Returns : | gretl correlation matrix struct, or NULL on failure.
|
VMatrix* vmatrix_new (void);
| Returns : | an allocated and initialized VMatrix, or
NULL on failure.
|
void free_vmatrix (VMatrix *vmat);
Frees all malloced elements of the struct.
vmat : |
gretl correlation matrix struct |
int gretl_corrmx (int *list,
const double **Z,
const DATAINFO *pdinfo,
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. |
Z : |
data array. |
pdinfo : |
data information struct. |
opt : |
option flags: OPT_U = use uniform sample size.
|
prn : |
gretl printing struct. |
| Returns : | 0 on successful completion, 1 on error. |
int means_test (const int *list,
const double **Z,
const DATAINFO *pdinfo,
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. |
Z : |
data matrix. |
pdinfo : |
data information struct. |
opt : |
if OPT_O, assume population variances are different. |
prn : |
gretl printing struct. |
| Returns : | 0 on successful completion, error code on error. |
int vars_test (const int *list,
const double **Z,
const DATAINFO *pdinfo,
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. |
Z : |
data matrix. |
pdinfo : |
data information struct. |
prn : |
gretl printing struct. |
| Returns : | 0 on successful completion, error code on error. |
void print_corrmat (VMatrix *corr, const DATAINFO *pdinfo, PRN *prn);
Prints a gretl correlation matrix to prn.
corr : |
gretl correlation matrix. |
pdinfo : |
dataset information. |
prn : |
gretl printing struct. |
double dh_root_b1_to_z1 (double rb1,
double n);
Performs the transformation from skewness, root b1, to the normal score, z1, as set out in Doornik and Hansen, "An Omnibus Test for Normality", 1994. The transformation is originally due to D'Agostino (Biometrika, 1970).
rb1 : |
square root b1, skewness. |
n : |
number of observations. |
| Returns : | the z1 value. |
double dh_b2_to_z2 (double b1,
double b2,
double n);
Performs the transformation from kurtosis, b2, to the normal score, z2, as set out in Doornik and Hansen, "An Omnibus Test for Normality", 1994.
b1 : |
skewness. |
b2 : |
kurtosis. |
n : |
number of observations. |
| Returns : | the z2 value, or NADBL on failure. |
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. |
int gretl_system_normality_test (const gretl_matrix *E, const gretl_matrix *Sigma, PRN *prn);
E : |
|
Sigma : |
|
prn : |
|
| Returns : |
int mahalanobis_distance (const int *list,
double ***pZ,
DATAINFO *pdinfo,
gretlopt opt,
PRN *prn);
list : |
|
pZ : |
|
pdinfo : |
|
opt : |
|
prn : |
|
| Returns : |
MahalDist* get_mahal_distances (const int *list, double ***pZ, DATAINFO *pdinfo, gretlopt opt, PRN *prn);
list : |
|
pZ : |
|
pdinfo : |
|
opt : |
|
prn : |
|
| Returns : |
const double* mahal_dist_get_distances (const MahalDist *md);
md : |
|
| Returns : |
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.
|
int gini (int vnum,
const double **Z,
DATAINFO *pdinfo,
gretlopt opt,
PRN *prn);
Graphs the Lorenz curve for variable vnum and prints the
Gini coefficient.
vnum : |
ID number of variable to examine. |
Z : |
data array |
pdinfo : |
data information struct. |
opt : |
not used yet. |
prn : |
gretl printing struct. |
| Returns : | 0 on successful completion, error code on error. |
| << Descriptive statistics and tests | compare >> |