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: maximum likelihood
From
"Abhimanyu Arora" <[email protected]>
To
<[email protected]>
Subject
st: maximum likelihood
Date
Tue, 13 Apr 2010 13:06:59 +0200
Dear statalist
I have been trying to find the maximum likelihood estimates of my model, but
I do not obtain standard errors (likelihood function non-concave and just a
couple of iterations achieved). Following the section "Importance of
generating temporary variables as doubles" pg 58-60 of the book by Gould et
al, I generate temporary variables which are functions of my parameters to
be estimated, only to obtain totally different coefficient values but still
no standard errors+no concavity. What is the reason behind this puzzling
phenomenon and its solution? Is my ml model command ok even though I may not
have any _dependent_ variable as such?
Please find below the initial and final likelihood evaluators. I have two
variables "i" (0/1) and "age"(1-5) and a constant matrix V(1X5) and need to
find parameters theta_1 and R which determine the likelihood of each
observation as below.
Thanks and regards
Abhimanyu Arora
KU Leuven
*******************
Initial ml commands
*******************
cap program drop maxl
program define maxl
qui{
args lnf theta_1 R
replace
`lnf'=ln((exp(`R'+0.9*V[1,1]))/exp(age*(`theta_1')+0.9*V[1,2])+exp(`R'+0.9*V
[1,1])) if i==1 & age ==1
replace
`lnf'=ln((exp(`R'+0.9*V[1,1]))/exp(age*(`theta_1')+0.9*V[1,3])+exp(`R'+0.9*V
[1,1])) if i==1 & age ==2
replace
`lnf'=ln((exp(`R'+0.9*V[1,1]))/exp(age*(`theta_1')+0.9*V[1,4])+exp(`R'+0.9*V
[1,1])) if i==1 & age ==3
replace
`lnf'=ln((exp(`R'+0.9*V[1,1]))/exp(age*(`theta_1')+0.9*V[1,5])+exp(`R'+0.9*V
[1,1])) if i==1 & age ==4
replace
`lnf'=ln((exp(`R'+0.9*V[1,1]))/exp(age*(`theta_1')+0.9*V[1,5])+exp(`R'+0.9*V
[1,1])) if i==1 & age ==5
replace
`lnf'=1-ln((exp(`R'+0.9*V[1,1]))/exp(age*(`theta_1')+0.9*V[1,2])+exp(`R'+0.9
*V[1,1])) if i==0 & age ==1
replace
`lnf'=1-ln((exp(`R'+0.9*V[1,1]))/exp(age*(`theta_1')+0.9*V[1,3])+exp(`R'+0.9
*V[1,1])) if i==0 & age ==2
replace
`lnf'=1-ln((exp(`R'+0.9*V[1,1]))/exp(age*(`theta_1')+0.9*V[1,4])+exp(`R'+0.9
*V[1,1])) if i==0 & age ==3
replace
`lnf'=1-ln((exp(`R'+0.9*V[1,1]))/exp(age*(`theta_1')+0.9*V[1,5])+exp(`R'+0.9
*V[1,1])) if i==0 & age ==4
replace
`lnf'=1-ln((exp(`R'+0.9*V[1,1]))/exp(age*(`theta_1')+0.9*V[1,5])+exp(`R'+0.9
*V[1,1])) if i==0 & age ==5
}
end
ml model lf maxl (theta_1:) (R:)
ml check
ml init 0 0,copy
ml maximize,difficult
*****************************************
Introducing double temporary variables
*****************************************
cap program drop maxl
program define maxl
qui{
args lnf theta_1 R
tempvar a b
gen double `a' =age*(`theta_1')
gen double `b'=exp(`R'+0.9*V[1,1])
replace `lnf'=ln(`b'/(exp(`a'+0.9*V[1,2])+`b')) if i==1 & age ==1
replace `lnf'=ln(`b'/(exp(`a'+0.9*V[1,3])+`b')) if i==1 & age ==2
replace `lnf'=ln(`b'/(exp(`a'+0.9*V[1,4])+`b')) if i==1 & age ==3
replace `lnf'=ln(`b'/(exp(`a'+0.9*V[1,5])+`b')) if i==1 & age ==4
replace `lnf'=ln(`b'/(exp(`a'+0.9*V[1,5])+`b')) if i==1 & age ==5
replace `lnf'=1-ln(`b'/(exp(`a'+0.9*V[1,2])+`b')) if i==0 & age ==1
replace `lnf'=1-ln(`b'/(exp(`a'+0.9*V[1,3])+`b')) if i==0 & age ==2
replace `lnf'=1-ln(`b'/(exp(`a'+0.9*V[1,4])+`b')) if i==0 & age ==3
replace `lnf'=1-ln(`b'/(exp(`a'+0.9*V[1,5])+`b')) if i==0 & age ==4
replace `lnf'=1-ln(`b'/(exp(`a'+0.9*V[1,5])+`b')) if i==0 & age ==5
}
end
ml model lf maxl (theta_1:) (R:)
ml check
ml init 0 0,copy
ml maximize,difficult
*
* 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/