Allin,
thanks a lot, that was the issue. When I thus try to constrain the calculation not to go in the direction where negative lambdas are created by
<hansl>
function scalar getNegativesCount(series * xSeries)
scalar xRetVal = 0
loop xIdx = 1..$nobs
if missing( xSeries[xIdx] ) = 0
if xSeries[xIdx] < 0.0
xRetVal = xRetVal + 1
endif
endif
endloop
return xRetVal
end function
...
# ESTIMATION
mle ll = xCheck == 0 ? -ln(lambda) - sqrtPark/lambda : NA
series lambda = mean(sqrtPark)
series lambda = c_ + rng * sqrtPark(-1) + rng2 * sqrtPark(-2) + err_ * lambda(-1) + err_2 * lambda(-2)
scalar xCheck = getNegativesCount(& lambda)
params c_ rng rng2 err_ err_2
end mle --robust
#ESTIMATION
</hansl>
I get a "Scalar loglikelihood: can't do QML". So, how do I tell the optimizer that in case it runs to negative lambda, it should "go away" from that parameter combination? I also tried to replace the
<hansl>
...
mle ll = xCheck == 0 ? -ln(lambda) - sqrtPark/lambda : NA
...
</hansl>
with
<hansl>
...
mle ll = xCheck == 0 ? -ln(lambda) - sqrtPark/lambda : -100000
...
</hansl>
but it produced the same error.
Many thanks,
Daniel