Hi,
On 05/13/2012 05:15 PM, José Belbute wrote:
> Dear all
>
> Let me suggest to the gretl development team to create an ARFIMA routine
> to test the presence of long memory in a time series.
If you want to _test_ for long memory, check out the "fractional
integration" menu item under unit root tests. (Equivalent command
'fractint'.)
A prepackaged ARFIMA routine for estimation indeed doesn't seem to
available, however. (This is typically the point where Jack responds
that you just need two lines of hansl code to do that.) Depending on
what you want to do, it may be enough to apply fractional differencing
to the data (Variable -> Filter -> Fractional difference) and then fit a
standard ARMA model.

Well, not exactly two lines, but not overly difficult either:
<hansl>
set echo off
set messages off
function scalar gph(series y, scalar m)
/*
Geweke/Porter-Hudak estimator
*/
matrix f = fft({y})/$nobs
matrix f = f[2:(m+1),]
matrix f = log(sumr(f.^2))
matrix lambda = (pi/$nobs) * seq(1,m)'
matrix X = ones(m,1) ~ log(sin(lambda))
matrix b = mols(f, X)
return -0.5*b[2]
end function
# --- main -----------------------------------
# generate pseudorandom data
set seed 1234
nulldata 1000
setobs 1 1 --special
true_d = -0.25
true_phi = 0.7
true_theta = 0.4
u = fracdiff(normal(), -true_d)
y = 3 + filter(u, {1, true_theta}, true_phi)
# initialise parameters: preliminary estimate of d via GPH, the
# rest via conditional ARMA
d = gph(y, 30)
my = mean(y)
z = fracdiff(y - my, d)
arma 1 1 ; z -cq
phi = $coeff[2]
theta = $coeff[3]
b = my
# do conditional mle
printf "Initial values: phi = %f, theta = %f, d = %f\n", \
phi, theta, d
mle ll = -0.5 * (ln(s2) + e2/s2)
series e = filter(y - b, {1, -phi}, -theta)
series e = abs(d) < 0.5 ? fracdiff(e, d) : NA
series e2 = e^2
scalar s2 = mean(e2)
params b phi theta d
end mle
</hansl>
Note: the above will estimate the parameters of an arfima(1,d,1) model via
*conditional* ml by making a number of choices that are both
asymptotically valid and computationally convenient. In order to get
*full* ml estimates you'd have to do much more work. IMHO, the
_definitive_ implementation of full-ML arfima is Doornik's "arfima" ox
package, which uses a very clever algorithm for fast computation of
determinants and inverses of Toeplitz matrices which unfortunately we
don't have yet.
--------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
--------------------------------------------------