Two situations break plain OLS: a regressor correlated with the error (endogeneity — omitted variables, simultaneity, measurement error), and a dependent variable that is not continuous (a 0/1 adoption decision, an ordered rating, a censored amount). Instrumental variables handle the first; logit, probit, and their relatives handle the second. Long & Freese is the reading for the categorical half; Cameron & Trivedi for both.
Instrumental variables: the problem
Suppose you want the causal effect of mobile-money use on household consumption. Households that adopt M-PESA differ from those that don't in unobserved ways (entrepreneurial drive, existing income) that also drive consumption. So the adoption regressor is correlated with the error, and OLS is biased. An instrument z is a variable that shifts adoption but has no direct effect on consumption — for example, distance to the nearest mobile-money agent.
Two conditions an instrument must satisfy
Relevance: z must be correlated with the endogenous regressor x (a strong first stage — testable). Exclusion (validity): z must affect the outcome y ONLY through x, never directly (not testable when the model is just-identified — it is an economic argument you must defend).
The 2SLS estimator
Two-stage least squares regresses the endogenous x on the instrument(s) and controls (stage one), then regresses y on the fitted x-hat and controls (stage two). Stata does both stages, with correct standard errors, in one command — never run the two OLS regressions by hand, because the manual second stage gives wrong standard errors.
* consumption on mobile-money use (endogenous), instrumented by distance to agent* w = exogenous controls: household size, education, i.countyivregress 2sls consumption hhsize educ i.county (mpesa_use = agent_dist), vce(robust)* syntax: ivregress 2sls depvar exog_controls (endog = instruments) , options* the endogenous regressor and its instrument(s) go inside the parentheses
Order inside the parentheses matters
(mpesa_use = agent_dist) reads endogenous_regressor = instrument. Everything left of the parentheses is an exogenous control that is its own instrument. Getting the two sides of the = backwards is the single most common ivregress mistake.
estat firststage — is the instrument strong enough?
A weak instrument (one only loosely correlated with x) makes 2SLS badly biased and its standard errors unreliable — often worse than the OLS you were trying to fix. After ivregress, estat firststage reports the first-stage F statistic on the excluded instruments.
ivregress 2sls consumption hhsize educ i.county (mpesa_use = agent_dist), vce(robust)estat firststage // first-stage F on the excluded instrument(s)
The F > 10 rule of thumb (Staiger-Stock 1997)
Staiger and Stock (1997) proposed the widely used rule that a first-stage F below 10 signals a weak instrument. With a single endogenous regressor and a single instrument, that first-stage F is exactly the square of the instrument's t-statistic in the first-stage regression. Above 10, breathe easier; below 10, your IV results are fragile.
estat endogenous — do you even need IV?
IV throws away efficiency: if x was exogenous all along, OLS was both consistent and tighter. estat endogenous runs the Durbin-Wu-Hausman test comparing OLS and IV. The null is that x is exogenous — a small p-value means x really is endogenous and IV is warranted; a large p-value says OLS would have been fine.
estat endogenous // Durbin-Wu-Hausman: H0 = regressor is exogenous
estat overid — testing the over-identifying restrictions
When you have MORE instruments than endogenous regressors (over-identified), the surplus instruments can be tested. estat overid reports the Sargan and Basmann statistics; the null is that all instruments are valid (uncorrelated with the error). A small p-value casts doubt on the exclusion restriction for at least one instrument. Note: with exactly as many instruments as endogenous regressors (just-identified), there is nothing to test — validity rests entirely on your economic argument.
* over-identified: two instruments for one endogenous regressorivregress 2sls consumption hhsize educ i.county ///(mpesa_use = agent_dist network_cov), vce(robust)estat overid // Sargan / Basmann: H0 = all instruments valid
Check your understanding
In ivregress 2sls consumption hhsize educ (mpesa_use = agent_dist), which variable is being treated as the endogenous regressor and which as its instrument?
Check your understanding
After ivregress with a single instrument, the first-stage regression reports a t-statistic of 6 on that instrument. Using the identity that the first-stage F equals the square of that t, what is the first-stage F statistic?
Check your understanding
You run estat endogenous after 2SLS and get p = 0.62. What is the sensible reading?
Limited dependent variables: binary outcomes
When the outcome is 0/1 — a household adopts M-PESA or not, a borrower defaults or not — OLS (the 'linear probability model') can predict probabilities below 0 or above 1 and has built-in heteroskedasticity. logit and probit model the probability directly through a link function that keeps predictions in [0, 1].
logit adopt hhsize educ i.county, vce(robust)probit adopt hhsize educ i.county, vce(robust)* logit, or reports odds ratios instead of raw coefficientslogit adopt hhsize educ i.county, or vce(robust)
Raw logit/probit coefficients are NOT marginal effects
A logit coefficient is a change in the LOG-ODDS; a probit coefficient is a change in a latent index in standard-deviation-like units. Neither is 'the effect on the probability of adopting'. Exponentiating a logit coefficient gives an odds ratio (exp(b)); the effect on the probability itself is non-linear and depends on where you evaluate it — which is exactly what margins is for. Reporting raw coefficients as if they were probability effects is the most common logit/probit error.
margins — average marginal effects and predicted probabilities
After logit or probit, margins, dydx(*) gives the average marginal effect (AME) of each regressor — the average across the sample of how much the predicted probability moves for a one-unit change. Plain margins over a factor gives predicted probabilities at each level. These are the numbers you actually report.
logit adopt hhsize educ i.county, vce(robust)margins, dydx(*) // average marginal effect of every regressor (on Pr scale)margins, dydx(educ) // AME of education alonemargins county // predicted Pr(adopt) at each countymargins, at(educ = (0(4)16)) // predicted Pr(adopt) across education levelsmarginsplot // and visualise it
logit vs probit — it rarely matters
logit and probit almost always give the same story; their average marginal effects are typically near-identical. logit is preferred when you want odds ratios (exp of the coefficient) and in case-control / epidemiological work; probit is common when you later need a model with normally distributed errors (e.g. heckman selection, biprobit). Pick one, report the marginal effects, and don't agonise over the choice.
Beyond binary: ordered, multinomial, and censored outcomes
- ologit / oprobit — an ORDERED outcome with ranked categories (a credit rating AAA > AA > A, a Likert satisfaction scale). The categories have an order but no cardinal spacing.
- mlogit — an UNORDERED (multinomial) choice among categories with no ranking (bank vs SACCO vs mobile-money vs cash as a household's main savings channel). Reports relative-risk ratios with rrr.
- tobit — a continuous outcome CENSORED at a limit (household savings bunched at zero for non-savers, or top-coded incomes). tobit y x, ll(0) sets a lower censoring limit at zero.
ologit rating hhsize educ i.county // ordered categoriesmlogit savings_channel hhsize educ, rrr // unordered choice, relative-risk ratiostobit savings hhsize educ, ll(0) // left-censored at zero* margins works after all of them — always the right way to interpretmargins, dydx(*) predict(outcome(2)) // e.g. AME on Pr of the 2nd category
Check your understanding
A logit of adopt on educ returns a coefficient of 0.6931 on educ. Reporting the odds ratio as exp(coefficient), what is the odds ratio for a one-year increase in education? (Round to two decimals.)
Check your understanding
You have fitted logit adopt hhsize educ i.county and want the average effect of an extra year of education on the PROBABILITY of adopting. Which command gives it?
Exercise · try it first
You suspect that mobile-money use (mpesa_use) is endogenous in a regression of household consumption (consumption) on mpesa_use with controls hhsize and educ, and you have distance to the nearest agent (agent_dist) as an instrument. Write the full do-file block: estimate 2SLS with robust standard errors, then run the three standard post-IV diagnostics, and say in one line what each checks.
Exercise · try it first
adopt is a 0/1 indicator of whether a household uses mobile money. Fit a logit of adopt on hhsize, educ, and i.county with robust standard errors, then report the results the correct way (not as raw coefficients).