Thanks for this, extremely helpful. I am getting this to work with lsq first and then
I'll tackle arma.
I am approaching the library in this way as I need to run estimation on a window of data,
and then increment forward throughout a time series period, with a moving window. So, for
each period t, I need to estmate the residuals from the previous X days, based on a
regression from the same previous x days. On day t+1 is another regression, etc.
If you have a preferred way for me to do this, certainly let me know. Perhaps I should
look into writing scripts and using issuing gretlcli commands, as it's a batch-like
process.
I have it all working with OLS at the moment, I can get residuals and it matches gretl.
The only thing missing is the coefficients of the constant and independent variable.
Having a working OLS model, these are the additional pieces I added (same result using
matrix):
gretl_vector *coeff=NULL; // same results using gretl_matrix
/ * model runs */
coeff = gretl_model_get_matrix(model, M_COEFF, errcode)
The function returns NULL, unfortunately, with a very large error code. Is a specific
option required to get this matrix return? The scalar M_NCOEFF returns 2 as expected.
This is hopefully the last thing I need. Thanks!
Joel
--Forwarded Message Attachment--
From: cottrell(a)wfu.edu
To: gretl-users(a)lists.wfu.edu
Date: Sat, 3 Jul 2010 13:48:49 -0400
Subject: Re: [Gretl-users] Using Gretl API for C++ Program
On Wed, 30 Jun 2010, Joel Bycraft wrote:
Is there documentation on the defintion of the 'list'
integers?
Sorry this has taken a while.
For general information on how gretl "lists" work see the "Lists"
sub-section of the libgretl API docs (under the "Utilities"
heading). Note that I've done quite a bit of work on these docs
lately, though they're still very much incomplete and are unlikely
to be completed any time soon.
http://gretl.sourceforge.net/API/
I see the example for the OLS, however I am looking to use ARMA.
It list: dependent variable, AR and MA orders, and any exogenous
regressors. However, I don't see the specific integer values to
use?
You should refer to the help entry for the "arima" command in
gretl to understand this. The specification of the arma list is
given in detail there. (In general, where the API docs are obscure
on a given function, and that function directly implements a gretl
command, that's what you'll have to do.)
Although there are other ways of doing this, for the present
you're probably best constructing the list argument for arma by
composing a string as per the help on arima, then calling
gretl_list_from_string to convert it to an actual "list".
For example:
<C-code>
const char *arma_spec = "1 2 ; 5";
int err = 0;
int *list = gretl_list_from_string(arma_spec, &err);
/* if err == 0, use the list ... */
free(list); /* once you're finished with it */
</C-code>
In this example the AR order is 1, the MA order is 2, and
the dependent variable is at position 5 in the "Z" data array.
To add seasonal terms, again look at the "arima" help.
also the data array for arma() is const double, why is that
different from say lsq()? How would I go about using this
function properly?
The assumption in libgretl is that a two-dimensional data array Z
(of type double **) lives somewhere in the calling program. With
some libgretl functions it is sufficient to pass Z as an argument
result = some_gretl_func(..., Z, ...);
but with others you must pass its address:
result = some_other_func(..., &Z, ...);
The functions that require the address of Z are ones that may
resize the Z array under some conditions: lsq is one such (it may
add auxiliary series to the data array temporarily). The arma
function, on the other hand, never resizes Z so it doesn't require
the address.
Note that whenever you see "***pZ" as a libgretl function
parameter, the corresponding argument should be "&Z". (Well,of
course you can call "Z" anything you like in your own program.)
Just out of interest, do you have a specific reason to do ARMA
modeling "the hard way", using libgretl yourself, rather than
using gretl?
Allin Cottrell
http://www.econ.univpm.it/lucchetti
_________________________________________________________________
Game on: Challenge friends to great games on Messenger
http://go.microsoft.com/?linkid=9734387