gretlR Package: Integration of R and gretl

Sagiru Mati (PhD)

About gretlR

gretlR is an R package that can run gretl program from R Markdown.


gretlR can be installed using the following commands in R.





Please load the gretlR package as follows:

```{r gretlR}                                                             

Then create a chunk for gretl as shown below:

```{gretl gretlR1,eval=T,echo=T,comment=NULL} 
nulldata 500
set seed 13
gretl1 = normal()
gretl2 = normal()
setobs 12 1980:01 --time-series
gnuplot gretl1 --time-series --with-lines --output="line.png"
gnuplot gretl2 gretl1 --output="scatter.png"
ols gretl1 const gretl2
modeltab add
tabprint --output="ols.Rmd"
eqnprint --output="olsmodel.Rmd"
tabprint --output="ols.csv"

The above chunk creates an gretl program with the chunk’s content, then automatically gretl, which will save gretl outputs in the current directory.

We can dynamically and reproducibly fetch the gretl graph object we created with the gretl chunk using the following R chunk:

For the scatter graph:

Scatter graph produced by gretl chunk

Scatter graph produced by gretl chunk

or the line graph:

Line graph produced by gretl chunk

Line graph produced by gretl chunk

we can also include the equation of the OLS generated by the gretl chunk using the following R chunk;

Remember the OLS equation output is saved by the gretl chunk as olsmodel.Rmd. The entire OLS equation model:

```{r child, child='olsmodel.Rmd'}


%%% the following needs the amsmath LaTeX package

Remember the OLS table output is saved by gretl chunk as ols.Rmd. The entire OLS table output:

```{r child1, child="ols.Rmd"}


Unfortunately, user of gretl has little or no control over the outputs customisation before exporting.

Please visit my Github for a better explanation and example files.

Try the gretlR package in your browser

Any scripts or data that you put into this service are public.

gretlR documentation built on July 2, 2020, 3:21 a.m.