Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How do I estimate multinomial logit using glm?


From   [email protected] (Brendan Halpin)
To   [email protected]
Subject   Re: st: How do I estimate multinomial logit using glm?
Date   Wed, 06 Apr 2011 14:17:54 +0100

On Wed, Apr 06 2011, Raquel Guimarães wrote:

> Taking into account that multinomial logit is a special case of glm,
> how would I estimate a multinomial logit model using glm? I do not
> want to use the mlogit command because I will try to modify an
> algorithm which uses glm.


I don't know if there is a general -glm- equivalent for -mlogit-. 

If all your data are categorical, you can fit your multinomial logistic
as a log-linear model (glm with a poisson link) of the collapsed version
of your data.

If you have continuous explanatory variables, you can approximate the
-mlogit- with a -logit-, by stacking the data. If you have C outcomes,
use C-1 stacks each containing the reference cases and the relevant
outcome, and append the stacks. Create a 0/1 outcome variable (base
category versus other category) and a stack identifier. Then fit a
logit, with the stack identifier interacted with the explanatory
variables. I append an example with four outcomes, and one binary and
one continuous explanatory variable. Parameter estimates will be close
to those from mlogit, though you have to combine first-order and
interaction terms to approximate the mlogit output (e.g., the Lib_Dem
age effect of .0139748 in the mlogit model corresponds to .0027183 +
.01302930 = .0157476 in the stacked logit). 


I have only intuition telling me this is a sensible thing to do, so I'd
be interested in opinions from statalisters who are more informed than
I!

Brendan


Example below:
-------------

. mlogit vote i.univ age, baseoutcom(1)

Iteration 0:   log likelihood = -2895.9773  
Iteration 1:   log likelihood = -2851.8536  
Iteration 2:   log likelihood = -2851.0618  
Iteration 3:   log likelihood = -2851.0613  
Iteration 4:   log likelihood = -2851.0613  

Multinomial logistic regression                   Number of obs   =       2180
                                                  LR chi2(6)      =      89.83
                                                  Prob > chi2     =     0.0000
Log likelihood = -2851.0613                       Pseudo R2       =     0.0155

------------------------------------------------------------------------------
        vote |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Con          |  (base outcome)
-------------+----------------------------------------------------------------
Lab          |
      1.univ |  -.5002323   .2964365    -1.69   0.092    -1.081237    .0807725
         age |   .0027612   .0036114     0.76   0.445    -.0043171    .0098394
       _cons |   .1086836   .1628719     0.67   0.505    -.2105395    .4279067
-------------+----------------------------------------------------------------
Lib_Dem      |
      1.univ |   .5005009   .2690018     1.86   0.063    -.0267329    1.027735
         age |   .0139748   .0039518     3.54   0.000     .0062295    .0217201
       _cons |  -.8745221   .1873641    -4.67   0.000    -1.241749   -.5072953
-------------+----------------------------------------------------------------
Nat_other    |
      1.univ |  -.6209613   .2682885    -2.31   0.021    -1.146797   -.0951255
         age |  -.0148047   .0034644    -4.27   0.000    -.0215949   -.0080146
       _cons |   1.260937   .1486731     8.48   0.000      .969543    1.552331
------------------------------------------------------------------------------

. 
. save /tmp/baseline, replace
file /tmp/baseline.dta saved

. 
. keep if inlist(vote,1,2)
(1202 observations deleted)

. gen outcome = vote == 2

. gen type = 2

. save /tmp/base2, replace
file /tmp/base2.dta saved

. 
. use /tmp/baseline

. keep if inlist(vote,1,3)
(1391 observations deleted)

. gen outcome = vote == 3

. gen type = 3

. save /tmp/base3, replace
file /tmp/base3.dta saved

. 
. use /tmp/baseline

. keep if inlist(vote,1,4)
(885 observations deleted)

. gen outcome = vote == 4

. gen type = 4

. save /tmp/base4, replace
file /tmp/base4.dta saved

. 
. clear

. use /tmp/base2

. append using /tmp/base3
(label vote already defined)
(label aage already defined)

. append using /tmp/base4
(label vote already defined)
(label aage already defined)

. 
. logit outcome i.univ##i.type c.age##i.type

Iteration 0:   log likelihood = -2094.0704  
Iteration 1:   log likelihood = -2024.0629  
Iteration 2:   log likelihood = -2023.9331  
Iteration 3:   log likelihood = -2023.9331  

Logistic regression                               Number of obs   =       3062
                                                  LR chi2(8)      =     140.27
                                                  Prob > chi2     =     0.0000
Log likelihood = -2023.9331                       Pseudo R2       =     0.0335

------------------------------------------------------------------------------
     outcome |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      1.univ |  -.4995742   .2964996    -1.68   0.092    -1.080703    .0815543
             |
        type |
          3  |  -1.059861    .256713    -4.13   0.000     -1.56301   -.5567129
          4  |   1.134931   .2194968     5.17   0.000     .7047247    1.565136
             |
   univ#type |
        1 3  |   .9875869   .4007027     2.46   0.014     .2022241     1.77295
        1 4  |  -.1123549   .4001716    -0.28   0.779    -.8966767     .671967
             |
         age |   .0027183   .0036004     0.75   0.450    -.0043383    .0097748
             |
  type#c.age |
          3  |   .0130293   .0055662     2.34   0.019     .0021197    .0239389
          4  |  -.0171311   .0049773    -3.44   0.001    -.0268865   -.0073758
             |
       _cons |    .110413   .1625013     0.68   0.497    -.2080837    .4289098
------------------------------------------------------------------------------



-- 
Brendan Halpin,   Department of Sociology,   University of Limerick,   Ireland
Tel: w +353-61-213147  f +353-61-202569  h +353-61-338562;  Room F1-009 x 3147
mailto:[email protected]    ULSociology on Facebook: http://on.fb.me/gSmj8x
http://teaching.sociology.ul.ie/bhalpin/wordpress         twitter:@ULSociology

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index