Dear Statalisters,
I am running a maximization procedure to maximize Y with Xb <=
percentiles 16. The iterations takes a value which does not change
over subsequent iterations and I have to break the procedure. I would
greatly appreciate some help.
Best regard,
Hendro
**********************************************
cap program drop maxreg1
program maxreg1
args todo b lnf
tempvar xb lnfj temprank d
tempname mu lnmu
mleval `xb' = `b', eq(1)
mleval `lnmu' = `b', eq(2) scalar
scalar `mu' = exp(`lnmu')
qui gen double `lnfj' = ln(normd($ML_y1,`xb',`mu'))
mlsum `lnf' = `lnfj'
end
cap program drop maxreg
program maxreg
args todo b lnf
tempvar xb lnfj temprank d
mleval `xb' = `b', eq(1)
gsort +`xb' +$ML_y1
g `temprank' = _n
qui count if `xb' != .
local tempcount = r(N)
qui g `d' = (`temprank' < `tempcount' * 0.16)
qui gen `lnfj' = $ML_y1 * `d'
mlsum `lnf' = `lnfj'
end
ml model d0 maxreg1 (xb : mutility = house troof1 troof2 twall tfloor
pcfloor water toilet septic lighting) (lnmu:)
ml max
matrix startval = e(b)
ml model d0 maxreg (xb : mutility = house troof1 troof2 twall tfloor
pcfloor water toilet septic lighting)
ml init startval, skip
ml max, difficult
log close
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/