Sub topic 13
When the dependent variable is categorical: logit and probit
This chapter assumes you can read multiple regression output, know what a dummy variable is, and understand t-tests and p-values. It covers what to do when the thing you want to explain is a yes/no outcome instead of a number.
Why a linear regression fails for a yes/no outcome
Suppose you want to explain whether a firm defaults on its debt within a year. The dependent variable is a qualitative (categorical) variable. It takes the value 1 if the firm defaults and 0 if it does not. Earlier in this tutorial, dummy variables appeared on the right-hand side of the equation. Here the dummy moves to the left-hand side.
You can still run OLS on a 0/1 dependent variable. The result is called a linear probability model (LPM):
Y = b0 + b1 X1 + b2 X2 + ... + bk Xk + error
The fitted value is read as the estimated probability that Y = 1. The LPM has three problems.
- Predictions outside 0 to 1. A straight line has no ceiling or floor. For extreme values of the X variables, the fitted "probability" can be negative or larger than 1.
- Heteroskedasticity by construction. Y can only be 0 or 1, so the error variance depends on the predicted probability. It is largest near 0.5 and shrinks near 0 or 1. The constant-variance assumption fails, and ordinary standard errors are unreliable.
- A constant marginal effect. The LPM says one more unit of X always changes the probability by the same amount. Real probabilities flatten out as they approach 0 or 1.
Logit and probit models fix these problems by passing the linear combination of the X variables through an S-shaped function that stays between 0 and 1.
The logit and probit models
Define the linear index as:
z = b0 + b1 X1 + ... + bk Xk
Both models set P(Y = 1) = F(z), where F is a cumulative distribution function. The two models differ only in the choice of F.
| Feature | Logit | Probit |
|---|---|---|
| Function F(z) | Logistic distribution: 1 / (1 + e^(-z)) | Standard normal cumulative distribution N(z) |
| Output range | Strictly between 0 and 1 | Strictly between 0 and 1 |
| Tails | Slightly heavier | Slightly lighter |
| Coefficient scale | Larger in magnitude, roughly 1.6 to 1.8 times the probit value | Smaller in magnitude |
| Estimation | Maximum likelihood | Maximum likelihood |
The two curves look almost identical in the middle and differ only a little in the tails. In practice, the choice rarely changes conclusions. Pick whichever your field or software defaults to.
Estimation: maximum likelihood, not OLS
Logit and probit models are not estimated by minimizing squared errors. They use maximum likelihood estimation (MLE). MLE searches for the coefficient values that make the observed pattern of 0s and 1s most probable. There is no closed-form formula, so software iterates until the likelihood stops improving.
Two consequences matter for the exam.
- R-squared is not defined in the usual way. There is no sum of squared errors to explain. Software reports a pseudo R-squared, such as McFadden's, which compares the fitted model's log likelihood with that of a model with only an intercept. Do not interpret it as "percent of variance explained."
- Coefficient tests use z-statistics. Each coefficient is tested against zero, and the output usually reports a z-statistic (or Wald statistic) instead of a t-statistic. The decision rule is the same: reject the null that the coefficient is zero when the p-value is below the significance level. To test several coefficients jointly, use a likelihood ratio (LR) test, which is the MLE counterpart of the F-test.
Interpreting the coefficients
This is the most commonly tested point. In logit and probit, a coefficient is not the change in probability per unit of X.
The sign tells you the direction. A positive coefficient means a higher X raises the probability that Y = 1. The size of the coefficient does not directly give the change in probability, because the effect depends on where you are on the S-curve. The same one-unit change in X moves the probability a lot near 0.5 and very little near 0 or 1.
Logit has an extra interpretation through odds. The odds of an event are P / (1 - P). The logit model is linear in the log odds:
ln[P / (1 - P)] = b0 + b1 X1 + ... + bk Xk
So b1 is the change in the log odds for a one-unit increase in X1, holding the other variables constant. Exponentiating gives the odds ratio, e^b1, which is the factor by which the odds are multiplied.
Worked example
A model of loan default uses X1 = debt-to-income ratio, in percentage points. Suppose the estimated logit is:
ln[P / (1 - P)] = -4.0 + 0.10 X1
- For a borrower with X1 = 30: z = -4.0 + 0.10 × 30 = -1.0. The odds are e^(-1.0) = 0.368, so P = 0.368 / 1.368 = 0.269, about 26.9%.
- For X1 = 40: z = 0.0. The odds are 1, so P = 0.50.
- For X1 = 50: z = 1.0. The odds are e^1.0 = 2.718, so P = 2.718 / 3.718 = 0.731.
The odds ratio is e^0.10 = 1.105. Each extra percentage point of debt-to-income multiplies the odds of default by about 1.105. Yet the change in probability differs by position. Moving from 30 to 40 raises P by 23.1 percentage points (0.269 to 0.500). Moving from 40 to 50 raises it by 23.1 points too in this symmetric case, but moving from 60 (z = 2, P = 0.881) to 70 (z = 3, P = 0.953) raises it by only 7.2 points.
You can verify the arithmetic with code.
import math
def logit_prob(z):
return 1.0 / (1.0 + math.exp(-z))
b0, b1 = -4.0, 0.10
for dti in (30, 40, 50, 60, 70):
z = b0 + b1 * dti
print(dti, round(z, 2), round(logit_prob(z), 3))
print("odds ratio:", round(math.exp(b1), 3))The output shows probabilities of 0.269, 0.5, 0.731, 0.881 and 0.953, and an odds ratio of 1.105. The slope of the probability curve flattens at the extremes, which a linear model cannot reproduce.
Fitting a logit and a probit in Python
The next example simulates data from a known logistic relationship, fits both models, and compares them.
import numpy as np
import statsmodels.api as sm
rng = np.random.default_rng(7)
n = 1000
x = rng.normal(size=n)
p = 1.0 / (1.0 + np.exp(-(-0.5 + 1.2 * x)))
y = rng.binomial(1, p)
X = sm.add_constant(x)
logit_res = sm.Logit(y, X).fit(disp=False)
probit_res = sm.Probit(y, X).fit(disp=False)
print("Logit params:", logit_res.params)
print("Probit params:", probit_res.params)
print("Logit pseudo R2:", logit_res.prsquared)
print("Logit odds ratio for x:", np.exp(logit_res.params[1]))
# Average marginal effect: change in probability per unit of x
print(logit_res.get_margeff().summary())You should see logit coefficients near -0.5 and 1.2, with probit coefficients smaller by a factor of roughly 1.6 to 1.8. The average marginal effect translates the coefficient into a probability change. It is smaller than the logit coefficient, because the slope of the curve is at most 0.25 times b for a logit.
Evaluating a logit or probit model
Because R-squared does not apply, you judge these models differently.
- Likelihood ratio test. Compare the log likelihood of the full model with that of the intercept-only model. Twice the difference follows a chi-square distribution with degrees of freedom equal to the number of slope coefficients tested.
- Information criteria. AIC and BIC apply to MLE models too, with the same rule: lower is better.
- Classification accuracy. Choose a cutoff, often 0.5, and classify each observation as 1 if the fitted probability exceeds the cutoff. A confusion matrix counts correct and incorrect predictions. The cutoff matters when errors have unequal costs. Missing a defaulter usually costs more than rejecting a good borrower, so a lower cutoff may be justified.
The usual regression problems carry over. Omitted variables bias the estimates. Heteroskedasticity is handled differently here: in a logit or probit it can make the MLE estimates inconsistent, not only the standard errors, so specification matters. Multicollinearity still inflates standard errors, and VIF can be computed from the predictors.
Common errors
- Reading b as a probability change. In logit and probit, b is a change in the index (or log odds), not in probability.
- Predicting probabilities above 1 and blaming the logit. That is an LPM symptom. A logit or probit cannot do it.
- Comparing logit and probit coefficients directly. They are on different scales. Compare predicted probabilities or marginal effects.
- Quoting R-squared. Report a pseudo R-squared, an LR test, or classification results instead.
- Treating a categorical dependent variable with more than two ordered or unordered outcomes as a simple logit. Those cases need ordered or multinomial models, which are beyond this chapter.
Exercise
A logit model of whether a company is acquired has the estimated equation ln[P/(1-P)] = -2.0 + 0.50 X, where X is a measure of cash holdings. (a) For X = 4, what is the predicted probability of acquisition? (b) What is the odds ratio for X, and how do you interpret it?
Show answer
(a) z = -2.0 + 0.50 × 4 = 0. The odds are e^0 = 1, so P = 1 / (1 + 1) = 0.50, or 50%. (b) The odds ratio is e^0.50 = 1.649. Each one-unit increase in X multiplies the odds of acquisition by about 1.65, holding other variables constant. This is not a 65% rise in probability. The probability change depends on the starting value of X.
Exercise
Give two reasons a linear probability model is a poor choice for a 0/1 dependent variable, and name the estimation method used for logit and probit.
Show answer
Any two of: fitted values can fall below 0 or above 1; the errors are heteroskedastic because their variance depends on the predicted probability; the marginal effect of X is forced to be constant. Logit and probit are estimated by maximum likelihood.
Exercise
A probit coefficient on leverage is 0.40 and the corresponding logit coefficient is 0.70. An analyst says the logit model finds leverage almost twice as important. Is that conclusion valid?
Show answer
No. Logit and probit coefficients are on different scales, and logit coefficients are typically about 1.6 to 1.8 times larger for the same underlying effect. The ratio 0.70 / 0.40 = 1.75 is in that normal range, so the two models agree. To compare them, use predicted probabilities or average marginal effects.