Command reference
logit — model a binary outcome
Fit a logistic regression when the outcome has two states. The model relates predictors to the log odds of the positive outcome and reports coefficients, uncertainty estimates, and an overall model test.
Syntax
logit outcome predictors [if condition] [in first/last] [weight] [, options]
logit [, level(#) coef]
The first variable is the outcome; supply at least one predictor after it. Zero is the negative outcome, and every other nonmissing numeric value is treated as positive. Both outcomes must occur in the estimation sample. Coding the outcome explicitly as 0 and 1 makes its meaning easier to check.
Use i.group to include a categorical predictor with an omitted reference category; an ordinary numeric predictor enters on a continuous scale. if and in restrict the estimation rows. Optional [fw=count], [iw=weight], or [pw=weight] weights go before the comma. Frequency weights represent integer repetition counts; sampling weights imply robust standard errors. Analytic weights are not accepted.
Calling logit with no variable list displays the latest binary-logit results. To display the same estimates as odds ratios, use the related logistic command.
Options
Example
Use the 24 synthetic teaching records to model the binary female indicator from math and read, with robust standard errors. This small invented dataset is useful for learning how to read a coefficient table.
clear
import delimited "data/student_scores.csv"
logit female math read, robust
Sample data included. Opens in a new tab; click Run.
What to look for
The coefficients are approximately −1.80 for math and 2.77 for read. Each describes a change in log odds while holding the other score fixed; neither is a percentage-point change in probability. Their wide confidence intervals show that these estimates are imprecise.
The robust overall Wald test has a p-value of about 0.1232. The pseudo R-squared is about 0.5899, but should not be interpreted like the R-squared from a linear regression. These results describe the synthetic example only.