Coding· RAccessibility checks passPublished

Rich and Poor Farmers: What Does Regression Recover?

By Alexis Diamond · Statistics · causal inference · Undergraduate · Simulation of a known property · version 9

A Coding workbook in R. Students simulate 100 farmers with both potential outcomes, compute the naïve gap, ATE, ATT, ATC and selection bias, then see that a regression with a control matches none of them while an interaction model does. A final part contrasts confidence and prediction intervals.

Report this artifact

Reports are anonymous. The artifact stays up until we've checked it.

Licence: CC BY 4.0

Assumption ledger

  • parameter100 farmers: 50 rich, 50 poor. Treated: 45 of 50 rich (90%) and 25 of 50 poor (50%). set.seed(104).
  • distributionY0 = 10 + 5*rich + u with u ~ Normal(0, 1); Y1 = Y0 + 6*rich. Harvest is in $1,000s.
  • parameterExact estimands: ATE = 6*50/100 = 3, ATT = 6*45/70 = 3.857, ATC = 6*5/30 = 1. u cancels in Y1 − Y0.
  • simplificationOne binary confounder and one binary treatment; no covariates beyond wealth. The additive lm weights each group by n × p(1−p), giving about 26% weight to the rich.
  • dataAll data are simulated inside the setup cell; nothing is loaded or fetched.
  • interpretationThe Rubin and Holland discussion (Q1 and Q24) uses 'rich' as a stand-in for attributes such as sex or race that cannot be manipulated.
  • interpretationBrand fonts: Chronicle Display and Neue Haas Grotesk are licensed, so EB Garamond (Google Fonts) and a Helvetica Neue, Helvetica, Arial stack are used. Body text is 19 px (14 pt) per the guide.
  • interpretationBrand colours: Clay #905112 is used for buttons, links and the plot highlight, on White, Bone and Ivory only. Goldenrod and Tangerine are not used. Plot groups are also separated by axis position, not colour alone.

Breakout check

Not checked yet.

Code checks

Not checked yet.

Built-in checks 6 of 6 pass

  • ATE equals 6 times the rich share of all farmers (passes)
  • ATT = 6*45/70 and ATC = 1 (passes)
  • ATE mixes ATT and ATC by treated share (0.7, 0.3) (passes)
  • Expected selection bias is about 2.38 (passes)
  • Regression weight on rich is about 0.265 (passes)
  • Every response key has a box and a state entry (passes)

Cite this

Alexis Diamond (2026). Rich and Poor Farmers: What Does Regression Recover? [Interactive model], version 9. Ideas at Play. https://ideasatplay.org/play/rich-and-poor-farmers-what-does-regression-recover-32963f?v=9 (CC BY 4.0)

History

  1. v9Edited by hand. (edited, Oct 19, 2026)current
  2. v8Edited by hand. (edited, Oct 19, 2026)View
  3. v7Fixed the Q16 heading typo to read 'allow the effect to differ by wealth'; nothing else changed. (generated, Oct 19, 2026)View
  4. v6Renamed the Q16 heading to “Q16 · Run a regression with an interaction term that allows the effect differ by wealth”; nothing else changed. (generated, Oct 19, 2026)View
  5. v5Removed Q23 (its heading, written-response box and the response_q23 state key); all other cells, keys and solutions are unchanged. (generated, Oct 19, 2026)View
  6. v4Removed the Q22 coverage-check cell and reworded the Q23 prompt, which depended on its output, to use the Q20 intervals; all state keys and the window.artifact interface are unchanged. (generated, Oct 19, 2026)View
  7. v3Part 2 now shows the actual prediction question (“Will the naïve difference in mean harvests be larger or smaller than the true average effect of the pump? Why?”) above the answer box; nothing else changed. (generated, Oct 19, 2026)View
  8. v2Q1 now includes the requested follow-up questions (What do you think? How can statistical methods… What do you take away from Rubin and Holland?) after a skipped line, ending with 'Write a first answer now. You will come back to this question at the end of the notebook.' (generated, Oct 19, 2026)View
  9. v1New Coding artifact in R built from the CS130 workbook v2 and the Minerva style kit; ___ blanks became NA, the instructor answer keys were kept out of the page, and plot colours use brand Slate and Clay. (generated, Oct 19, 2026)View

Comments

No comments yet.

Sign in to comment or like.