On Tue, 20 Mar 2012, Daniel Bencik wrote:
I humbly ask you for help with hopefully the last problem.
I would like to estimate an AR(1)-GARCH(1,1) model with T-distributed normalized
residuals. I take the loglik function from
http://faculty.chicagobooth.edu/jeffrey.russell/teaching/finecon/readings... p15
and transform everything into code.
# allRng[t] = c + a1*allRng[t-1] + e[t]
scalar c = 0.1
scalar a1 = 0.1
# e[t] = h[t] * Student[t]
# GARCH - h[t] = cg + ga*h[t-1] + arc*e^2[t-1]
scalar cg = 0.1
scalar ga = 0.1
scalar arc = 0.1
scalar dof = 4
mle ll = log(gammafun((dof + 1)/2)) - log(gammafun(dof/2)) - 0.5*log(dof-2) - log(h) # -
0.5*(dof + 1)*log(1 + (dof - 2)^(-1)*h^(-2)*e^2)
series e = 0
series e = allRng - c - a1*allRng(-1) #AR1 process
series h = var(allRng)
This is a type error: given a series argument, the var()
function returns a scalar result, namely the variance of the
series.
Have you looked at gig? (/Help/Check for addons)
Anyway, here's an example that works (though it's probably far
from optimal):
<hansl>
open b-g.gdt
garch 1 1 ; Y
matrix theta = zeros(6,1)
theta[1] = $coeff[1]
theta[2] = 0.1
theta[3] = $coeff[2]
theta[4] = $coeff[3]
theta[5] = $coeff[4]
theta[6] = 10
print theta
series e2
series h
series midbit
series rightbit
scalar gammabit
mle ll = log(gamma_bit * midbit * rightbit)
v = theta[6]
gamma_bit = gammafun((v+1)/2) / gammafun(v/2)
e2 = (Y - theta[1] - theta[2]*Y(-1))^2
h = 0
h = theta[3] + theta[4]*e2(-1) + theta[5]*h(-1)
midbit = ((v-2)*h)^(-0.5)
rightbit = (1 + e2/((v-2)*h))^(-(v+1)/2)
params theta
end mle
</hansl>
Allin Cottrell