[Gretl-devel] libgretl arma

Allin Cottrell cottrell at wfu.edu
Wed Feb 8 09:27:14 EST 2012


On Wed, 8 Feb 2012, Emrah Samdan wrote:

> I am a newbie for this mail list. Sorry, if i ask something not suitable.
> I have been trying to use libgretl api to make estimations using arma
> models, I have made the libgretl read my datafile. However, when i call
> arma function like this:
> ArmaModel = arma(list,NULL,dset,OPT_N,prn) ; it gives the error arma.so:
> cannot open shared object file: No such file or directory.
> I have execute sudo ldconfig /usr/local/lib/gretl-gtk2/ to add arma.so .But
> it didn't fix my problem.
>
> Do you have any solution to this ?

See 
http://gretl.sourceforge.net/API/new/gretl/gretl-Plugins.html

You should do:

gretl_setenv("GRETL_PLUGIN_PATH", "/usr/local/lib/gretl-gtk2/");

to tell libgretl where to find the plugins.

> Additionally, is there any place where some example code resides. I
> desperately need some example code for especially arma model. ?

I'm attaching a simple example.

Allin Cottrell
-------------- next part --------------
#include <gretl/libgretl.h>

int arma_estimate (DATASET *dset, PRN *prn)
{
    MODEL *model;
    int *list;
    int err;

    model = gretl_model_new();
    list = gretl_list_new(5);

    list[1] = 1;        /* AR order */
    list[2] = 0;        /* order of integration */
    list[3] = 1;        /* MA order */
    list[4] = LISTSEP;  /* separator */
    list[5] = 1;        /* position of dependent variable in dataset */

    *model = arma(list, NULL, dset, OPT_NONE, prn);
    err = model->errcode;

    if (!err) {
	printmodel(model, dset, OPT_NONE, prn);
    }

    gretl_model_free(model);
    free(list);

    return err;
}

int main (void)
{
    DATASET *dset;
    PRN *prn;
    int err;

    libgretl_init();
    gretl_setenv("GRETL_PLUGIN_PATH", "/usr/local/lib/gretl-gtk2/");

    dset = datainfo_new();
    prn = gretl_print_new(GRETL_PRINT_STDOUT, NULL);

    err = gretl_read_native_data("data9-7.gdt", dset);

    if (err) {
	exit(EXIT_FAILURE);
    }

    err = arma_estimate(dset, prn);
    
    destroy_dataset(dset);
    gretl_print_destroy(prn);

    libgretl_cleanup();

    return 0;
}


More information about the Gretl-devel mailing list