Hello Allin,
I found my bug, if m_datainfo->varname[2] is not set, it give back the
same list at laglist2.
example
replace in your example:
strcpy(m_datainfo->varname[1], "y1");
strcpy(m_datainfo->varname[2], "y2");
by
strcpy(m_datainfo->varname[0], "y1");
strcpy(m_datainfo->varname[1], "y2");
and you'll get my problem.
I'm not sure it's a bug, but it's a big trap.
thanks
2010/5/5 Allin Cottrell <cottrell(a)wfu.edu>:
On Wed, 5 May 2010, denis joubert wrote:
> I think there is a bug into laggenr_from_to or i don't know to use it.
> when you call it twice on 2 different id of variable(already stored
> into Z), it does restart the position of the returned list.
> For example :
> listlag1 = laggenr_from_to(1, 1, 50, &m_Z, m_datainfo, &err);
> listlag2 = laggenr_from_to(2, 1, 50, &m_Z, m_datainfo, &err);
> return the same numbers into listlag1 and listlag2.
You will have to show me a small but complete program that
produces unexpected results to make me believe there is a bug. The
following program produces two distinct lists: 3 lags of the first
variable, then 3 lags of the second.
#include <gretl/libgretl.h>
int main (void)
{
DATAINFO *m_datainfo;
double **m_Z;
int *laglist1, *laglist2;
PRN *prn;
int err = 0;
libgretl_init();
prn = gretl_print_new(GRETL_PRINT_STDOUT, NULL);
m_datainfo = create_new_dataset(&m_Z, 3, 10, 0);
strcpy(m_datainfo->varname[1], "y1");
strcpy(m_datainfo->varname[2], "y2");
m_Z[1][0] = 1431225;
m_Z[1][1] = 207958;
m_Z[1][2] = 1328798;
m_Z[1][3] = 1412733;
m_Z[1][4] = 1766147;
m_Z[1][5] = 1635199;
m_Z[1][6] = 1565249;
m_Z[1][7] = 949787;
m_Z[1][8] = 1130386;
m_Z[1][9] = 834164;
m_Z[2][0] = 2080654;
m_Z[2][1] = 1153485;
m_Z[2][2] = 857538;
m_Z[2][3] = 1363286;
m_Z[2][4] = 2051956;
m_Z[2][5] = 660288;
m_Z[2][6] = 664975;
m_Z[2][7] = 1831966;
m_Z[2][8] = 1516991;
m_Z[2][9] = 1284537;
laglist1 = laggenr_from_to(1, 1, 3, &m_Z, m_datainfo, &err);
laglist2 = laggenr_from_to(2, 1, 3, &m_Z, m_datainfo, &err);
printlist(laglist1, "list of lags for var 1");
printlist(laglist2, "list of lags for var 2");
free(laglist1);
free(laglist2);
destroy_dataset(m_Z, m_datainfo);
gretl_print_destroy(prn);
libgretl_cleanup();
return 0;
}
Allin Cottrell
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users