Statalist The Stata Listserver


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

Re: [SPAM] st: Ordered logit


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: [SPAM] st: Ordered logit
Date   Sun, 10 Dec 2006 00:52:42 -0500

At 02:14 PM 12/9/2006, 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?
I'm still curious why you are doing this, but in any event I think I see the problem.


* 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
}
Note that rep77 has 8 cases with missing values. Under the coding above, those cases will all be coded 0 on i1 through i5.


  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
Under program 1's method, the rep77 8 missing cases get coded 0 on lnf.

  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
Under program 2's method, the rep77 8 missing cases never get assigned a value on lnf, hence the program can't produce feasible values.

So, you have to do something about missing values. You could do something like

keep if rep77 < .

Or, your ml model command could be

ml model lf jologit (i1 i2 i3 i4 i5= ) ( ) ( ) ( ) if rep77 < .

Or, to keep the program more general, you could rework the code a bit to add marksample and markout commands.

Incidentally, note that even in the "correct" program, the signs are the opposite of those reported by ologit; and the N reported was 74 compared to ologit's 66, again because those 8 cases aren't being dropped correctly.


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc
*
* 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