Ordered multinomial modelling with runmlwin vs. ordered logi
Posted: Mon Oct 01, 2012 4:11 pm
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
------------------------------------------------------------------------------
*/
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
------------------------------------------------------------------------------
*/