Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Ordered logit


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: Ordered logit
Date   Sat, 09 Dec 2006 17:48:35 -0500

It would be helpful if you could post the error message
you are getting, or otherwise indicate what the problem
is.

Jeph


Josefina Posadas wrote:
Dear Statalist users,
I'm trying to replicate the ordered logit by programing a maximum
likelihood.
I'm running the program with the fullauto.dta database as in the manual.
I have these two programs that I think should be equal, but the first one
works and the second doesn't. Can somebody explain what is going on?


* First I create the indicator variable
tempvar i1 i2 i3 i4 i5
forvalues x=1/5 {
gen i`x'=0
replace i`x'=1 if `x'==rep77
}

**************************************
*** PROGRAM 1 ***
**************************************
capture program drop jologit
program define jologit
args lnf k1 k2 k3 k4
tempvar p1 p2 p3 p4 d1 d2 d3 d4
forvalues z=1/4 {
gen double `p`z''=1+exp(`k`z'')
gen double `d`z''=1/`p`z''
}
replace
`lnf'=$ML_y1*log(`d1')+$ML_y2*log(`d2'-`d1')+$ML_y3*log(`d3'-`d2')+$ML_y4*log(`d4'-`d3')+$ML_y5*log(1-`d4')
end

ml model lf jologit (i1 i2 i3 i4 i5= ) ( ) ( ) ( )
ml check
ml maximize



**************************************
*** PROGRAM 2 ***
**************************************
capture program drop jologit
program define jologit
args lnf k1 k2 k3 k4
tempvar p1 p2 p3 p4 d1 d2 d3 d4
forvalues z=1/4 {
quietly gen double `p`z''=1+exp(`k`z'')
quietly gen double `d`z''=1/`p`z''
}
replace `lnf'=log(`d1') if $ML_y1==1
replace `lnf'=log(`d2'-`d1') if $ML_y2==1
replace `lnf'=log(`d3'-`d2') if $ML_y3==1
replace `lnf'=log(`d4'-`d3') if $ML_y4==1
replace `lnf'=log(1-`d4') if $ML_y5==1
end

ml model lf jologit (i1 i2 i3 i4 i5= ) ( ) ( ) ( )
ml check
ml maximize



* Run them separately since they have the same name

_________________________________________________________________
Stay up-to-date with your friends through the Windows Live Spaces friends
list.
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mk

*
* 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/


*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index