Top |
enum | DatasetMarkerType |
enum | VarFlags |
enum | DatasetOp |
enum | DataCopyFlag |
enum | CompactMethod |
typedef | series_table |
#define dataset_is_cross_section(p) (p != NULL && p->structure == CROSS_SECTION)
Attempt to determine whether a dataset contains cross-sectional data (1) or not (0).
#define dataset_is_time_series(p)
Attempt to determine whether a dataset contains time series data (1) or not (0).
#define dataset_is_seasonal(p)
Attempt to determine whether a dataset contains seasonal time series data (1) or not (0).
#define custom_time_series(p) (p != NULL && p->structure == SPECIAL_TIME_SERIES)
Attempt to determine whether a dataset contains time series data with custom (non-standard) frequency (1) or not (0).
#define dataset_is_daily(p)
Attempt to determine whether a dataset contains daily time series data (1) or not (0).
#define dataset_is_incomplete_daily(p)
Attempt to determine whether a dataset contains daily on an incomplete calendar (1) or not (0).
#define dataset_is_weekly(p)
Attempt to determine whether a dataset contains weekly time series data (1) or not (0).
#define dataset_is_hourly(p)
Attempt to determine whether a dataset contains hourly time series data (1) or not (0).
#define dataset_is_decennial(p)
Attempt to determine whether a dataset contains decennial time series data (1) or not (0).
#define dated_daily_data(p)
Attempt to determine whether a dataset contains dated daily time series data (1) or not (0).
#define dated_seven_day_data(p)
Attempt to determine whether a dataset contains dated daily (seven-day) time series data (1) or not (0).
#define dated_weekly_data(p)
Attempt to determine whether a dataset contains dated weekly time series data (1) or not (0).
#define calendar_data(p)
Attempt to determine whether a dataset uses calendar dates for observation strings (1) or not (0).
#define quarterly_or_monthly(p)
Attempt to determine whether a dataset is a quarterly or monthly time series (1), or something else (0).
#define annual_data(p)
Attempt to determine whether a dataset is an annual time series (1), or something else (0).
#define decennial_data(p)
Attempt to determine whether a dataset is a decemmial time series (1), or something else (0).
#define dataset_is_panel(p) (p != NULL && p->structure == STACKED_TIME_SERIES)
Attempt to determine whether a dataset contains panel data (1) or not (0).
#define dataset_is_seasonal_panel(p)
Attempt to determine whether a dataset contains panel data with a seasonal time-series dimension (1) or not (0).
#define dataset_has_markers(p) (p != NULL && p->markers && p->S != NULL)
Determine whether a dataset has observation marker strings (1) or not (0).
#define dataset_has_panel_time(p)
Determine whether a panel dataset has information on its time dimension recorded (1) or not (0).
#define sample_size(p) ((p == NULL)? 0 : (p->t2 - p->t1 + 1))
Retrieves the length of the current sample range.
#define dset_get_data(d,i,t) (d->Z[i][t])
Gets the value of series i
at observation t
.
#define dset_set_data(d,i,t,x) (d->Z[i][t]=x)
Sets the value of series i
at observation t
.
DATASET *
datainfo_new (void
);
Creates a new data information struct pointer from scratch, properly initialized as empty (no variables, no observations).
void
datainfo_init (DATASET *dset
);
Zeros all members of dset
and sets it as a plain cross-section.
Designed for use with a DATASET structure that has not been
obtained via datainfo_new()
.
DATASET * create_new_dataset (int nvar
,int nobs
,int markers
);
Allocates space in the dataset to hold the specified number of variables and observations.
void clear_datainfo (DATASET *dset
,int code
);
Frees the allocated content of a data information struct;
note that dset
itself is not freed.
int allocate_Z (DATASET *dset
,gretlopt opt
);
Allocates the two-dimensional data array Z,
based on the v (number of variables) and n (number of
observations) members of dset
. The variable at
position 0 is initialized to all 1s; other variables
are initialized to NADBL (unless OPT_B is given).
int
dataset_allocate_varnames (DATASET *dset
);
Given a blank dset
, which should have been obtained using
datainfo_new()
, allocate space for the names of variables.
The v
member of dset
(representing the number of variables,
including the automatically added constant at position 0) must be
set before calling this function.
int
dataset_allocate_obs_markers (DATASET *dset
);
Allocates space in dset
for strings indentifying the
observations and initializes all of the markers to empty
strings. Note that These strings have a fixed maximum
length of OBSLEN - 1.
void
dataset_destroy_obs_markers (DATASET *dset
);
Frees any allocated observation markers for dset
.
void
dataset_obs_info_default (DATASET *dset
);
Sets the "date" or observations information in dset
to a
simple default of cross-sectional data, observations 1 to n,
where n is the n
element (number of observations) in dset
.
void copy_dataset_obs_info (DATASET *targ
,const DATASET *src
);
Sets the "date" or observations information in targ
to that
found in src
.
void copy_varinfo (VARINFO *targ
,const VARINFO *src
);
Copies relevant information from src
to targ
.
int start_new_Z (DATASET *dset
,gretlopt opt
);
Initializes the data array within dset
(adding the constant in
position 0).
int dataset_add_observations (DATASET *dset
,int n
,gretlopt opt
);
Extends all series in the dataset by the specified number of extra observations. The added values are initialized to the missing value code, NADBL, with the exception of simple deterministic variables when OPT_A is given.
dset |
pointer to dataset. |
|
n |
number of observations to add. |
|
opt |
use OPT_A to attempt to recognize and automatically extend simple deterministic variables such as a time trend and periodic dummy variables; use OPT_D to drop any observation markers rather than expanding the set of markers and padding it out with dummy values; use OPT_T to extend in the time dimension in the case of panel data. |
int dataset_drop_observations (DATASET *dset
,int n
);
Deletes n
observations from the end of each series in the
dataset.
int
dataset_shrink_obs_range (DATASET *dset
);
Truncates the range of observations in the dataset, based on
the current values of the t1 and t2 members of dset
.
int dataset_add_series (DATASET *dset
,int newvars
);
Adds space for the specified number of additional series in the dataset. Values are initialized to zero.
int dataset_add_NA_series (DATASET *dset
,int newvars
);
Adds space for the specified number of additional series in the dataset. Values are initialized to NA.
int dataset_add_allocated_series (DATASET *dset
,double *x
);
Adds x
as an additional series in the dataset.
The array x
is not copied; it should be treated as
belonging to dset
after this operation.
int dataset_add_series_as (DATASET *dset
,double *x
,const char *name
);
Adds to the dataset a new series with name name
and
values given by x
. The new variable is added at one
level "deeper" (in terms of function execution) than the
current level. This is for use with user-defined functions.
int dataset_copy_series_as (DATASET *dset
,int v
,const char *name
);
Makes a copy of series v
under the name name
.
The copy exists in a variable namespace one level "deeper"
(in terms of function execution) than the variable being copied.
This is for use with user-defined functions: a variable
supplied to a function as an argument is copied into the
function's namespace under the name it was given as a
parameter.
int dataset_replace_series (DATASET *dset
,int v
,double *x
,const char *descrip
,DataCopyFlag flag
);
Replaces the description and numerical content of
series v
with the information provided.
int dataset_replace_series_data (DATASET *dset
,int v
,const double *x
,int t1
,int t2
,const char *descrip
);
Replaces the description and numerical content of
series v
over the given sample range, with the
information provided.
int dataset_rename_series (DATASET *dset
,int v
,const char *name
);
int dataset_drop_listed_variables (int *list
,DATASET *dset
,int *renumber
,PRN *prn
);
Deletes the series given in list
from the dataset. Remaining
series may have their ID numbers changed as a consequence. If
renumber
is not NULL, this location receives 1 in case series
have been renumbered, 0 otherwise.
int dataset_drop_variable (int v
,DATASET *dset
);
Deletes variable v
from the dataset.
int dataset_destroy_hidden_variables (DATASET *dset
,int vmin
);
Deletes from the dataset any "hidden" variables that have
been added automatically (for example, auto-generated variables
used for the x-axis in graph plotting), and that have ID
numbers greater than or equal to vmin
. Never deletes the
automatically generated constant (ID number 0).
int dataset_drop_last_variables (DATASET *dset
,int delvars
);
Deletes from the dataset the number delvars
of variables
that were added most recently (that have the highest ID numbers).
int dataset_renumber_variable (int v_old
,int v_new
,DATASET *dset
);
Moves the variable that was originally at position v_old
in the datset to position v_new
, renumbering other
variables as required.
int renumber_series_with_checks (const int *list
,const char *param
,int fixmax
,DATASET *dset
,PRN *prn
);
int build_stacked_series (double **pstack
,int *list
,int length
,int offset
,DATASET *dset
);
Really for internal use. Don't worry about it.
int series_is_log (const DATASET *dset
,int i
,char *parent
);
Tries to determine if the variable with ID number i
is
the logarithm of some other variable.
void series_set_discrete (DATASET *dset
,int i
,int s
);
Mark a variable as being discrete or not.
int modify_dataset (DATASET *dset
,int op
,const int *list
,const char *s
,gretlopt opt
,PRN *prn
);
int
dataset_purge_missing_rows (DATASET *dset
);
Removes empty rows from the dataset -- that is, observations at which there are no non-missing values. This is intended for dated daily data only.
void set_dataset_is_changed (DATASET *dset
,int s
);
Sets the internal boolean "changed" flag to s
.
int dataset_set_time_series (DATASET *dset
,int pd
,int yr0
,int minor0
);
Sets time-series properties on dset
: frequency pd
with
starting observation yr0
, minor0
. If the data are
annual (pd
= 1) then minor0
is ignored.
int series_is_listarg (const DATASET *dset
,int i
,const char **lname
);
void series_set_flag (DATASET *dset
,int i
,VarFlags flag
);
Sets the given flag
on series i
.
void series_unset_flag (DATASET *dset
,int i
,VarFlags flag
);
Unsets the given flag
on series i
.
void series_attach_string_table (DATASET *dset
,int i
,series_table *st
);
const char * series_get_string_for_obs (const DATASET *dset
,int i
,int t
);
const char * series_get_string_for_value (const DATASET *dset
,int i
,double val
);
int series_set_string_val (DATASET *dset
,int i
,int t
,const char *s
);
Attempts to set the string value for observation t
of series i
to s
. This will fail if the series in question does not have
an associated table of string values.
int string_series_assign_value (DATASET *dset
,int i
,int t
,double x
);
Attempts to set the value for observation t
of series i
to x
. This will fail if the x
falls outside of the range
of values supported by the string table for the series.
int series_set_string_vals_direct (DATASET *dset
,int i
,char **S
,int ns
);
int series_recode_strings (DATASET *dset
,int v
,gretlopt opt
,int *changed
);
This function "trims" the array of string values associated
with series v
so that it contains no redundant elements --
that is, values of which there is no instance in the
current sample -- and resets the numeric codes for the
strings if necessary.
By default the original "series_table" attached to series v
is destroyed, but if opt
contains OPT_P it is replaced but
not freed; this make sense only if another pointer to the
original table exists.
If it happens that the current sample contains
instances of all the strings in the full dataset, this
function will not actually make any changes to dset
. The
changed
argument provides a means of determining
whether any change has been made.
double series_decode_string (const DATASET *dset
,int i
,const char *s
);
the numerical value associated with the string
s
for series i
, or NADBL if there's no such value.
char ** series_get_string_vals (const DATASET *dset
,int i
,int *n_strs
,int subsample
);
int steal_string_table (DATASET *l_dset
,int lvar
,DATASET *r_dset
,int rvar
);
Detaches the string table from rvar
in r_dset
and attaches it
to lvar
in l_dset
,
int merge_string_tables (DATASET *l_dset
,int lvar
,DATASET *r_dset
,int rvar
);
Translates the encoding of the string-values of series rvar
in r_dset
to that of series lvar
in l_dset
, adding extra
strings as needed.
series_table * get_panel_group_table (const DATASET *dset
,int maxlen
,int *pv
);
gretl_matrix * list_info_matrix (const int *list
,const DATASET *dset
,gretlopt opt
,int *err
);
Symbolic codes for various methods of compacting data
series (i.e. converting from a higher to a lower
frequency). COMPACT_WDAY
is applicable only when
converting from daily to weekly frequency.