logit: binary regression with robust standard errors
Model a zero/one outcome on the log-odds scale and keep coefficient interpretation separate from probability and causal claims.
Independent software. Not affiliated with, sponsored by, or endorsed by StataCorp LLC.
Complete example
clear
import delimited "data/student_scores.csv"
logit female math read, robust
The outcome is a zero/one indicator. robust requests a sandwich variance estimate while leaving the maximum-likelihood coefficients unchanged.
Output from stats.camp
Logistic regression Number of obs = 24
Wald chi2(2) = 4.19
Prob > chi2 = 0.1232
Log likelihood = -6.82215 Pseudo R2 = 0.5899
--------------------------------------------------------------------------------
| Robust
female | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+------------------------------------------------------------------
math | -1.7951443 1.236561 -1.45 0.147 -4.218758 .6284698
read | 2.7685663 1.785122 1.55 0.121 -.7302075 6.26734
_cons | -52.723487 30.56276 -1.73 0.085 -112.6254 7.178413
--------------------------------------------------------------------------------
How to read the coefficients
A coefficient is a change in log odds for a one-unit predictor change while holding the other included predictor fixed. It is not a change in probability. Exponentiating a coefficient produces an odds ratio, but this tiny synthetic dataset yields imprecise and unstable estimates that should not receive substantive interpretation.
The overall robust Wald test has p=0.1232. A pseudo R-squared is not interpreted like the OLS R-squared.
Common options and modeling checks
robustandvce(robust)request robust standard errors; supportedvce()forms should be chosen from the sampling design.iterate()andtolerance()control convergence. Changing them does not repair separation or a poorly specified model.- Supported factor-variable notation such as
i.groupcreates categorical indicators with an omitted reference group. - Inspect outcome coding, missing observations, convergence, separation, functional form, and sample size before interpreting results.
- The related
logisticcommand reports odds ratios;logitreports coefficients.
See the current logit entry and Stata's logit manual for an external reference.
Related guides
Run this exact example
Clone the example repository in stats.camp and open the exact do-file shown on this page. No stats.camp account is required.
Open this example