Prediction asks “what will happen?” Econometrics asks “what will happen if I change something?” Does health insurance make people healthier? Does this execution algorithm actually reduce slippage, or do we just use it on easier orders? Answering needs more than a good fit.
The selection-bias problem
Let if person has insurance and otherwise. Each person has two potential outcomes: with insurance and without. We only ever see one. Comparing group averages gives
The selection-bias term asks: would the insured have been healthier even without insurance? Usually yes: richer, more educated people are both more likely to buy insurance and healthier anyway. The naive comparison mixes the two.
Randomise
If a coin decides who is treated, treatment can’t be related to anything else about people. By the law of large numbers both groups have the same average , so the selection-bias term goes to zero and the simple difference in means is the causal effect. After randomising, “check for balance”: compare the groups’ averages on age, income and so on; they should match.
Statistics for comparing two groups
- Sample mean is unbiased for , with sampling variance and standard error .
- -statistic for “the mean is ”: ; is the usual bar, and is an approximate 95% interval.
- Two groups: (pooled), and .
A large needs both a real effect and a small standard error. A small may mean there is no effect, or just not enough data to see it.
Regression as a substitute for randomisation
Often you can’t randomise. Regression controls for observed differences:
where holds control variables (age, income, …). The key assumption is the conditional independence assumption: once you compare people with the same controls, treatment is as good as random. Continuous variables enter as they are; categories enter as one-hot (dummy) variables. Regressing on makes read as an approximate percentage effect.
Omitted-variable bias
What if you left out an important control? Compare the short regression (without the control ) and the long one (with it):
where is ’s effect on in the long regression and is the slope from regressing on the treatment. Bias needs both: the omitted variable must move with the treatment () and matter for the outcome (). Even without data on , you can reason about the sign of the bias.
Regression facts worth knowing
- Regression gives the best linear approximation to the conditional expectation function , which is itself the minimum-mean-squared-error predictor: .
- Residuals have mean zero and are uncorrelated with every input and with the fitted values.
- ANOVA identity: .
- If the error variance changes with (heteroskedasticity, which any nonlinear CEF or a 0/1 outcome produces), use robust standard errors. They are usually close to the conventional ones.
- Sampling weights (inverse sampling probabilities) fix non-random samples; heteroskedasticity alone is not a reason to use weighted least squares.
- A saturated model (a dummy for every combination of discrete inputs) fits the CEF exactly, at the cost of noisy coefficients.
In code
import numpy as np
rng = np.random.default_rng(11)
n = 100_000
health = rng.standard_normal(n) # unobserved
chooses = rng.random(n) < 1 / (1 + np.exp(-2.2 * health))
y0 = 70 + 7 * health + 3 * rng.standard_normal(n)
effect = 2.0
naive = (y0[chooses] + effect).mean() - y0[~chooses].mean()
print("people choose:", round(naive, 2)) # far above 2: selection bias
coin = rng.random(n) < 0.5
print("coin flip:", round((y0[coin] + effect).mean() - y0[~coin].mean(), 2)) # ≈ 2
Check yourself
Stocks that a broker’s analysts cover outperform uncovered stocks by 3% a year. Which omitted variable would most plausibly bias the ‘coverage effect’ upwards?