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:
Both models provide similar results.
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’
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’
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.
Interpretation
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.
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.
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
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:
Stata will give us the following output table.
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:
Stata will give us the following output table.
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:
Stata will give us the following output table.
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:
Stata will give us the following output table.
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:
Stata will give us the following output table.
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
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.
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.
As discussed earlier, we should use the ordered logit model when the dependent variable is categorical but ordered (e.g., low to high).
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.
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.
Interpretation
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.).
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.
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:
In section 3.1., we got logit coefficient for x1 = -.946804. Therefore, the odds ratio for x1 = exp(-.946804) = 0.387979.
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.
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.
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.
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.
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_or, setting 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.
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
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.
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.
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.
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.
As discussed earlier, we should use the multinomial logit model when the dependent variable is categorical but without any particular order.
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.
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.
Interpretation
LR chi2(8)= 20.46 and Prob > chi2 = 0.0087. The 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
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.
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
If you have questions or comments about this guide or method, please email data@Princeton.edu.