I was computing a garch-in-mean model, so I have 2 equations: one for mean to obtain residuals (res) and another for variance (sig2).
The problem is that the model computes negative variance at some points and therefore I cannot take a square root of it.
So my question is how to put a non-negative constraint on the sig2 variable which is dependent.
Anyone knows? Thanks!
Here´s the part of the code I am using:
Code: Select all
logl ll4
ll4.append @logl logl
ll4.append sig2 = omega(1)+alpha(1)*res(-1)^2 +alpha2(1)*res(-1)^2*dummyshocks(-1)+beta(1)*sig2(-1)
ll4.append dummyshocks=@recode(res(-1)>0,1,0)
ll4.append res = marketVW-exp(mu(1))-param(1)*sig2-param(2)*dummysentiment-param(3)*dummysentiment*sig2
ll4.append z = res/@sqrt(sig2)
ll4.append logl = log(@dnorm(z)) - log(sig2)/2
' estimate and display results
ll4.ml(showopts, m=1000, c=1e-5)
show ll4.output
