Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Constraints in the MLE
From
Beatrice Crozza <[email protected]>
To
statalist <[email protected]>
Subject
st: Constraints in the MLE
Date
Wed, 22 Jun 2011 11:57:02 +0100
Dear All,
I am trying to perform a maximum likelihood with two constraints
because I want to do a likelihood ratio test to see which model is
better, the restricted or the unrestricted.
My code works ( in the sense that I don't receive an error message),
however, the value of the log likelihood that I receive is always the
same, whatever the constraint that I impose. So, I think that I am
doing something wrong and that I am not changing anything in the code
actually!
Could you please help me?
Thanks a lot,
Bea
program define myprog
args lnf a d m e g p
tempvar ma md mm me mg mp am dm omm em
quietly gen double `am'=exp(`a')/(1+exp(`a'))
quietly gen double `dm'=exp(`d')/(1+exp(`d'))
quietly gen double `omm'=exp(`m')
quietly gen double `em'=exp(`e')
quietly gen double `ma'=1-`am'
quietly gen double `md'=1-`dm'
quietly gen double `mm'=1-`omm'
quietly gen double `me'=1-`em'
quietly gen double `mg'=1-`g'
quietly gen double `mp'=1-`p'
quietly replace
`lnf'=ln((`am')*(`dm')*((((`mm')+(`omm')*(`em')*(`g'))^x1)*(((`omm')+(`mm')*(`em')*(`p'))^x2)*(((`mm')*(`em')*(`me'))^x3)*(((`mmo')*(`em')*(`mg'))^x4)*(((`mm')*(`mp'))^x5)*(((`mmo')*(`eo'))^x6)))
end
constraint 1 m=e
constraint 2 g=p
ml model lf myprog (a:) (d:) (m:) (e:) (g:) (p:), technique(bfgs)
constraint(1-2)
ml check
ml search
ml maximize, difficult
nlcom (a: exp([am]_b[_cons])/(1+exp([am]_b[_cons])))
nlcom (d: exp([dm]_b[_cons])/(1+exp([dm]_b[_cons])))
nlcom (e: exp([em]_b[_cons]))
nlcom (m: exp([omm]_b[_cons]))
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/