Top |
void
libgretl_init (void
);
In a program that uses libgretl, this function should be
called once, before any other libgretl functions are
used. See also libgretl_cleanup()
, and libgretl_mpi_init()
.
int libgretl_mpi_init (int self
,int np
,int dcmt
);
This function provides an alternative to libgretl_init()
which should be used when a libgretl program is to be run in
MPI mode.
void
libgretl_cleanup (void
);
In a program that uses libgretl, this function may be called to free various chunks of memory after the program is finished with libgretl. Do not attempt to call any other libgretl functions after invoking this cleanup.
See also libgretl_init()
.
double date_as_double (int t
,int pd
,double sd0
);
int gretl_isdummy (int t1
,int t2
,const double *x
);
Check whether series x
has only 0 or 1 values over the
given sample range (or possibly missing values).
int gretl_iszero (int t1
,int t2
,const double *x
);
Check whether series x
has only zero (or missing) values
over the given sample range.
int gretl_isconst (int t1
,int t2
,const double *x
);
Check whether series x
is constant over the
given sample range (aside from any missing values).
int gretl_isstoch (int t1
,int t2
,const double *x
);
Check whether series x
is stochastic, and contains a
contiguous set of valid values within the given sample span.
The simple and fallible heuristic for a stochastic series is
that the differences between successive values are all the
same.
int gretl_isunits (int t1
,int t2
,const double *x
);
Check whether series x
equals 1 over the
given sample range (aside from any missing values).
int gretl_iscount (int t1
,int t2
,const double *x
);
Check whether series x
contains nothing but non-negative
integer values (some of which are > 1) over the
given sample range.
int gretl_isdiscrete (int t1
,int t2
,const double *x
);
Checks the variable x
over the range t1
to t2
for discreteness.
This is a heuristic whose components are (a) whether the values
are "fairly round" (multiples of 0.25) or not, and, if test (a) is
passed, (b) whether the variable takes on only "few" distinct
values.
0 if test (a) is not passed or the number of distinct values
is > 32; else 1 if the number of distinct values is <= 32; else 2 if
the number of distinct values is <= 8. A return of 1 is supposed
to indicate that it's "reasonable" to treat x
as discrete, while
a return of 2 indicates that it's probably unreasonable _not_ to
treat x
as discrete for the purpose of drawing up a frequency
distribution.
int gretl_ispositive (int t1
,int t2
,const double *x
,int strict
);
int gretl_is_oprobit_ok (int t1
,int t2
,const double *x
);
Checks the variable x
over the range t1
to t2
for its
suitability as the dependent variable in an ordered probit
analysis. The criterion used is that the variable has
only non-negative integer values.
int true_const (int v
,const DATASET *dset
);
Check whether variable Z[v] equals 1 over the sample
range given in dset
(aside from any missing values).
char * format_obs (char *obs
,int maj
,int min
,int pd
);
Prints to obs
the gretl-type date string representing
the observation given by maj
, min
and pd
.
obs |
target string (should be of length OBSLEN). |
|
maj |
major period (e.g. year). |
|
min |
minor period (e.g. quarter, month). |
|
pd |
data frequency. |
int set_obs (const char *parm1
,const char *parm2
,DATASET *dset
,gretlopt opt
);
Set the frequency and initial observation for a dataset, or in the case of a panel dataset, extra group or time information.
parm1 |
first parameter. |
|
parm2 |
second parameter. |
|
dset |
dataset struct. |
|
opt |
|
int simple_set_obs (DATASET *dset
,int pd
,const char *stobs
,gretlopt opt
);
See the "setobs" command.
int gretl_compare_doubles (const void *a
,const void *b
);
Comparison function for use with qsort. Sorts doubles in ascending order.
int gretl_inverse_compare_doubles (const void *a
,const void *b
);
Comparison function for use with qsort. Sorts doubles in descending order.
int rearrange_id_array (double *x
,int m
,int n
);
Rearranges the sorted array x
such that the first m
elements contain the m
distinct values in sorted order.
int gretl_compare_ints (const void *a
,const void *b
);
Comparison function for use with qsort. Sorts integers in ascending order.
void printlist (const int *list
,const char *msg
);
Prints to stderr the given list
of integers along with a message.
double gretl_double_from_string (const char *s
,int *err
);
If s
is a valid string representation of a double,
return its value, otherwise if s
is the name of a
scalar variable, return the value of that variable,
otherwise set the content of err
to a non-zero value.
int gretl_int_from_string (const char *s
,int *err
);
If s
is a valid string representation of an integer,
return that integer, otherwise if s
is the name of a
scalar variable, return the value of that variable,
provided it can be converted to an integer, otherwise
set the content of err
to a non-zero value.
int
positive_int_from_string (const char *s
);
If s
is a valid string representation of a positive integer,
return that integer, otherwise return -1.
void doubles_array_free (double **X
,int m
);
Frees a 2-dimensional array of doubles, first freeing each sub-array.
double ** doubles_array_new (int m
,int n
);
Allocates a 2-dimensional array of doubles, that is,
m
arrays each containing n
elements. If n
is
zero the sub-arrays are just set to NULL
.
double ** doubles_array_new0 (int m
,int n
);
Works just as doubles_array_new()
, except that on
successful allocation all values in the arrays are
set to zero.
int doubles_array_adjust_length (double **X
,int m
,int new_n
);
For each of the m
sub-arrays in X
, reallocate to
a length of new_n
.
double ** data_array_from_model (const MODEL *pmod
,double **Z
,int missv
);
Constructs a dataset containing all the variables referenced in
pmod
. The arrays start at the correct sample offset for pmod
,
and are contiguous. If missvals
equals 0, this is done by creating
a set of pointers into the main dataset, but if there are missing
values to be handled, the sub-arrays are newly allocated and purged
of NAs.
int ijton (int i
,int j
,int nrows
);
Given a (row, column) reference into a symmetric 2-dimensional matrix A, finds the index into a 1-dimensional array x composed of the non-redundant (lower) elements of A.
E.g. for the 3 x 3 case with 6 non-redundant elements, 0 to 5,
A(0,0) = x[0] A(0,1) = x[1] A(0,2) = x[2] A(1,0) = x[1] A(1,1) = x[3] A(1,2) = x[4] A(2,0) = x[2] A(2,1) = x[4] A(2,1) = x[5]
int transcribe_array (double *targ
,const double *src
,const DATASET *dset
);
Copy from src
to targ
, skipping any missing values,
over the sample range defined in dset
.
int gretl_pipe_output (gchar **argv
,gchar **envp
,const char *currdir
,PRN *prn
,gchar **errp
);
int gretl_calculate_criteria (double ess
,int n
,int k
,double *ll
,double *aic
,double *bic
,double *hqc
);
Calculates model selection criteria based on ess
, nobs
and
k
, for a model estimated via least squares.
int
ls_criteria (MODEL *pmod
);
Fills out the model selection criteria members of pmod
, using
gretl_calculate_criteria()
.
void record_matrix_test_result (gretl_matrix *tests
,gretl_matrix *pvals
);