I am trying to understand ml hold and ml unhold to use in a complicated
procedure. Nothing seems to work, so I have included a simple, contrived
example to see if someone can help.
<>My two do files defining my ml models:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
capture program drop mypmg_ec
program define mypmg_ec
version 8.2
args lnf beta
local y $ML_y1
ml hold
ml model lf mypmg_all (junk: `y'= weight, offset(`beta') nocons) /sigma
quie ml max
ml unhold
quietly replace `lnf' = e(ll)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
capture program drop mypmg_all
program define mypmg_all
version 8.2
args lnf thetas sigma
tempvar z
local y $ML_y1
quie gen double `z' = `y'-`thetas'
quietly replace `lnf' = ln(normd(`z'/exp(`sigma')))-`sigma'
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
To replicate my problem using auto.dta:
<>I want to estimate the (approximately) equivalent of regress price
disp weight, nocons <>The code fragment is:
use auto
ml model lf mypmg_ec(price=displ, nocons)
ml max
<>The problem is the ml routine seems to converge to a max, but
continually “backs up” and, as far as Stata is concerned, will not converge.