I am trying to run a MLE for an interval regression model that assumes an SGT distribution for the error distribution. (the SGT distribution has 5 model parameters and 13 parameters we are interested in aside from the constant so it's a pretty heavily involved model.
So my MLE is all set up. I have tried other distributions for the error distribution like the SGED and the Normal with less parameters and they work fine. But for some reason, my MLE with the SGT doesn't really work. I have tried editing the CDF for the SGT distribution to make it within bounds and what not but I am still experiencing the following error everytime I try to iterate over the log likelihood values:
Fitting constant only model:
initial: log likelihood = -<inf> (could not be evaluated)
feasible: log likelihood = -2279.7385
improve: log likelihood = -2279.7385
rescale: log likelihood = -2119.268
rescale eq: log likelihood = -1994.3679
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
Iteration 0: log likelihood = -1994.3679 (not concave)
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
cannot compute an improvement -- discontinuous region encountered
r(430);
So the log likelihood value I am looking to go down to is about -1526. But I'm not sure why I am experiencing this problem all the time. I have tried putting in different initial values or repeating more times but it doesn't seem to work.
Here is a code of my CDF function. Not sure if I should do more to condition it
program intllf_sgt_condition
version 13
args lnf mu lambda sigma p q
tempvar Fu Fl zu zl cond
qui gen double `Fu' = .
qui gen double `Fl' = .
qui gen double `zu' = .
qui gen double `zl' = .
qui gen double `cond' = 0.75
qui replace `lambda' = exp(`lambda')/(1+exp(`lambda'))
qui replace `q' = sqrt(`q'^2)
qui replace `sigma' = sqrt(`sigma'^2)
qui replace `p' = sqrt(`p'^2)
*Interval data
qui replace `zu' = 1 / (1+ `q'* ((`sigma'*(1+`lambda'*sign($ML_y2 - `mu')))/(abs($ML_y2 - `mu')))^`p') ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2
qui replace `Fu' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y2- ///
`mu'))*sign($ML_y2 - `mu')*ibeta(1/`p',`q',`zu') ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2 & `zu' <= `cond'
qui replace `Fu' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y2- ///
`mu'))*sign($ML_y2 - `mu')*(1-ibeta(`q', 1/`p', 1 - `zu')) ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2 & `zu' > `cond'
qui replace `zl' = 1 / (1+ `q'* ((`sigma'*(1+`lambda'*sign($ML_y1 - `mu')))/(abs($ML_y1 - `mu')))^`p') ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2
qui replace `Fl' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y1- ///
`mu'))*sign($ML_y1 - `mu')*ibeta(1/`p',`q',`zl') ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2 & `zl' <= `cond'
qui replace `Fl' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y1- ///
`mu'))*sign($ML_y1 - `mu')*(1-ibeta(`q',1/`p',1 - `zl')) ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2 & `zl' > `cond'
qui replace `lnf' = log(`Fu' -`Fl') if $ML_y1 != . & $ML_y2 != . & ///
$ML_y1 != $ML_y2
*Bottom coded data
qui replace `zl' = 1 / (1+ `q'* ((`sigma'*(1+`lambda'*sign($ML_y1 - `mu')))/(abs($ML_y1 - `mu')))^`p') ///
if $ML_y1 != . & $ML_y2 == .
qui replace `Fl' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y1- ///
`mu'))*sign($ML_y1 - `mu')*ibeta(1/`p',`q',`zl') ///
if $ML_y1 != . & $ML_y2 == . & `zl' <= `cond'
qui replace `Fl' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y1- ///
`mu'))*sign($ML_y1 - `mu')*(1-ibeta(`q',1/`p',1-`zl')) ///
if $ML_y1 != . & $ML_y2 == . & `zl' > `cond'
qui replace `lnf' = log(1-`Fl') if $ML_y1 != . & $ML_y2 == .
*Top coded data
qui replace `zu' = 1 / (1+ `q'* ((`sigma'*(1+`lambda'*sign($ML_y2 - `mu')))/(abs($ML_y2 - `mu')))^`p') ///
if $ML_y2 != . & $ML_y1 == .
qui replace `Fu' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y2- ///
`mu'))*sign($ML_y2 - `mu')*ibeta(1/`p',`q',`zu') ///
if $ML_y2 != . & $ML_y1 == . & `zu' <= `cond'
qui replace `Fu' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y2- ///
`mu'))*sign($ML_y2 - `mu')*(1-ibeta(`q',1/`p', 1 - `zu')) ///
if $ML_y2 != . & $ML_y1 == . & `zu' > `cond'
qui replace `lnf' = log(`Fu') if $ML_y2 != . & $ML_y1 == .
*Missing values
qui replace `lnf' = 0 if $ML_y2 == . & $ML_y1 == .
end
So my MLE is all set up. I have tried other distributions for the error distribution like the SGED and the Normal with less parameters and they work fine. But for some reason, my MLE with the SGT doesn't really work. I have tried editing the CDF for the SGT distribution to make it within bounds and what not but I am still experiencing the following error everytime I try to iterate over the log likelihood values:
Fitting constant only model:
initial: log likelihood = -<inf> (could not be evaluated)
feasible: log likelihood = -2279.7385
improve: log likelihood = -2279.7385
rescale: log likelihood = -2119.268
rescale eq: log likelihood = -1994.3679
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
Iteration 0: log likelihood = -1994.3679 (not concave)
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
cannot compute an improvement -- discontinuous region encountered
r(430);
So the log likelihood value I am looking to go down to is about -1526. But I'm not sure why I am experiencing this problem all the time. I have tried putting in different initial values or repeating more times but it doesn't seem to work.
Here is a code of my CDF function. Not sure if I should do more to condition it
program intllf_sgt_condition
version 13
args lnf mu lambda sigma p q
tempvar Fu Fl zu zl cond
qui gen double `Fu' = .
qui gen double `Fl' = .
qui gen double `zu' = .
qui gen double `zl' = .
qui gen double `cond' = 0.75
qui replace `lambda' = exp(`lambda')/(1+exp(`lambda'))
qui replace `q' = sqrt(`q'^2)
qui replace `sigma' = sqrt(`sigma'^2)
qui replace `p' = sqrt(`p'^2)
*Interval data
qui replace `zu' = 1 / (1+ `q'* ((`sigma'*(1+`lambda'*sign($ML_y2 - `mu')))/(abs($ML_y2 - `mu')))^`p') ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2
qui replace `Fu' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y2- ///
`mu'))*sign($ML_y2 - `mu')*ibeta(1/`p',`q',`zu') ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2 & `zu' <= `cond'
qui replace `Fu' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y2- ///
`mu'))*sign($ML_y2 - `mu')*(1-ibeta(`q', 1/`p', 1 - `zu')) ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2 & `zu' > `cond'
qui replace `zl' = 1 / (1+ `q'* ((`sigma'*(1+`lambda'*sign($ML_y1 - `mu')))/(abs($ML_y1 - `mu')))^`p') ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2
qui replace `Fl' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y1- ///
`mu'))*sign($ML_y1 - `mu')*ibeta(1/`p',`q',`zl') ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2 & `zl' <= `cond'
qui replace `Fl' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y1- ///
`mu'))*sign($ML_y1 - `mu')*(1-ibeta(`q',1/`p',1 - `zl')) ///
if $ML_y1 != . & $ML_y2 != . & $ML_y1 != $ML_y2 & `zl' > `cond'
qui replace `lnf' = log(`Fu' -`Fl') if $ML_y1 != . & $ML_y2 != . & ///
$ML_y1 != $ML_y2
*Bottom coded data
qui replace `zl' = 1 / (1+ `q'* ((`sigma'*(1+`lambda'*sign($ML_y1 - `mu')))/(abs($ML_y1 - `mu')))^`p') ///
if $ML_y1 != . & $ML_y2 == .
qui replace `Fl' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y1- ///
`mu'))*sign($ML_y1 - `mu')*ibeta(1/`p',`q',`zl') ///
if $ML_y1 != . & $ML_y2 == . & `zl' <= `cond'
qui replace `Fl' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y1- ///
`mu'))*sign($ML_y1 - `mu')*(1-ibeta(`q',1/`p',1-`zl')) ///
if $ML_y1 != . & $ML_y2 == . & `zl' > `cond'
qui replace `lnf' = log(1-`Fl') if $ML_y1 != . & $ML_y2 == .
*Top coded data
qui replace `zu' = 1 / (1+ `q'* ((`sigma'*(1+`lambda'*sign($ML_y2 - `mu')))/(abs($ML_y2 - `mu')))^`p') ///
if $ML_y2 != . & $ML_y1 == .
qui replace `Fu' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y2- ///
`mu'))*sign($ML_y2 - `mu')*ibeta(1/`p',`q',`zu') ///
if $ML_y2 != . & $ML_y1 == . & `zu' <= `cond'
qui replace `Fu' = .5*(1-`lambda') + .5*(1+`lambda'*sign($ML_y2- ///
`mu'))*sign($ML_y2 - `mu')*(1-ibeta(`q',1/`p', 1 - `zu')) ///
if $ML_y2 != . & $ML_y1 == . & `zu' > `cond'
qui replace `lnf' = log(`Fu') if $ML_y2 != . & $ML_y1 == .
*Missing values
qui replace `lnf' = 0 if $ML_y2 == . & $ML_y1 == .
end