On Tue, 14 Jul 2009, Riccardo (Jack) Lucchetti wrote:
I just tried the new Rlib thing on one of Lee Adkins'
(
http://www.learneconometrics.com/gretl/ebook.pdf) examples;
attached you'll find a simple script and the dataset to
replicate Lee's section 16.9.2 (coditional logit). A couple of
things that need to be fixed appeared when you use the new
mechanism:
1) If you run the script through the GUI client, the output of
the R foreign block isn't included in the output window; the cli
client is ok.
When we run the R binary, we do so using glib's "spawn" mechanism,
which attaches pipes to the called program's standard output and
error output so that we can capture these in files and send them
where we wish. I have not figured out how we can do the
equivalent when calling libR. Sane libraries offer a reasonably
simple way of redirecting printed output, sometimes by passing a
printing-function pointer. I can't find this in libR. but maybe
that's my failing.
2) More worryingly, it seems that the R computations are done
_twice_. If you run the script with Rlib on, you'll see the
output...
Yes, granted. I've put a bunch of debugging statements,
conditional on FDEBUG, into gretl_foreign.c, talking to stdout so
we can compare the sequence of events with gretl and libR's
stdout. So it seems that as soon as we call R(f)_initEmbeddedR
our current R command-set starts executing, and the subsequent
call to lib_run_Rlib_sync() is redundant -- see the sequence in
foreign_execute().
This may be fairly easy to fix -- or not. (Do we just have to
skip the first command?) Another clue may be in the argv passed
to R_initEmbeddedR. Varying the elements in that array can cause
things to break or behave oddly, or anyway differently. And in
different ways depending on whether we're starting gretl from a
shell prompt or launching it from a GUI icon, note.
One thing to watch out for, in varying anything in the libR calls,
is the condition where "gretl.export" (defined in our
gretl.Rprofile) is not found. I've run into that a bunch of
times.
I have to say that, compared to using all the other libraries
we've encountered with gretl, using libR is a rather frustrating
guessing-game.
Allin.