Code error
Posted: Wed May 27, 2015 5:20 am
Hi Trubador
I am trying to trying to come up with maximum likelihood estimates using an extended TGARCH model (assuming errors follow the generalised error distribution function). My conditional mean equation is:
r_t= α+ μ(σ_t^2 )+D_t (γ_0H+γ_1H σ_t^2 ) r_(t-1)+ (1-D_L )(γ_0L+γ_1L σ_t^2 ) r_(t-1)+ε_t
and my variance equation is:
σ_t^2= α_0+ α_1 ε_(t-1)^2+ βσ_(t-1)^2+ δS_(t-1) ε_(t-1)^2
I have searched the forum and came up with my code (pasted below). When l tried running the program it gave me an error message "syntax error in eq.1arch (1,1)....". May you kindly assist me in showing me how do l can go about solving this as l am stuck. I have attached my workfile as well.
sample s0 @first @first+1
sample s1 @first+2 @last
smpl @all
' declare coef vectors to use in ARCH likelihood
coef(4) beta = 0
coef(3) alpha = 0
coef(1) dof = 0
coef(1) mu = 0
coef(1) thresh = 0
coef(6) beta = 0
' get starting values
eq1.arch(1,1,thrsh=1,archm=VAR,ged,backcast=1) y c y(-1)
eq1.makegarch garchm
eq1.arch(1,1,thrsh=1,ged,backcast=1) y = c(1) + c(2)*garchm + c(3)*savi y(-1) + c(4)*savi*garchm* y(-1) + c(5) *(1- savi)*y(-1) + c(6) *(1- savi)*garchm)*y(-1)
beta(1) = eq1.c(1)
beta(2) = eq1.c(2)
beta(3) = eq1.c(3)
beta(4) = eq1.c(4)
beta(5) = eq1.c(5)
beta(6) = eq1.c(6)
alpha(1) = eq1.c(7)
alpha(2) = eq1.c(8)
thresh(1) = eq1.c(9)
alpha(3) = eq1.c(10)
dof(1) = eq1.c(11)
mu(1) = eq1.@se^2
' set presample values of expressions in logl
series sig2 = mu(1)
series res = resid
' set up GARCH likelihood
logl ll1
ll1.append @logl logl
ll1.append @byeqn
ll1.append res = y -beta(2) *sig2 + beta(1) + beta(3)*savi* y(-1) + beta(4)*savi*sig2* y(-1) + beta(5) *(1- savi)*y(-1) + beta(6)*(1- savi)*sig2*y(-1)
ll1.append sig2 = alpha(1)+ alpha(2)*res(-1)^2 + alpha(3)*sig2(-1) + thresh(1)*res(-1)^2*(res(-1)<0)
ll1.append z = res/@sqrt(sig2)
ll1.append logl = log(@dged(z,dof(1))) - log(sig2)/2
' estimate and display results
smpl s1
ll1.ml(showopts, m=1000, c=1e-5)
show ll1.output
I am trying to trying to come up with maximum likelihood estimates using an extended TGARCH model (assuming errors follow the generalised error distribution function). My conditional mean equation is:
r_t= α+ μ(σ_t^2 )+D_t (γ_0H+γ_1H σ_t^2 ) r_(t-1)+ (1-D_L )(γ_0L+γ_1L σ_t^2 ) r_(t-1)+ε_t
and my variance equation is:
σ_t^2= α_0+ α_1 ε_(t-1)^2+ βσ_(t-1)^2+ δS_(t-1) ε_(t-1)^2
I have searched the forum and came up with my code (pasted below). When l tried running the program it gave me an error message "syntax error in eq.1arch (1,1)....". May you kindly assist me in showing me how do l can go about solving this as l am stuck. I have attached my workfile as well.
sample s0 @first @first+1
sample s1 @first+2 @last
smpl @all
' declare coef vectors to use in ARCH likelihood
coef(4) beta = 0
coef(3) alpha = 0
coef(1) dof = 0
coef(1) mu = 0
coef(1) thresh = 0
coef(6) beta = 0
' get starting values
eq1.arch(1,1,thrsh=1,archm=VAR,ged,backcast=1) y c y(-1)
eq1.makegarch garchm
eq1.arch(1,1,thrsh=1,ged,backcast=1) y = c(1) + c(2)*garchm + c(3)*savi y(-1) + c(4)*savi*garchm* y(-1) + c(5) *(1- savi)*y(-1) + c(6) *(1- savi)*garchm)*y(-1)
beta(1) = eq1.c(1)
beta(2) = eq1.c(2)
beta(3) = eq1.c(3)
beta(4) = eq1.c(4)
beta(5) = eq1.c(5)
beta(6) = eq1.c(6)
alpha(1) = eq1.c(7)
alpha(2) = eq1.c(8)
thresh(1) = eq1.c(9)
alpha(3) = eq1.c(10)
dof(1) = eq1.c(11)
mu(1) = eq1.@se^2
' set presample values of expressions in logl
series sig2 = mu(1)
series res = resid
' set up GARCH likelihood
logl ll1
ll1.append @logl logl
ll1.append @byeqn
ll1.append res = y -beta(2) *sig2 + beta(1) + beta(3)*savi* y(-1) + beta(4)*savi*sig2* y(-1) + beta(5) *(1- savi)*y(-1) + beta(6)*(1- savi)*sig2*y(-1)
ll1.append sig2 = alpha(1)+ alpha(2)*res(-1)^2 + alpha(3)*sig2(-1) + thresh(1)*res(-1)^2*(res(-1)<0)
ll1.append z = res/@sqrt(sig2)
ll1.append logl = log(@dged(z,dof(1))) - log(sig2)/2
' estimate and display results
smpl s1
ll1.ml(showopts, m=1000, c=1e-5)
show ll1.output