### Re: Please Professor Lucchetti: question concerning ARMA model with Garch errors in Gretl

On Wed, 25 Feb 2015, kaffel bilel wrote:
> Dear Professor Lucchetti,Hello,I hope that I am notdisturbing you
> I am Bilel Kaffel.
[...]
> My problem is: I want to know how can I estimate the parameters of an
> ARMA model with Garch errors in Gretl?. For exemple : ARMA(1,2) model
> with Garch(1,1) errors. The parameters will need to be estimate
> simultaneously. Please Professor: can you help me?
Two things:
(1) I strongly advise you to subscribe to the gretl user list and ask
these questions there: not only you have a much better chance of receiving
an answer in a short time, you will also benefit the gretl community
because your question (and the subsequent answers) will be archived and
made public (and, most importantly, googleable). For this reason, I'm
replying to you with the user mailing list in cc. You can browse the
archives here:
http://lists.wfu.edu/pipermail/gretl-users/
(2) Here is a sample script that estimates an arma(1,1) + garch(1,1). I'm
sure that by studying this example together with the gretl manuals you'll
find it quite easy to generalise it to the case of your interest:
<hansl>
set echo off
set messages off
function series arma_garch_flt(series y, matrix param, scalar p, scalar q)
scalar m = param[1]
matrix arpar = param[2:p+1]
matrix mapar = param[p+2:p+q+1]
scalar c = param[p+q+2]
scalar a = param[p+q+3]
scalar b = param[p+q+4]
series ret = NA
# --- checks
# stationarity
matrix roots = polroots(1 | -arpar)
check = minc(abs(sumr(roots.^2))) > 1
# invertibility
matrix roots = polroots(1 | mapar)
check = check && minc(abs(sumr(roots.^2))) > 1
# garch param
check = check && (c>0) && (a > 0) && (b>=0) && (a+b<1)
if check
scalar hlag = c/(1-a-b)
series ret = -0.5*ln(2*$pi) # the loglikelihood
series e = filter(y - m, 1 | -arpar, -mapar, m)
series e2 = e^2
scalar h_unc = c/(1-a-b)
series e2lag = ok(e(-1)) ? e(-1)^2 : h_unc
series h = filter(c + a*e2lag, 1, b)
series ret = -0.5*(2*$pi) - 0.5*ln(h) - 0.5*e2/h
endif
return ret
end function
# ------------------------------------------------------------------------
open djclose.gdt --quiet
series r = 100 * ldiff(djclose)
arima 1 1 ; r
armapar = $coeff
garch 1 1 ; r
garchpar = $coeff[2:]
param = armapar | garchpar
mle ll = arma_garch_flt(r, param, 1, 1)
params param
end mle -v
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti@...
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------

On Wed, 25 Feb 2015, kaffel bilel wrote:
> Dear Professor Lucchetti,Hello,I hope that I am notdisturbing you
> I am Bilel Kaffel.
[...]
> My problem is: I want to know how can I estimate the parameters of an
> ARMA model with Garch errors in Gretl?. For exemple : ARMA(1,2) model
> with Garch(1,1) errors. The parameters will need to be estimate
> simultaneously. Please Professor: can you help me?
Two things:
(1) I strongly advise you to subscribe to the gretl user list and ask
these questions there: not only you have a much better chance of receiving
an answer in a short time, you will also benefit the gretl community
because your question (and the subsequent answers) will be archived and
made public (and, most importantly, googleable). For this reason, I'm
replying to you with the user mailing list in cc. You can browse the
archives here:
http://lists.wfu.edu/pipermail/gretl-users/
(2) Here is a sample script that estimates an arma(1,1) + garch(1,1). I'm
sure that by studying this example together with the gretl manuals you'll
find it quite easy to generalise it to the case of your interest:
<hansl>
set echo off
set messages off
function series arma_garch_flt(series y, matrix param, scalar p, scalar q)
scalar m = param[1]
matrix arpar = param[2:p+1]
matrix mapar = param[p+2:p+q+1]
scalar c = param[p+q+2]
scalar a = param[p+q+3]
scalar b = param[p+q+4]
series ret = NA
# --- checks
# stationarity
matrix roots = polroots(1 | -arpar)
check = minc(abs(sumr(roots.^2))) > 1
# invertibility
matrix roots = polroots(1 | mapar)
check = check && minc(abs(sumr(roots.^2))) > 1
# garch param
check = check && (c>0) && (a > 0) && (b>=0) && (a+b<1)
if check
scalar hlag = c/(1-a-b)
series ret = -0.5*ln(2*$pi) # the loglikelihood
series e = filter(y - m, 1 | -arpar, -mapar, m)
series e2 = e^2
scalar h_unc = c/(1-a-b)
series e2lag = ok(e(-1)) ? e(-1)^2 : h_unc
series h = filter(c + a*e2lag, 1, b)
series ret = -0.5*(2*$pi) - 0.5*ln(h) - 0.5*e2/h
endif
return ret
end function
# ------------------------------------------------------------------------
open djclose.gdt --quiet
series r = 100 * ldiff(djclose)
arima 1 1 ; r
armapar = $coeff
garch 1 1 ; r
garchpar = $coeff[2:]
param = armapar | garchpar
mle ll = arma_garch_flt(r, param, 1, 1)
params param
end mle -v
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti@...
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------