[Gretl-devel] Gretl and R integration
Allin Cottrell
cottrell at wfu.edu
Sat May 24 21:40:01 EDT 2008
On Sat, 24 May 2008, Allin Cottrell wrote:
> BTW, please watch out for some changes in CVS: I'm moving the
> R-file writing apparatus from gui_utils.c to a new file,
> lib/src/foreign.c, so as to support command-line invocation of
> chunks of external script, as per Ignacio's suggestion.
E.g., based on the example in the manual:
<script>
open bjg.gdt
foreign language=R
# extract the log series
y <- gretldata[, "lg"]
# estimate the model
strmod <- StructTS(y)
# save the fitted components
compon <- as.ts(strmod$fitted)
# save the estimated variances
vars <- as.matrix(strmod$coef)
# export into gretl's temp dir
gretl.export(compon)
gretl.export(vars)
end foreign
append @dotdir/compon.csv
vars = mread("@dotdir/vars.mat")
print vars
</script>
This works in CVS. I'll do some proper testing tomorrow.
("foreign language=ox" should be a possibility too, but it's not
ready yet.)
Allin.
More information about the Gretl-devel
mailing list