On Sat, 2 Jun 2012, Evan Miller wrote:
I am using libgretl in a C program and wish to perform an IV
regression via GMM. Here is the relevant code:
DATASET *data_set = create_new_dataset(nvar, nobs, 0);
for (i=0; i<nvar; i++) {
for (j=0; j<nobs; j++) {
dset_set_data(data_set, i, j, x[i*nobs+j]);
}
}
... create list using -100 as a separator ...
Best to use the LISTSEP macro.
MODEL model_results = ivreg(list, data_set, OPT_G);
When I first tried it, I got this error:
realgen: exiting on expr() error 19
genr_compile: genrs[0] = 0x0, err = 19
formula: 'gmm___e = const-(b0+b1*+b2*+b3*+b4*+b5*+b6*+b7*+b8*+b9*)'
nls_genr_setup failed
Apparently variables without names were a big no-no,
In the context of GMM or NLS, yes, we need the names.
so I named the variables in my data set by writing to
data_set->varnames. Now I get this error:
realgen: exiting on lex() error 15
genr_compile: genrs[0] = 0x0, err = 15
formula: 'gmm___e =
var0-(b0+b1*var5+b2*var6+b3*var7+b4*var8+b5*var9+b6*var10+b7*var11+b8*var12+b9*var13)'
The symbol 'var0' is undefined
nls_genr_setup failed
What am I doing wrong? I am using libgretl 1.9.8 on a Mac.
The series in position 0 in the dataset is "reserved". It is
automatically filled with 1s and named "const"; if you give it any
other content or rename it this will cause trouble.
Allin Cottrell