Allright, I got round to writing the function for fractional differencing
using vector functions so I could test it in C properly. While I was at
it, I squashed a couple bugs and optimised it a little: it seems to run ok
for any reasonable value of d, but again, the sooner this is integrated
into gretl, the better (Allin?).
Since it's rather short, I'll just put the function here instead of
attaching it.
Have a nice day, everyone.
----------------------------------------------------------------------------
/* write fractional difference of variable y into diffvec */
static int fracdiff (const gretl_matrix *y, gretl_matrix *diffvec, double d)
{
int dd, t, T;
double phi = -d;
const double TOL = 1.0E-07;
double yt, dyt;
T = gretl_vector_get_length(y);
for(t = 0; t < T; t++) {
yt = gretl_vector_get( y, t );
gretl_vector_set( diffvec, t, yt );
}
dd = 1;
while((dd<T) && fabs(phi)>TOL) {
for(t = dd; t < T; t++) {
dyt = gretl_vector_get( diffvec, t );
yt = gretl_vector_get( y, t-dd );
dyt += phi*yt;
gretl_vector_set( diffvec, t, dyt );
}
phi *= (dd-d)/(++dd);
}
return 0;
}
Riccardo `Jack' Lucchetti
Dipartimento di Economia
Università di Ancona
jack(a)dea.unian.it
http://www.econ.unian.it/lucchetti