I'm estimating a model with threshold (1 threshold, thus 2 regimes) in both the mean and variance equation, and since the threshold value is not 0, it seems that the TGARCH feature in Eviews cannot be directly applied. Therefore I tried the User-defined optimization in Eviews, but since it's my first time using it, I'm not sure if it's programmed properly. Now I'm getting errors saying some of the log likelihood equations are NA, which I should be able to fix if there's no other big issues with the program structure. Any comment on the program will be very much appreciated! The should be useful to other users as well if it works. Thanks!
Basically, I'm applying ML to two equations:
(1) dep = (beta(1) - beta(2)*regs(1) - beta(3)*regs(2) - beta(4)*regs(3)-beta(5)*regs(4)-beta(6)*regs(5)-beta(7)*regs(6)-beta(8)*regs(7)-beta(9)*regs(8))*(thresh<thresh_value)-(beta(10)-beta(11)*regs(1)-beta(12)*regs(2)-beta(13)*regs(3)-beta(14)*regs(4)-beta(15)*regs(5)-beta(16)*regs(6)-beta(17)*regs(7)-beta(18)*regs(8))*(thresh>=thresh_value) +et
(2) ht = (beta(19)+beta(20)*e(t-1)^2+beta(21)*h(t-1))*(thresh<thresh_value)+(beta(22)+beta(23)*e(t-1)^2+beta(24)*h(t-1))*(thresh>=thresh_value)
Code: Select all
subroutine dtarch(series logl, vector beta, series dep, group regs, series thresh, scalar thresh_value, scalar sigma0)
series et = dep - (beta(1) - beta(2)*regs(1) - beta(3)*regs(2) - beta(4)*regs(3)-beta(5)*regs(4)-beta(6)*regs(5)-beta(7)*regs(6)-beta(8)*regs(7)-beta(9)*regs(8))*(thresh<thresh_value)-(beta(10)-beta(11)*regs(1)-beta(12)*regs(2)-beta(13)*regs(3)-beta(14)*regs(4)-beta(15)*regs(5)-beta(16)*regs(6)-beta(17)*regs(7)-beta(18)*regs(8))*(thresh>=thresh_value) 'residual from SETAR
series ht(10)=sigma0^2 'define the initial residual variance value
for !n=1 to 172 'forecast residual variance for GARCH
series ht(10+!n)=(beta(19)+beta(20)*et(9+!n)^2+beta(21)*ht(9+!n))*(thresh<thresh_value)+(beta(22)+beta(23)*et(9+!n)^2+beta(24)*ht(9+!n))*(thresh>=thresh_value) 'variance equation with threshold
next
logl = @log((1/ht)*@dnorm(et/ht)) 'construct logliklihood equation
endsub
series LL
vector(24) coef_dtarch
coef_dtarch=1 'set the inital value of coefficients to 1
group xs d_total_in_gdp(-1) d_total_in_gdp(-2) d_total_in_gdp(-3) d_total_in_gdp(-4) d_total_in_gdp(-5) d_total_in_gdp(-6) d_total_in_gdp(-7) d_total_in_gdp(-8) 'Group the autoregressive right hand variables
scalar sigma0=@var(setar_resid1) 'define the inital residual variance as the unconditonal variance of the SETAR residual
series d_total_in_gdp_lag=d_total_in_gdp(-1) 'threshold variable
optimize(ml=1, hess=bfgs) dtarch(LL, coef_dtarch, d_total_in_gdp, xs, d_total_in_gdp_lag, 0.1888, sigma0) 'optimization using ML
%status = @optmessage
statusline {%status}