Ordered multinomial modelling with runmlwin vs. ordered logi

Welcome to the forum for runmlwin users. Feel free to post your question about runmlwin here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to runmlwin: Running MLwiN from within Stata >> http://www.bristol.ac.uk/cmm/software/runmlwin/
Post Reply
germain2012
Posts: 2
Joined: Fri Sep 28, 2012 4:26 pm

Ordered multinomial modelling with runmlwin vs. ordered logi

Post by germain2012 »

Dear runmlwin user forum-Members,

I am trying to reproduce the example from Stata's Manual, with the very useful command runmlwin in order to perform an ordered logistic regression (please, see below my Stata codes).
The results show that signs of the coefficients are opposite compared to what I found with Stata's ologit, i.e., when I run runmlwin the coefficients are became all negative for the three variables: foreign, length, mpg.
Also, when I reverse my outcome variable (now from 5= Poor to 1= Excellent ), the coefficients are the same, but the signs of the contrast 1, 2, 3 are reversed.

Please, how can I manage both options contrast() and basecategory() in order to have similar coefficients that look like those coefficients when I run classic ologit in Stata.

Thanks for your help.
Boco.

************** Start codes *******************************

/*runmlwin vs. ordered logistic regression

reproduce example from Stata Manual

[R] ologit -- Ordered logistic regression
STATA BASE REFERENCE MANUAL
RELEASE 12

page 1393
use http://www.stata-press.com/data/r12/fullauto, clear
*/


*** Example 2
use http://www.stata-press.com/data/r12/fullauto, clear
** alternative - specify where you have the data saved on your computer
// webuse fullauto, clear

la li repair
/*
repair:
1 Poor
2 Fair
3 Average
4 Good
5 Excellent

*/

* tabulation of rep77
tab rep77,m

//drop if rep77==.

*** Ordered logistic regression using ologit

ologit rep77 foreign length mpg, nolog


/*

Ordered logistic regression Number of obs = 66
LR chi2(3) = 23.29
Prob > chi2 = 0.0000
Log likelihood = -78.250719 Pseudo R2 = 0.1295

------------------------------------------------------------------------------
rep77 | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
foreign | 2.896807 .7906411 3.66 0.000 1.347179 4.446435
length | .0828275 .02272 3.65 0.000 .0382972 .1273579
mpg | .2307677 .0704548 3.28 0.001 .0926788 .3688566
-------------+----------------------------------------------------------------
/cut1 | 17.92748 5.551191 7.047344 28.80761
/cut2 | 19.86506 5.59648 8.896161 30.83396
/cut3 | 22.10331 5.708936 10.914 33.29262
/cut4 | 24.69213 5.890754 13.14647 36.2378
------------------------------------------------------------------------------


*/


**** Using runmlwin to fit a single-level model with an ordered categorical response variable

global MLwiN_path C:\Program Files\MLwiN v2.25\mlwin.exe

use http://www.stata-press.com/data/r12/fullauto, clear // alternative data webuse fullauto, clear
drop if rep77==.
gen cons=1
clonevar id =order // to define unique id

set more off
runmlwin rep77 cons (foreign length mpg, contrast(1/4)), ///
level1(id) ///
discrete(distribution(multinomial) link(ologit) base(5) denom(cons) mql1) nopause


/*
MLwiN 2.25 multilevel model Number of obs = 66
Ordered multinomial logit response model
Estimation algorithm: IGLS, MQL1

----------------------------------
Contrast | Log-odds
-------------+--------------------
1 | 1 vs. 2 3 4 5
2 | 1 2 vs. 3 4 5
3 | 1 2 3 vs. 4 5
4 | 1 2 3 4 vs. 5
----------------------------------

Run time (seconds) = 6.25
Number of iterations = 6
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Contrast 1 |
cons_1 | 17.92805 5.471183 3.28 0.001 7.204725 28.65137
-------------+----------------------------------------------------------------
Contrast 2 |
cons_2 | 19.86533 5.527701 3.59 0.000 9.031236 30.69943
-------------+----------------------------------------------------------------
Contrast 3 |
cons_3 | 22.10351 5.636585 3.92 0.000 11.05601 33.15102
-------------+----------------------------------------------------------------
Contrast 4 |
cons_4 | 24.69247 5.815991 4.25 0.000 13.29334 36.0916
-------------+----------------------------------------------------------------
foreign_1234 | -2.897809 .7577225 -3.82 0.000 -4.382918 -1.4127
length_1234 | -.0828333 .0225195 -3.68 0.000 -.1269707 -.038696
mpg_1234 | -.2307168 .0680191 -3.39 0.001 -.3640319 -.0974017
------------------------------------------------------------------------------


*/


*** REVERSE THE OUTCOME VARIABLE
global MLwiN_path C:\Program Files\MLwiN v2.25\mlwin.exe
use http://www.stata-press.com/data/r12/fullauto, clear // alternative data webuse fullauto, clear
drop if rep77==.
gen cons=1
clonevar id =order // to define unique id

recode rep77 (5=1 "Excellent") (4=2 "Good") (3=3 "Average") (2=4 "Fair") (1=5 "Poor"), gen(rep77_reverse)

tab1 rep77_reverse

/*

5 Poor
4 Fair
3 Average
2 Good
1 Excellent

*/

set more off
runmlwin rep77_reverse cons (foreign length mpg, contrast(1/4)), ///
level1(id) ///
discrete(distribution(multinomial) link(ologit) base(5) denom(cons) mql1) nopause


*** Now, I have similar coefficients but ancillary parameters are negatives

/*
MLwiN 2.25 multilevel model Number of obs = 66
Ordered multinomial logit response model
Estimation algorithm: IGLS, MQL1

----------------------------------
Contrast | Log-odds
-------------+--------------------
1 | 1 vs. 2 3 4 5
2 | 1 2 vs. 3 4 5
3 | 1 2 3 vs. 4 5
4 | 1 2 3 4 vs. 5
----------------------------------

Run time (seconds) = 1.34
Number of iterations = 6
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Contrast 1 |
cons_1 | -24.68866 5.813664 -4.25 0.000 -36.08323 -13.29409
-------------+----------------------------------------------------------------
Contrast 2 |
cons_2 | -22.09972 5.634651 -3.92 0.000 -33.14343 -11.05601
-------------+----------------------------------------------------------------
Contrast 3 |
cons_3 | -19.86159 5.525934 -3.59 0.000 -30.69222 -9.030955
-------------+----------------------------------------------------------------
Contrast 4 |
cons_4 | -17.92415 5.469443 -3.28 0.001 -28.64406 -7.204241
-------------+----------------------------------------------------------------
foreign_1234 | 2.897922 .7576764 3.82 0.000 1.412903 4.38294
length_1234 | .0828196 .0225126 3.68 0.000 .0386956 .1269435
mpg_1234 | .2306664 .0679953 3.39 0.001 .097398 .3639349
------------------------------------------------------------------------------

*/
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Ordered multinomial modelling with runmlwin vs. ordered

Post by GeorgeLeckie »

Hi Boco,

Interesting post.

In terms of the single-level ordinal logistic model which you are considering, -ologit- and -runmlwin- are fitting the same model. That is both models fit the data equally well and will give identical model predictions. The reasons why the coefficients don't match up (are of different signs) is simply because the two packages have implemented the same underlying model using two different parameterisations.

If you wish both packages to give the same signed coefficients, then there are tricks which you can employ to do this.

You have asked how to make the signs of the -runmlwin- coefficients match those of -ologit-.

You can do this by reverse coding the response and multiplying the variable associated with the cut points by -1.

I give an example below.

However, I see no reason to do this. The main thing to is to be aware of the different parametrisations that the two commands employ and to know how to interpret the model results in each case. See the relevant software manuals for more details.

Best wishes

George

Code: Select all

. sysuse auto, clear
(1978 Automobile Data)

. 
. keep rep78 foreign length mpg

. 
. drop if rep78==.
(5 observations deleted)

. 
. gen id = _n

. 
. gen cons = 1

. 
. 
. 
. **************************************
. * (1) -ologit- gives +ve cut points and +ve coefficients
. **************************************
. 
. * Fit the model
. ologit rep78 foreign length mpg, nolog

Ordered logistic regression                       Number of obs   =         69
                                                  LR chi2(3)      =      35.70
                                                  Prob > chi2     =     0.0000
Log likelihood =  -75.84285                       Pseudo R2       =     0.1905

------------------------------------------------------------------------------
       rep78 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     foreign |   3.386723   .8107449     4.18   0.000     1.797692    4.975754
      length |   .0442834   .0216494     2.05   0.041     .0018513    .0867155
         mpg |   .1886168   .0817381     2.31   0.021      .028413    .3488205
-------------+----------------------------------------------------------------
       /cut1 |   9.193326   5.588753                     -1.760428    20.14708
       /cut2 |   10.98896   5.556764                      .0979072    21.88002
       /cut3 |   13.66862   5.619971                      2.653681    24.68356
       /cut4 |   15.84741   5.716623                      4.643035    27.05178
------------------------------------------------------------------------------

. 
. 
. 
. **************************************
. * (2) -runmlwin- gives +ve cut points and -ve coefficients
. **************************************
. 
. * Fit the model
. runmlwin rep78 cons ///
>         (foreign length mpg, contrast(1/4)), ///
>         level1(id)  /// 
>         discrete(distribution(multinomial) link(ologit) base(5) denom(cons) mql1) ///
>         nopause
 
MLwiN 2.26 multilevel model                     Number of obs      =        69
Ordered multinomial logit response model
Estimation algorithm: IGLS, MQL1

----------------------------------
    Contrast | Log-odds
-------------+--------------------
           1 | 1 vs. 2 3 4 5
           2 | 1 2 vs. 3 4 5
           3 | 1 2 3 vs. 4 5
           4 | 1 2 3 4 vs. 5
----------------------------------

Run time (seconds)   =       2.79
Number of iterations =          6
------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Contrast 1   |
      cons_1 |   9.205256   5.422334     1.70   0.090    -1.422325    19.83284
-------------+----------------------------------------------------------------
Contrast 2   |
      cons_2 |    10.9998   5.417526     2.03   0.042      .381641    21.61795
-------------+----------------------------------------------------------------
Contrast 3   |
      cons_3 |   13.67902   5.487697     2.49   0.013     2.923326     24.4347
-------------+----------------------------------------------------------------
Contrast 4   |
      cons_4 |   15.85764    5.57615     2.84   0.004     4.928586    26.78669
-------------+----------------------------------------------------------------
foreign_1234 |  -3.383673   .7643919    -4.43   0.000    -4.881853   -1.885492
 length_1234 |   -.044303   .0210506    -2.10   0.035    -.0855614   -.0030446
    mpg_1234 |  -.1889964   .0784811    -2.41   0.016    -.3428166   -.0351762
------------------------------------------------------------------------------


. 
. 
. 
. **************************************
. * (3) -runmlwin- gives +ve cut points and +ve coefficients
. **************************************
. 
. * Multiple cutpoint variables by -1
. gen cons2 = -1*cons

. 
. * Reverse code the response
. gen invrep78 = 6 - rep78

. 
. * Fit the model
. runmlwin invrep78 cons2 ///
>         (foreign length mpg, contrast(1/4)), ///
>         level1(id)  /// 
>         discrete(distribution(multinomial) link(ologit) base(5) denom(cons) mql1) ///
>         nopause
 
MLwiN 2.26 multilevel model                     Number of obs      =        69
Ordered multinomial logit response model
Estimation algorithm: IGLS, MQL1

----------------------------------
    Contrast | Log-odds
-------------+--------------------
           1 | 1 vs. 2 3 4 5
           2 | 1 2 vs. 3 4 5
           3 | 1 2 3 vs. 4 5
           4 | 1 2 3 4 vs. 5
----------------------------------

Run time (seconds)   =       2.45
Number of iterations =          6
------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Contrast 1   |
     cons2_1 |    15.8501   5.575326     2.84   0.004     4.922665    26.77754
-------------+----------------------------------------------------------------
Contrast 2   |
     cons2_2 |   13.67168   5.486925     2.49   0.013     2.917505    24.42586
-------------+----------------------------------------------------------------
Contrast 3   |
     cons2_3 |   10.99251   5.416993     2.03   0.042        .3754    21.60962
-------------+----------------------------------------------------------------
Contrast 4   |
     cons2_4 |   9.197242   5.422504     1.70   0.090    -1.430671    19.82515
-------------+----------------------------------------------------------------
foreign_1234 |   3.382255   .7640399     4.43   0.000     1.884764    4.879745
 length_1234 |   .0442695   .0210484     2.10   0.035     .0030154    .0855235
    mpg_1234 |   .1889766   .0784718     2.41   0.016     .0351747    .3427785
------------------------------------------------------------------------------
germain2012
Posts: 2
Joined: Fri Sep 28, 2012 4:26 pm

Re: Ordered multinomial modelling with runmlwin vs. ordered

Post by germain2012 »

Hi George,
Thanks a lot for your very helpful response!
Best,
Boco.
Post Reply