On Sat, 29 Mar 2014, GOO Creations wrote:
Thanks for the example program. I've fixed the reference errors
(have send an
email 5min ago).
On a different note. I'm new to gretl and still struggeling to figure out how
to work with DATASET. I have a double array with my time series samples. I
want to create a DATASET directly from this array (without reading it from
file or DB). This is what I've done:
int length = 8;
double d[] = {0.1, 0.2, 0.3, 0.2, 0.1, 0.3, 0.4, 0.6};
DATASET *data = create_new_dataset(length, 1, 0);
dataset_add_series_as(data, d, "data");
Is this the correct way of doing it?
Close but not quite. Instead of using dataset_add_series_as(), which is
intended for internal use and will not do what you want, you can do
dataset_add_series(data, 1);
int t, newvar = data->v - 1;
for (t=0; t<length; t++) {
data->Z[newvar][t] = d[t];
}
strcpy(data->varname[newvar], "data");
It is also possible to use dataset_add_allocated_series(), in which case
you don't have to copy the values across, but this requires that the array
passed in has been obtained via malloc, and the dataset struct takes
ownership of it.
Allin Cottrell