Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: simulation for generalized ordered logit models

 From Jun Xu To Listserv STATA Subject st: simulation for generalized ordered logit models Date Wed, 18 May 2011 14:11:37 -0500

```Statalisters,

I am trying to study performance of some extensions of the order logit models (e.g., generalized ordered logit models and partial proportionality models.  However, it appears the data generating process is a bit tricky.  My problem is that I don't know (or I don't know if I did it right) how to turn latent y's into an observed ordered response variable.  In addition, because of that, I think the gologit2 estimates seem to be off quite a bit.  Any help would be greatly appreciated.

Jun Xu, PhD
Assistant Professor
Department of Sociology
Ball State University
Muncie, IN 47306

. // clear out memory and set seed
. clear all
. set more off
. set obs 50000
. set seed 15243

. // create four normally distributed x's
. gen double x1 = 1*invnorm(uniform()) - 2
. gen double x2 = 2*invnorm(uniform()) - 1
. gen double x3 = 3*invnorm(uniform()) + 1
. gen double x4 = 4*invnorm(uniform()) + 2

. // create probability to be transformed into logistically distributed variables below
. gen e1 = uniform()

. gen e2 = uniform()

.  // create a latent variable for odds of y = 3 vs. y=2, 1
. gen ylat1 = -1 +  0.25*x1 - 0.7*x2 + 0.3*x3 + 1.2*x4 + log(e1/(1-e1))
. // create another latent variable for odds of y = 3, 2 vs. y = 1
. gen ylat2 =  2 +  0.25*x1 + 0.3*x2 + 0.2*x3 + 0.8*x4 + log(e2/(1-e2))

.
. sum ylat1 ylat2

Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
ylat1 |     50000    1.895159    5.392776  -20.57706   24.00623
ylat2 |     50000    3.004502    3.786819  -14.42388   20.64439

. gen int yobs = 2

. replace yobs = 3 if ylat2 >0
(39384 real changes made)

. replace yobs = 1 if ylat1 <0
(18278 real changes made)

. // denote cases with ylat > 0 & ylat1 <0 to be deleted afterward
. // because of the contradiction in recoding; that is, should they be coded
. // as 3 or 1

. gen ctrd = (ylat2 > 0 & ylat1 <0)

|         ctrd
yobs |         0          1 |     Total
-----------+----------------------+----------
1 |     8,627      9,651 |    18,278
2 |     1,989          0 |     1,989
3 |    29,733          0 |    29,733
-----------+----------------------+----------
Total |    40,349      9,651 |    50,000

. drop if ctrd == 1
(9651 observations deleted)

.
. tab yobs, m

yobs |      Freq.     Percent        Cum.
------------+-----------------------------------
1 |      8,627       21.38       21.38
2 |      1,989        4.93       26.31
3 |     29,733       73.69      100.00
------------+-----------------------------------
Total |     40,349      100.00

.
. gologit2 yobs x1 x2 x3 x4,

Generalized Ordered Logit Estimates               Number of obs   =      40349
LR chi2(8)      =   39104.00
Prob > chi2     =     0.0000
Log likelihood = -8821.1251                       Pseudo R2       =     0.6891

------------------------------------------------------------------------------
yobs |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
1            |
x1 |   .3643754   .0223432    16.31   0.000     .3205835    .4081673
x2 |  -.3713747   .0131601   -28.22   0.000    -.3971681   -.3455813
x3 |   .3775103   .0093891    40.21   0.000      .359108    .3959126
x4 |   1.457066   .0166926    87.29   0.000     1.424349    1.489783
_cons |   1.191765   .0569216    20.94   0.000     1.080201    1.303329
-------------+----------------------------------------------------------------
2            |
x1 |   .3453517   .0215363    16.04   0.000     .3031413    .3875621
x2 |  -.0367582   .0118087    -3.11   0.002    -.0599027   -.0136136
x3 |   .3121494   .0082156    37.99   0.000      .296047    .3282517
x4 |   1.255422    .014501    86.58   0.000     1.227001    1.283844
_cons |   .4242695   .0532812     7.96   0.000     .3198402    .5286988
------------------------------------------------------------------------------

WARNING! 2363 in-sample cases have an outcome with a predicted probability that is
less than 0. See the gologit2 help section on Warning Messages for more information.

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