Skip to Main Content

Logit, Ordered Logit, and Multinomial Logit Models in Stata: A Hands-on Tutorial

An introductory guide to estimate logit, ordered logit, and multinomial logit models using Stata

A Hands-on Tutorial

1. Basic Concept

Logit Model

If the outcome or dependent variable is binary and in the form 0/1, then use logit or probit models. 

Example 1:

Did you vote in the last election?

0 ‘No’

1 ‘Yes’

Example 2:

Do you prefer to use public transportation or to drive a car?

0 ‘Prefer to drive’

1 ‘Prefer public transport’

Note: Logit and probit models are basically the same; the difference is in the distribution:

  • Logit – Cumulative standard logistic distribution (F)
  • Probit – Cumulative standard normal distribution (Φ)

Both models provide similar results.

Ordered Logit Model

If the outcome or dependent variable is categorical but ordered (e.g., low to high), use ordered logit or ordered probit models. 

Example 1:

Do you agree or disagree with the President?

1 ‘Disagree’

2 ‘Neutral’

3 ‘Agree’

Example 2:

What is your socioeconomic status?

1 ‘Low’

2 ‘Middle’

3 ‘High’

Multinomial Logit Model

If the outcome or dependent variable is categorical without any particular order, then use multinomial logit.

Example 1:

If elections were held today, for which party would you vote?

1 ‘Democrats’

2 ‘Independent’

3 ‘Republicans’

Example 2:

What do you like to do on the weekends?

1 ‘Rest’

2 ‘Go to movies’

3 ‘Exercise’

2. Estimating the Logit Model using Stata

2.1. Estimating log-odds ratio

To get the data. Type:

use "https://dss.princeton.edu/training/logit.dta"

To run a logit model, type:

logit y_bin x1 x2 x3 i.opinion

Where y_bin is the dependent variable, and x1 x2 x3 i.opinion are independent variables. We use i. before opinion because it is a categorical variable.

Stata will give us the following output table.

. logit y_bin x1 x2 x3 i.opinion
Iteration 0:   log likelihood =  -35.02817  
Iteration 1:   log likelihood =  -28.82225  
Iteration 2:   log likelihood = -27.871856  
Iteration 3:   log likelihood = -27.842191  
Iteration 4:   log likelihood = -27.842142  
Iteration 5:   log likelihood = -27.842142  
Logistic regression                                     Number of obs =     70
                                                        LR chi2(6)    =  14.37
                                                        Prob > chi2   = 0.0257
Log likelihood = -27.842142                             Pseudo R2     = 0.2051
------------------------------------------------------------------------------
       y_bin | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
          x1 |   1.133556   .9340937     1.21   0.225    -.6972338    2.964346
          x2 |   .3021217   .3566358     0.85   0.397    -.3968716    1.001115
          x3 |   .3976277   .4763941     0.83   0.404    -.5360876    1.331343
             |
     opinion |
      Agree  |  -1.916357   .9046227    -2.12   0.034    -3.689385    -.143329
      Disag  |   .3270627   .9984349     0.33   0.743    -1.629834    2.283959
  Str disag  |   .6891686   1.249471     0.55   0.581     -1.75975    3.138087
             |
       _cons |   .8816118   .8587917     1.03   0.305     -.801589    2.564813
------------------------------------------------------------------------------

Interpretation

  • The P>|z| column shows the two-tailed p-values testing the null hypothesis that the coefficient equals zero (i.e., no significant effect). We usually reject the null hypothesis if the p-value <0.05. By this measure, none of the coefficients except for Agree significantly affect the log-odds ratio of the dependent variable. The coefficient for Agree is significant at the 5% (0.034<0.05) level.
  • The z value also tests the null that the coefficient equals zero. For a 5% significance, the z-value should fall outside the ±1.96.
  • The Coefficient column shows the coefficients in log-odds form. For example, when x1 increases by one unit, the expected change in the log odds is 1.133556 (an increase), holding all other variables in the model constant. However, this increase is not statistically significant because the p-value is not < 0.05.

Note: What you get from the Coefficient column is whether the effect of the predictors is positive or negative. See the following sub-sections (2.2., 2.3., and 2.4.) for an extended explanation of logit outcomes.

2.2. Estimating the odds ratio

The odds ratio allows an easier interpretation of the logit coefficients. They are the exponentiated value of the logit coefficients. We can get the odds ratio by using the following procedure. 

To get the data. Type: (You don't need to get data again if you already estimated log-odds following the instruction in section 2.1.)

use "https://dss.princeton.edu/training/logit.dta", clear

To get odds ratio rather than logit coefficients, type:

logit y_bin x1 x2 x3 i.opinion, or

Note: We added or at the end of the command to get the odds ratio. 

Stata will give us the following output table.

. logit y_bin x1 x2 x3 i.opinion, or
Iteration 0:   log likelihood =  -35.02817  
Iteration 1:   log likelihood =  -28.82225  
Iteration 2:   log likelihood = -27.871856  
Iteration 3:   log likelihood = -27.842191  
Iteration 4:   log likelihood = -27.842142  
Iteration 5:   log likelihood = -27.842142  
Logistic regression                             Number of obs     =         70
                                                LR chi2(6)        =      14.37
                                                Prob > chi2       =     0.0257
Log likelihood = -27.842142                     Pseudo R2         =     0.2051
------------------------------------------------------------------------------
       y_bin | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |   3.106685   2.901935     1.21   0.225     .4979609    19.38203
          x2 |   1.352726   .4824304     0.85   0.397     .6724204    2.721314
          x3 |    1.48829   .7090125     0.83   0.404     .5850326    3.786125
             |
     opinion |
      Agree  |    .147142    .133108    -2.12   0.034     .0249874     .866469
      Disag  |   1.386888   1.384718     0.33   0.743     .1959622    9.815465
  Str disag  |   1.992059    2.48902     0.55   0.581     .1720878    23.05972
             |
       _cons |   2.414789     2.0738     1.03   0.305     .4486155    12.99822
------------------------------------------------------------------------------
Note: _cons estimates baseline odds.

 

Interpretation:

  • Odds Ratio: They represent the odds of Y=1 when X increases by 1 unit. These are the exp(logit coeff). 

If the OR > 1 then the odds of Y=1 increases

If the OR < 1 then the odds of Y=1 decreases

  • Let's interpret the odds ratio for x1 which is 3.106685.

It indicates, keeping all other variables constant, when x1 increases by one unit, the odds of Y = 1 increase by 211%. However, this increase is not statistically significant as the p-value is not < 0.05. We get this 211% as follows: (3.106685 - 1) * 100 = 210.67.

Or, we can also say the odds of Y =1 are 3.1 times higher when x1 increases by one unit, keeping all other predictors constant. 

Note: To calculate the odds ratio by hand, you need to exponentiate the logit coefficient. The formula is:

 odds ratio = exp(coef(logit))

In section 2.1., we got logit coefficient for x1 = 1.133556. Therefore, the odds ratio for x1 = exp(1.133556) = 3.106685

2.3. Estimating predicted probabilities after logit

First, we will estimate the probability that the outcome variable (Y) = 1, given that all predictors are set to their mean values.

To get the data. Type: 

use "https://dss.princeton.edu/training/logit.dta", clear

To get the predicted probability, type:

quietly logit y_bin x1 x2 x3 i.opinion
margins, atmeans post

Stata will give us the following output table.

. quietly logit y_bin x1 x2 x3 i.opinion
. margins, atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(y_bin), predict()
at           : x1              =    .6480006 (mean)
               x2              =    .1338694 (mean)
               x3              =     .761851 (mean)
               1.opinion       =    .2857143 (mean)
               2.opinion       =    .2142857 (mean)
               3.opinion       =    .2714286 (mean)
               4.opinion       =    .2285714 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   .8575618   .0512873    16.72   0.000     .7570405    .9580832
------------------------------------------------------------------------------

 

Interpretation:

The probability of y_bin = 1 is 85%, given that all predictors are set to their mean values.

 

Second, we will estimate the probability that the outcome variable (Y) = 1, setting a predictor to a specific value (x2 = 3)

To get the data. Type: 

use "https://dss.princeton.edu/training/logit.dta", clear

To get the predicted probability, type:

quietly logit y_bin x1 x2 x3 i.opinion
margins, at(x2=3) atmeans post

Stata will give us the following output table.

. use "https://dss.princeton.edu/training/logit.dta", clear
. quietly logit y_bin x1 x2 x3 i.opinion
. margins, at(x2=3) atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(y_bin), predict()
at           : x1              =    .6480006 (mean)
               x2              =           3
               x3              =     .761851 (mean)
               1.opinion       =    .2857143 (mean)
               2.opinion       =    .2142857 (mean)
               3.opinion       =    .2714286 (mean)
               4.opinion       =    .2285714 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   .9346922   .0732788    12.76   0.000     .7910683    1.078316
------------------------------------------------------------------------------

Interpretation:

The probability of y_bin = 1 is 93%, given that x2 = 3 and the rest of the predictors are set to their mean values.

 

Third, we will estimate the probability that the outcome variable (Y) = 1, setting specific values for a couple of predictors  (i.e., x2 = 3 and x3 = 5)

To get the data. Type: 

use "https://dss.princeton.edu/training/logit.dta", clear

To get the predicted probability, type:

quietly logit y_bin x1 x2 x3 i.opinion
margins, at(x2=3 x3=5) atmeans post

Stata will give us the following output table.

. use "https://dss.princeton.edu/training/logit.dta", clear
. quietly logit y_bin x1 x2 x3 i.opinion
. margins, at(x2=3 x3=5) atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(y_bin), predict()
at           : x1              =    .6480006 (mean)
               x2              =           3
               x3              =           5
               1.opinion       =    .2857143 (mean)
               2.opinion       =    .2142857 (mean)
               3.opinion       =    .2714286 (mean)
               4.opinion       =    .2285714 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   .9872112   .0357288    27.63   0.000      .917184    1.057238
------------------------------------------------------------------------------

Interpretation:

The probability of y_bin = 1 is 99% given that x2 = 3, x3 = 5, and the rest of the predictors are set to their mean values.

 

Fourth, we will estimate the probability that the outcome variable (Y) = 1, setting specific values for multiple predictors   (i.e., x2 = 3, x3 = 5, and opinion=(1 2))

To get the data. Type: 

use "https://dss.princeton.edu/training/logit.dta", clear

To get the predicted probability, type:

quietly logit y_bin x1 x2 x3 i.opinion
margins, at(x2=3 x3=5 opinion=(1 2)) atmeans post

Stata will give us the following output table.

. use "https://dss.princeton.edu/training/logit.dta", clear
. quietly logit y_bin x1 x2 x3 i.opinion
. margins, at(x2=3 x3=5 opinion=(1 2)) atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(y_bin), predict()
1._at        : x1              =    .6480006 (mean)
               x2              =           3
               x3              =           5
               opinion         =           1
2._at        : x1              =    .6480006 (mean)
               x2              =           3
               x3              =           5
               opinion         =           2
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   .9891283   .0305393    32.39   0.000     .9292724    1.048984
          2  |   .9304941   .1915434     4.86   0.000     .5550758    1.305912
------------------------------------------------------------------------------

 

Interpretation:

1. The probability of y_bin = 1 is 98% given that x2 = 3, x3 = 5, the opinion is “strongly agree”, and the rest of the predictors are set to their mean values.

2. The probability of y_bin = 1 is 93% given that x2 = 3, x3 = 5, the opinion is “agree”,  and the rest of the predictors are set to their mean values.

 

Fifth, we will estimate the probability that the outcome variable (Y) = 1 for each category of the categorical variable  ( i.e., opinion)

To get the data. Type: 

use "https://dss.princeton.edu/training/logit.dta", clear

To get the predicted probability, type:

quietly logit y_bin x1 x2 x3 i.opinion
margins opinion, atmeans post

Stata will give us the following output table.

. use "https://dss.princeton.edu/training/logit.dta", clear
. quietly logit y_bin x1 x2 x3 i.opinion
. margins opinion, atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(y_bin), predict()
at           : x1              =    .6480006 (mean)
               x2              =    .1338694 (mean)
               x3              =     .761851 (mean)
               1.opinion       =    .2857143 (mean)
               2.opinion       =    .2142857 (mean)
               3.opinion       =    .2714286 (mean)
               4.opinion       =    .2285714 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     opinion |
  Str agree  |   .8764826   .0739471    11.85   0.000      .731549    1.021416
      Agree  |   .5107928   .1509988     3.38   0.001     .2148405    .8067451
      Disag  |    .907761   .0673524    13.48   0.000     .7757527    1.039769
  Str disag  |    .933931   .0644709    14.49   0.000     .8075704    1.060292
------------------------------------------------------------------------------

 

Interpretation:

- Holding all variables at their mean values. The probability of y_bin = 1 is:

• 87% among those who “strongly agree”,

• 51% among those who “agree”,

• 91% among those who “disagree” and

• 93% among those who “strongly disagree”

- We can show the above predictions with the help of a graph. To do this, type:  

marginsplot

The command will produce the graph below

2.4.Estimating marginal effects after logit

Marginal effects show the change in probability when the predictor or independent variable increases by one unit. For continuous variables, this represents the instantaneous change, given that the ‘unit’ may be very small. For binary variables, the change is from 0 to 1, so one ‘unit’ is as it is usually thought.

To calculate marginal effects after logit, type:

use "https://dss.princeton.edu/training/logit.dta", clear

quietly logit y_bin x1 x2 x3 i.opinion

margins, dydx(*) atmeans post

Stata will give us the following output table.

. margins, dydx(*) atmeans post
Conditional marginal effects                    Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(y_bin), predict()
dy/dx w.r.t. : x1 x2 x3 2.opinion 3.opinion 4.opinion
at           : x1              =    .6480006 (mean)
               x2              =    .1338694 (mean)
               x3              =     .761851 (mean)
               1.opinion       =    .2857143 (mean)
               2.opinion       =    .2142857 (mean)
               3.opinion       =    .2714286 (mean)
               4.opinion       =    .2285714 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |   .1384634   .1093955     1.27   0.206    -.0759478    .3528746
          x2 |    .036904   .0421082     0.88   0.381    -.0456266    .1194346
          x3 |     .04857   .0548416     0.89   0.376    -.0589176    .1560577
             |
     opinion |
      Agree  |  -.3656898   .1670551    -2.19   0.029    -.6931118   -.0382678
      Disag  |   .0312784   .0945857     0.33   0.741    -.1541062    .2166629
  Str disag  |   .0574484    .098205     0.58   0.559    -.1350299    .2499268
------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.

Interpretation of the numbers in dy/dx column :

x1 = .1384634  The change in probability for one instant change in x1 is 13 percentage points (pp). However, the change is not statistically significant because the p-value is not <0.05.

x2 = .036904 The change in probability for one instant change in x2 is 3 percentage points (pp). However, the change is not statistically significant because the p-value is not <0.05.

Agree = -.3656898 The change in probability when opinion goes from ‘strongly agree’ to ‘agree’ decreases by 36 percentage points or -0.36. This change is statistically significant because the p-value is 0.029 which is  <0.05. 

Disag = .0312784 The change in probability when opinion goes from ‘strongly agree’ to ‘disagree’ increases by 3 percentage points or 0.03. However, the change is not statistically significant because the p-value is not <0.05.

Str Disag = .0574484 The change in probability when opinion goes from ‘strongly agree’ to ‘strongly disagree’ increases by 5 percentage points or 0.05. However, the change is not statistically significant because the p-value is not <0.05.


We can publish the above results in a Word document by using outreg2 command. To do this, type:

use "https://dss.princeton.edu/training/logit.dta", clear

quietly logit y_bin x1 x2 x3 i.opinion

margins, dydx(*) atmeans post

outreg2 using test.doc, word replace ctitle(Marginal effects)

Stata will give us the following outputs 

. outreg2 using test.doc, word replace ctitle(Marginal effects)
test.doc
dir : seeout

- Windows users: click on test.doc to open the file in Word (you can replace this name with your own). 

- Mac users: click on dir to go to the directory where test.doc is saved, and open it with Word (you can replace this name with your own)

The outputs in the Word document look as follows.

3. Estimating the Ordered Logit Model using Stata

As discussed earlier, we should use the ordered logit model when the dependent variable is categorical but ordered (e.g., low to high).

3.1. Estimating log-odds ratio

To get the data. Type:

use "https://dss.princeton.edu/training/ologit.dta"

Before running the regression, let's check the nature of the dependent variable first. Type:

tab opinion_or
tab opinion_or, nolab

Stat will give us the following tables.

. tab opinion_or
    Outcome |
   variable |      Freq.     Percent        Cum.
------------+-----------------------------------
  Str disag |         16       22.86       22.86
      Disag |         19       27.14       50.00
      Agree |         15       21.43       71.43
  Str agree |         20       28.57      100.00
------------+-----------------------------------
      Total |         70      100.00
. tab opinion_or, nolab
    Outcome |
   variable |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         16       22.86       22.86
          2 |         19       27.14       50.00
          3 |         15       21.43       71.43
          4 |         20       28.57      100.00
------------+-----------------------------------
      Total |         70      100.00

 

To run an ordered logit model, type:

ologit opinion_or x1 x2 x3 i.gender

Where opinion_or is the dependent variable, and x1 x2 x3 gender are independent variables. gender is a dummy variable defined by assigning 0 for female and 1 for male. 

Stata will give us the following output table.

. ologit opinion_or x1 x2 x3 i.gender
Iteration 0:   log likelihood = -96.553508  
Iteration 1:   log likelihood = -94.247232  
Iteration 2:   log likelihood = -94.239474  
Iteration 3:   log likelihood = -94.239472  
Ordered logistic regression                     Number of obs     =         70
                                                LR chi2(4)        =       4.63
                                                Prob > chi2       =     0.3276
Log likelihood = -94.239472                     Pseudo R2         =     0.0240
------------------------------------------------------------------------------
  opinion_or |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |   -.946804   .5639295    -1.68   0.093    -2.052086    .1584776
          x2 |  -.2233003   .2099466    -1.06   0.288    -.6347881    .1881875
          x3 |  -.0579506   .1580635    -0.37   0.714    -.3677493    .2518481
             |
      gender |
       male  |  -.5636039    .524222    -1.08   0.282     -1.59106    .4638524
-------------+----------------------------------------------------------------
       /cut1 |  -2.401919   .6513011                     -3.678446   -1.125392
       /cut2 |  -1.108298   .5878275                     -2.260419    .0438225
       /cut3 |  -.1540898   .5775204                     -1.286009    .9778293
------------------------------------------------------------------------------

Interpretation

  • LR chi2(4)= 4.63 and Prob > chi2 = 0.3276. The likelihood ratio chi-square of 4.63 with a p-value of 0.33 indicates that our model as a whole is not statistically significant. To be statistically significant, we need a p-value  <0.05. 
  • x1 = -.946804 indicates that when x1 increases by one unit, the expected change in the log-odds of being in a higher level of opinion_or  is - 0.95 (a decrease), holding all other variables in the model constant. This decrease is not statistically significant at the 5% level because the p-value is not < 0.05 (however, the drop is statistically significant at the 10% level as the p-value is < 0.10). 
  • male = -.5636039 indicates that when gender increases by one unit (i.e., goes from 0 (female) to 1(male)), the expected change in the log-odds of being in a higher level of opinion_or  is - 0.56, holding all other variables in the model constant. However, this decrease is not statistically significant because the p-value is not < 0.05.

Note: The log-odds in the above output table mainly help us to understand the direction of the relationship between the dependent and independent variable; for more comprehensive interpretations of the ordered logit outcomes, see the following sub-sections (3.2, 3.3. and 3.4.).

3.2. Estimating the odds ratio

The odds ratio allows an easier interpretation of the ordered logit coefficients. They are the exponentiated value of the ordered logit coefficients. We can get the odds ratio by using the following procedure. 

To get the data. Type: (You don't need to get data again if you already estimated log-odds following the instruction in section 3.1.)

use "https://dss.princeton.edu/training/ologit.dta", clear

To get odds ratio rather than ordered logit coefficients, type:

ologit opinion_or x1 x2 x3 i.gender, or

Where opinion_or is the dependent variable, and x1 x2 x3 gender are independent variables. gender is a dummy variable defined by assigning 0 for female and 1 for male. 

Note: We added or at the end of the command to get the odds ratio. 

Stata will give us the following output table.

. ologit opinion_or x1 x2 x3 i.gender, or
Iteration 0:   log likelihood = -96.553508  
Iteration 1:   log likelihood = -94.247232  
Iteration 2:   log likelihood = -94.239474  
Iteration 3:   log likelihood = -94.239472  
Ordered logistic regression                     Number of obs     =         70
                                                LR chi2(4)        =       4.63
                                                Prob > chi2       =     0.3276
Log likelihood = -94.239472                     Pseudo R2         =     0.0240
------------------------------------------------------------------------------
  opinion_or | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |    .387979   .2187928    -1.68   0.093     .1284667    1.171726
          x2 |   .7998746    .167931    -1.06   0.288     .5300478     1.20706
          x3 |   .9436966   .1491639    -0.37   0.714     .6922907    1.286401
             |
      gender |
       male  |   .5691542   .2983632    -1.08   0.282     .2037095    1.590188
-------------+----------------------------------------------------------------
       /cut1 |  -2.401919   .6513011                     -3.678446   -1.125392
       /cut2 |  -1.108298   .5878275                     -2.260419    .0438225
       /cut3 |  -.1540898   .5775204                     -1.286009    .9778293
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.

Interpretation

  • Odds Ratio: They represent the odds of Y=1 when X increases by 1 unit. These are the exp(logit coeff). 

If the OR > 1 then the odds of Y=1 increases

If the OR < 1 then the odds of Y=1 decreases

  • Let's interpret the odds ratio for x1 which is .387979.

It indicates, keeping all other variables constant, when x1 increases by one unit, the odds of moving to a higher category in the outcome variable decrease by 61%. However, this decrease is not statistically significant as the p-value is not < 0.05. We get this 61% as follows: (.387979 - 1) * 100 = - 61.2021.

Or, we can also say for a one-unit increase in x1, the odds of the high category of opinion_or versus the combined other categories of opinion_or are 0.39 times greater, given that all other variables in the model are constant. 

Note: To calculate the odds ratio by hand, you need to exponentiate the ordered logit coefficient. The formula is:

odds ratio = exp(coef(ordered logit))

In section 3.1., we got logit coefficient for x1 = -.946804. Therefore, the odds ratio for x1 = exp(-.946804) = 0.387979.

3.3. Estimating predicted probabilities after ordered logit

As we discussed earlier, in an ordinal logit model, the outcome (dependent) variable has categories in a meaningful order. In our example, the variable opinion_or has four categories: 1, "Strongly disagree", 2, "Disagree", 3 "Agree",  and  4 "Strongly agree". 

First, we will estimate the probability of the outcome variable for different values of opinion_or, given that all predictors are set to their mean values.

Case 1:  opinion_or = 1 ( "Strongly disagree")

Run the following Stata codes:

use "https://dss.princeton.edu/training/ologit.dta", clear
ologit opinion_or x1 x2 x3 i.gender
margins, predict(outcome(1)) atmeans post

Stata will give us the following outputs.

. margins, predict(outcome(1)) atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(opinion_or==1), predict(outcome(1))
at           : x1              =    .6480006 (mean)
               x2              =    .1338694 (mean)
               x3              =     .761851 (mean)
               0.gender        =          .2 (mean)
               1.gender        =          .8 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   .2203782   .0501331     4.40   0.000     .1221192    .3186373
------------------------------------------------------------------------------

 

Interpretation

_cons =.2203782 indicates that the probability of opinion_or = 1 ("Strongly disagree") given that all predictors are set to their mean values is 22%.

Case 2:  opinion_or = 2 ("Disagree")

we can estimate the probability of the outcome variable when opinion_or = 2, given that all predictors are set to their mean values.

Run the following Stata codes:

use "https://dss.princeton.edu/training/ologit.dta", clear
ologit opinion_or x1 x2 x3 i.gender
margins, predict(outcome(2)) atmeans post

Stata will give us the following outputs.

. margins, predict(outcome(2)) atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(opinion_or==2), predict(outcome(2))
at           : x1              =    .6480006 (mean)
               x2              =    .1338694 (mean)
               x3              =     .761851 (mean)
               0.gender        =          .2 (mean)
               1.gender        =          .8 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   .2871605   .0563818     5.09   0.000     .1766542    .3976668
------------------------------------------------------------------------------

 

Interpretation

_cons =.2871605 indicates that the probability of opinion_or = 2 ("Disagree"), given that all predictors are set to their mean values, is 28%.

Case 3:  opinion_or = 3 ( "Agree")

we can estimate the probability of the outcome variable when opinion_or = 3, given that all predictors are set to their mean values.

Run the following Stata codes:

use "https://dss.princeton.edu/training/ologit.dta", clear
ologit opinion_or x1 x2 x3 i.gender
margins, predict(outcome(3)) atmeans post

Stata will give us the following outputs.

. margins, predict(outcome(3)) atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(opinion_or==3), predict(outcome(3))
at           : x1              =    .6480006 (mean)
               x2              =    .1338694 (mean)
               x3              =     .761851 (mean)
               0.gender        =          .2 (mean)
               1.gender        =          .8 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   .2204349   .0505508     4.36   0.000     .1213571    .3195126
------------------------------------------------------------------------------

Interpretation

_cons =.2204349 indicates that the probability of opinion_or = 3 ("Agree"), given that all predictors are set to their mean values, is 22%.

Case 4:  opinion_or = 4 ( "Strongly agree")

we can estimate the probability of the outcome variable when opinion_or = 4, given that all predictors are set to their mean values.

Run the following Stata codes:

use "https://dss.princeton.edu/training/ologit.dta", clear
ologit opinion_or x1 x2 x3 i.gender
margins, predict(outcome(4)) atmeans post

Stata will give us the following outputs.

. margins, predict(outcome(4)) atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(opinion_or==4), predict(outcome(4))
at           : x1              =    .6480006 (mean)
               x2              =    .1338694 (mean)
               x3              =     .761851 (mean)
               0.gender        =          .2 (mean)
               1.gender        =          .8 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   .2720264   .0540224     5.04   0.000     .1661444    .3779084
------------------------------------------------------------------------------

Interpretation

_cons =.2720264 indicates that the probability of opinion_or = 3 ("Strongly agree"), given that all predictors are set to their mean values, is 27%.

Second, we will estimate the probability of the outcome variable for different values of opinion_orsetting predictors to specific values.

Case 1:  opinion_or = 1 ( "Strongly disagree"), x3=5, and the other variables are at their mean values.

Run the following Stata codes:

use "https://dss.princeton.edu/training/ologit.dta", clear
ologit opinion_or x1 x2 x3 i.gender
margins, predict(outcome(1)) at(x3=5) atmeans post

Stata will give us the following outputs.

. margins, predict(outcome(1)) at(x3=5) atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(opinion_or==1), predict(outcome(1))
at           : x1              =    .6480006 (mean)
               x2              =    .1338694 (mean)
               x3              =           5
               0.gender        =          .2 (mean)
               1.gender        =          .8 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   .2654444   .1388834     1.91   0.056    -.0067621    .5376509
------------------------------------------------------------------------------

Interpretation

_cons =.2654444 indicates that the probability of opinion = 1, given x3=5, and the rest of the variables are at their mean values is 26.5%.

Case 2:  opinion_or = 2 ( "disagree"), x3=5, and the other variables are at their mean values.

Run the following Stata codes:

use "https://dss.princeton.edu/training/ologit.dta", clear
ologit opinion_or x1 x2 x3 i.gender
margins, predict(outcome(2)) at(x3=5) atmeans post

Stata will give us the following outputs

. margins, predict(outcome(2)) at(x3=5) atmeans post
Adjusted predictions                            Number of obs     =         70
Model VCE    : OIM
Expression   : Pr(opinion_or==2), predict(outcome(2))
at           : x1              =    .6480006 (mean)
               x2              =    .1338694 (mean)
               x3              =           5
               0.gender        =          .2 (mean)
               1.gender        =          .8 (mean)
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   .3030621   .0687894     4.41   0.000     .1682375    .4378868
------------------------------------------------------------------------------

Interpretation

_cons =.3030621 indicates that the probability of opinion = 2, given x3=5, and the rest of the variables are at their mean values, is 30%.

Do Case 3 and Case 4 by yourself. 

3.4.Estimating marginal effects after ordered logit

Marginal effects show the change in probability when the predictor or independent variable increases by one unit. For continuous variables, this represents the instantaneous change, given that the ‘unit’ may be very small. For binary variables, the change is from 0 to 1, so one ‘unit’ is as it is usually thought.

To calculate marginal effects after ordered logit with respect to the independent variable x1, type:

use "https://dss.princeton.edu/training/ologit.dta", clear

ologit opinion_or x1 x2 x3 i.gender

margins, dydx(x1)

Stata will give us the following output table.

. margins, dydx(x1)
Average marginal effects                        Number of obs     =         70
Model VCE    : OIM
dy/dx w.r.t. : x1
1._predict   : Pr(opinion_or==1), predict(pr outcome(1))
2._predict   : Pr(opinion_or==2), predict(pr outcome(2))
3._predict   : Pr(opinion_or==3), predict(pr outcome(3))
4._predict   : Pr(opinion_or==4), predict(pr outcome(4))
------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
x1           |
    _predict |
          1  |   .1620537   .0962109     1.68   0.092    -.0265162    .3506236
          2  |   .0625812   .0402706     1.55   0.120    -.0163477    .1415101
          3  |  -.0417126   .0283309    -1.47   0.141    -.0972401    .0138148
          4  |  -.1829222   .1065133    -1.72   0.086    -.3916845      .02584
------------------------------------------------------------------------------

Interpretation 

The marginal effects indicate that for one instant change in x1, it is 16 percentage points more likely to strongly disagree, 6 percentage points more likely to disagree, 4 percentage points less likely to agree, and 18 percentage points less likely to strongly agree. 

 

To calculate marginal effects after ordered logit with respect to the categorical independent variable gender, type:

margins, dydx(gender)

Stata will give us the following output table.

. margins, dydx(gender)
Average marginal effects                        Number of obs     =         70
Model VCE    : OIM
dy/dx w.r.t. : 1.gender
1._predict   : Pr(opinion_or==1), predict(pr outcome(1))
2._predict   : Pr(opinion_or==2), predict(pr outcome(2))
3._predict   : Pr(opinion_or==3), predict(pr outcome(3))
4._predict   : Pr(opinion_or==4), predict(pr outcome(4))
------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
0.gender     |  (base outcome)
-------------+----------------------------------------------------------------
1.gender     |
    _predict |
          1  |   .0880757   .0750215     1.17   0.240    -.0589637    .2351151
          2  |   .0466492   .0515201     0.91   0.365    -.0543283    .1476267
          3  |  -.0179264   .0161309    -1.11   0.266    -.0495423    .0136896
          4  |  -.1167985   .1133705    -1.03   0.303    -.3390007    .1054037
------------------------------------------------------------------------------

Interpretation 

The marginal effects indicate that, on average, males are 8.8 percentage points more likely than females to say strongly disagree, 4.6 percentage points more likely to say disagree, 1.8 percentage points less likely to say agree, and about 12 percentage points less likely to say strongly agree.

4. Estimating the Multinomial Logit Model using Stata

As discussed earlier, we should use the multinomial logit model when the dependent variable is categorical but without any particular order.

4.1. Estimating log-odds ratio

To get the data. Type:

use "https://dss.princeton.edu/training/mlogit.dta"

Before running the regression, let's check the nature of the dependent variable first. Type:

tab opinion_ml
tab opinion_ml, nolab

Stat will give us the following tables.

. tab opinion_ml
    Outcome |
   variable |      Freq.     Percent        Cum.
------------+-----------------------------------
  Democrats |         36       51.43       51.43
Independent |         15       21.43       72.86
Republicans |         19       27.14      100.00
------------+-----------------------------------
      Total |         70      100.00
. tab opinion_ml, nolab
    Outcome |
   variable |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         36       51.43       51.43
          2 |         15       21.43       72.86
          3 |         19       27.14      100.00
------------+-----------------------------------
      Total |         70      100.00

To run a multinomial logit model, type:

mlogit opinion_ml x1 x2 x3 i.gender

Where opinion_ml is the dependent variable, and x1 x2 x3 gender are independent variables. gender is a dummy variable defined by assigning 0 for female and 1 for male. 

Stata will give us the following output table.

. mlogit opinion_ml x1 x2 x3 i.gender
Iteration 0:   log likelihood = -71.822892  
Iteration 1:   log likelihood = -63.254631  
Iteration 2:   log likelihood = -61.738873  
Iteration 3:   log likelihood =  -61.59156  
Iteration 4:   log likelihood = -61.591121  
Iteration 5:   log likelihood = -61.591121  
Multinomial logistic regression                 Number of obs     =         70
                                                LR chi2(8)        =      20.46
                                                Prob > chi2       =     0.0087
Log likelihood = -61.591121                     Pseudo R2         =     0.1425
------------------------------------------------------------------------------
  opinion_ml |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Democrats    |  (base outcome)
-------------+----------------------------------------------------------------
Independent  |
          x1 |   .5438799   .9719664     0.56   0.576    -1.361139    2.448899
          x2 |  -.2741146   .3610776    -0.76   0.448    -.9818137    .4335846
          x3 |  -1.036186   .5886012    -1.76   0.078    -2.189823    .1174509
             |
      gender |
       male  |  -2.255614   .8000494    -2.82   0.005    -3.823682   -.6875462
       _cons |   .7328207   .8913779     0.82   0.411    -1.014248    2.479889
-------------+----------------------------------------------------------------
Republicans  |
          x1 |  -.3814889   .7140076    -0.53   0.593    -1.780918     1.01794
          x2 |  -.0402157   .2757943    -0.15   0.884    -.5807626    .5003313
          x3 |   .2691887   .2230701     1.21   0.228    -.1680206    .7063981
             |
      gender |
       male  |  -.0693857    .935593    -0.07   0.941    -1.903114    1.764343
       _cons |  -.6036808   .9478304    -0.64   0.524    -2.461394    1.254033
------------------------------------------------------------------------------

 

Interpretation

LR chi2(8)20.46 and Prob > chi2 = 0.0087The likelihood ratio chi-square of 20.46 with a p-value of 0.009 indicates that our model as a whole is statistically significant. 

Notice that the above output table has two parts, and they are labeled with the categories of the outcome variable opinion_ml. When we explain the coefficients, we will explain them from the perspective of both categories. Remember that our benchmark category is  Democrats

  • The .5438799 coefficient of x1 under Independent category suggests that for one unit increase in x1, the logit coefficient for Independent relative to Democrats will increase by that amount, 0.54. In other words, if  x1 increases by one unit, the chances for voting for an independent candidate are higher compared to voting for a Democrat candidate. Note that the coefficient is not statistically significant as the p-value is not < 0.05. 
  • The -.3814889 coefficient of x1 under Republicans category suggests that for one unit increase in x1, the logit coefficient for Republicans relative to Democrats will decrease by that amount, 0.38. In other words, if  x1 increases by one unit, the chances for voting for a Republican candidate are lower compared to voting for a Democrat candidate. Note that the coefficient is not statistically significant as the p-value is not < 0.05. 
  • The -2.255614 coefficient of male under Independent category suggests that when gender increases by one unit (i.e., goes from 0 (female) to 1(male)), the expected change in the log-odds of voting an independent candidate will decrease by 2.3 than voting a democrat, holding all other variables in the model constant. Note that this decrease is statistically significant because the p-value is < 0.05. 

4.2. Estimating relative risk ratios

Relative risk ratios allow an easier interpretation of the multinomial logit coefficients. They are the exponentiated value of the logit coefficients.

To get the data. Type: (You don't need to get data again if you already estimated log-odds following the instruction in section 4.1.)

use "https://dss.princeton.edu/training/mlogit.dta", clear

To get odds ratio rather than multinomial logit coefficients, type:

mlogit opinion_ml x1 x2 x3 i.gender, rrr

Note: We added rrr at the end of the command to get the odds ratio. 

Stata will give us the following output table.

. mlogit opinion_ml x1 x2 x3 i.gender, rrr
Iteration 0:   log likelihood = -71.822892  
Iteration 1:   log likelihood = -63.254631  
Iteration 2:   log likelihood = -61.738873  
Iteration 3:   log likelihood =  -61.59156  
Iteration 4:   log likelihood = -61.591121  
Iteration 5:   log likelihood = -61.591121  
Multinomial logistic regression                 Number of obs     =         70
                                                LR chi2(8)        =      20.46
                                                Prob > chi2       =     0.0087
Log likelihood = -61.591121                     Pseudo R2         =     0.1425
------------------------------------------------------------------------------
  opinion_ml |        RRR   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Democrats    |  (base outcome)
-------------+----------------------------------------------------------------
Independent  |
          x1 |   1.722678   1.674385     0.56   0.576     .2563685    11.57559
          x2 |   .7602449   .2745074    -0.76   0.448      .374631    1.542778
          x3 |   .3548052   .2088388    -1.76   0.078     .1119365    1.124626
             |
      gender |
       male  |   .1048092   .0838525    -2.82   0.005     .0218472    .5028083
       _cons |   2.080942   1.854906     0.82   0.411     .3626751    11.93994
-------------+----------------------------------------------------------------
Republicans  |
          x1 |    .682844   .4875558    -0.53   0.593     .1684834    2.767488
          x2 |   .9605822   .2649231    -0.15   0.884     .5594715    1.649268
          x3 |   1.308902   .2919769     1.21   0.228     .8453365    2.026678
             |
      gender |
       male  |   .9329667   .8728772    -0.07   0.941     .1491035    5.837735
       _cons |   .5467953   .5182692    -0.64   0.524     .0853159    3.504446
------------------------------------------------------------------------------
Note: _cons estimates baseline relative risk for each outcome.

Interpretation:

  • Keeping all other variables constant, if your x1 increases by one unit, you are 1.72 times more likely to vote for an independent candidate as compared to the benchmark category Democrats (the risk or odds is (1.722678 - 1) * 100 = 72% higher). The coefficient, however, is not significant.

  • Keeping all other variables constant, if your x1 increases by one unit, you are .68 times more likely to vote for a Republican candidate as compared to voting for a Democrat (the risk or odds is (.682844 - 1) * 100 = 32% lower). The coefficient, however, is not significant.

Note: To calculate the relative risk ratio by hand, you need to exponentiate the multinomial logit coefficient. The formula is:

 relative risk ratio = exp(coef(logit))

In section 4.1., we got the multinomial logit coefficient for x1 = .5438799. Therefore, the relative risk ratio for x1 = exp(.5438799 ) = 1.7226

References / Useful Resources

Adjusted Predictions & Marginal Effects for Multiple Outcome Models & Commands (including ologit, mlogit, oglm, & gologit2) / Richard Williams, University of Notre Dame, 2021. Available at https://www3.nd.edu/~rwilliam/stats3/Margins05.pdf
 
Applied Regression Analysis and Generalized Linear Models / John Fox, Sage, 2008.
 
Data analysis using regression and multilevel/hierarchical models / Andrew Gelman, Jennifer Hill. Cambridge ; New York : Cambridge University Press, 2007.
 
DSS Data Analysis Guides. Available at https://library.princeton.edu/dss/training
 
Econometric analysis / William H. Greene. 8th ed., Upper Saddle River, N.J. : Prentice Hall, 2018.
 
Introduction to econometrics / James H. Stock, Mark W. Watson. 4th ed., Boston: Pearson Addison Wesley, 2019.
 
UCLA, Stata Data Analysis Example. Multinomial Logistic Regression. Available at https://stats.oarc.ucla.edu/stata/dae/multinomiallogistic-regression/
 
UCLA, Stata Data Analysis Example. Ordered Logistic Regression. Available at https://stats.oarc.ucla.edu/stata/dae/ordered-logistic-regression/

Data Consultant

Profile Photo
Muhammad Al Amin
He/Him/His
Contact:
Firestone Library, A-12-F.1
609-258-6051

Data Consultant

Profile Photo
Yufei Qin
Contact:
Firestone Library, A.12F.2
6092582519

Comments or Questions?

If you have questions or comments about this guide or method, please email data@Princeton.edu.