Who has a pump?
Rich farmers
Poor farmers
The truth and the estimates
β₁ is an average of the two groups’ effects, with weights of its own
Each row averages the pump's effect for rich and poor farmers. Only the weights differ. The number on the right is the average each row produces.
To get the ATE, ATT or ATC back, let the effect differ by wealth. Then predict every farmer’s harvest with and without a pump, and average the difference over the farmers you care about:
fit <- lm(Y_obs ~ treat * rich, data = df) # Each farmer's predicted harvest with and without a pump Y1_hat <- predict(fit, newdata = transform(df, treat = 1)) Y0_hat <- predict(fit, newdata = transform(df, treat = 0)) ATE_hat <- mean(Y1_hat - Y0_hat) ATT_hat <- mean(Y1_hat[df$treat == 1] - Y0_hat[df$treat == 1]) ATC_hat <- mean(Y1_hat[df$treat == 0] - Y0_hat[df$treat == 0])
| Estimand | Truth | From lm(Y ~ pump * rich) |
|---|
What this page assumes
- There are 100 farmers, and you choose how many are rich (default 50).
- Harvest without a pump: Y0 = 10 + 5·rich + u, with u ~ Normal(0, 1) drawn from a seeded generator. Units are $1,000s.
- Harvest with a pump: Y1 = Y0 + the effect for the farmer's group (defaults +6 rich, +0 poor). Every farmer in a group has the same effect.
- Pumps go to exactly round(rate × group size) farmers in each group, so pump ownership depends on wealth and nothing else. Wealth is the only confounder.
- The true ATE, ATT and ATC use both potential outcomes. Every estimate uses only the observed harvest.
- The regression is OLS of observed harvest on pump and rich, with conventional standard errors. The blue bar shows ±1.96 SE.
- Regression weight for a group = n × p × (1 − p), where p is that group's pump rate, normalized to sum to 1.
- The noise is generated in the browser, so estimates differ slightly from the R workbook (set.seed(104)). The true ATE, ATT and ATC match it exactly.
Left out on purpose: standard errors for the interaction-model ATE, ATT and ATC, and confidence versus prediction intervals. Both are covered in the workbook.