Virata manual

mlogit

Explains a choice among categories with no order.

What we have

  • the base outcome is the most frequent, as in Stata
  • baseoutcome() to choose a different one

Coming later

  • rrr, to print relative risk ratios
  • predict and margins afterwards

How you write it

mlogit depvar indepvars [if]

Square brackets mean optional. A vertical bar means choose one.

What it does

For outcomes like which department someone joined, or which of four transport modes they took — categories with no natural ranking.

The output has one block of coefficients per category, each read against one category held back for comparison (the base outcome, here the most common one). A coefficient says how a column shifts the chance of that category *relative to the base*, so the base is part of the meaning of every number.

Try it

Every example below was run after sysuse vira.sample03, clear.

. mlogit dept age level
Multinomial logistic regression              Number of obs      =        4,000
                                             LR chi2            =         9.42
                                             Prob > chi2        =       0.3081
                                             Pseudo R2          =       0.0008

------------------------------------------------------------------------------
        dept | Coefficient  Std. err.      z   P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
           2 |
         age |    -.010002  .00547719   -1.83   0.068    -.0207371   .00073307
       level |    .1041765  .04490758    2.32   0.020    .01615931    .1921938
       _cons |   .02541439   .1956219    0.13   0.897    -.3579974    .4088262
-------------+----------------------------------------------------------------
           3 |
         age |    -.003396  .00565136   -0.60   0.548    -.0144725   .00768043
       level |   .07206193  .04649382    1.55   0.121    -.0190643    .1631881
       _cons |   -.2891609   .2030703   -1.42   0.154    -.6871715    .1088496
-------------+----------------------------------------------------------------
           4 |
         age |   -.0063909   .0080367   -0.80   0.426    -.0221426   .00936072
       level |   .00636131  .06752159    0.09   0.925    -.1259786    .1387012
       _cons |   -1.077235   .2871923   -3.75   0.000    -1.640122   -.5143488
-------------+----------------------------------------------------------------
           5 |
         age |   .00270994  .00661423    0.41   0.682    -.0102537   .01567359
       level |   .02634223  .05476985    0.48   0.631    -.0810047    .1336892
       _cons |   -.9452208    .239189   -3.95   0.000    -1.414023    -.476419
------------------------------------------------------------------------------
(base outcome: dept = 1)
The same thing in pandas and in R

pandas

import statsmodels.formula.api as smf

model = smf.mnlogit("dept ~ age + level", data=df).fit()

R

library(nnet)
model <- multinom(dept ~ age + level, data = df)
summary(model)

# This R has NOT been run against a real R yet: read it as documentation.

Nearby

regress logit probit poisson nbreg ologit