DATEMON AUG 24
TIME1-4 PM
FORMATLESSON + LAB

CODING LESSON 3

Compare patterns.

Treat plots and models as lenses that compress evidence—useful because they simplify, risky because every simplification hides something.

OPEN LAB 3 →OPEN SLIDES ↗

LEARNING OUTCOMES

Connect a visual pattern to a careful sentence.

By the end of the meeting, you should be able to create a legible comparison, fit a simple regression, inspect residuals, and state what the evidence does and does not show.

  1. 01Choose plot encodings that match the variables and question.
  2. 02Use transformations when the scale makes a pattern hard to see.
  3. 03Interpret a coefficient in the units of the variables.
  4. 04Inspect residuals and influential observations.
  5. 05Separate descriptive, associational, and causal language.

Why this matters for policy work

A figure and a regression both compress a large table into a smaller object that people can reason about. Compression is useful, but it is never neutral. Axis scales determine which differences look large. Color and facets determine which groups become visible. A model formula determines which comparisons are summarized together. Reading those choices is part of reading the evidence.

MAP-AND-LENS ANALOGY

A map is valuable because it leaves most of the world out. A statistical figure or model does the same: it preserves features needed for one comparison and suppresses others. The task is not to demand a map with every detail. It is to know what the current map includes, what it omits, and whether it is suitable for the journey.

International development data make restraint especially important. Countries differ in history, institutions, measurement capacity, and exposure to shocks. Repeated observations are not independent snapshots of identical units. This lesson does not solve those design problems. It teaches students to recognize them, describe an association honestly, and identify the additional evidence that a stronger claim would require.

CLAIM LADDER

Use the strongest claim the design can carry.

LevelExampleAllowed here?
DescriptiveUnder-five mortality declined in most observed countries.Yes, with coverage noted.
AssociationalHigher income is associated with lower mortality in this sample.Yes, with specification noted.
CausalHigher income caused mortality to fall.No. This design does not identify a causal effect.

Interpretation check. A more complex model does not repair a weak research design. The purpose here is to learn the mechanics and limits of comparison before the fall sequence develops them further.

VISUAL CRITIQUE

A graph is an argument made with encodings.

We will begin with an intentionally weak figure. In pairs, students mark what the graph asks the eye to compare, what information is hidden, and which design choice most changes the interpretation.

NOTICEWhat do you see?

Describe before evaluating.

COMPAREWhat is the eye doing?

Position, color, size, shape, or facet.

QUESTIONWhat is missing?

Units, sample, source, uncertainty, or context.

REVISEWhat one change matters most?

Prioritize clarity over decoration.

Three checkpoints for every figure

  • Someone can identify the population, variables, units, and period without narration.
  • The encoding supports the comparison instead of distracting from it.
  • The caption states what the figure shows and one thing it cannot establish.

LIVE CODING

Plot, model, diagnose, explain.

Plot

Map variables deliberately and label units clearly.

Transform

Compare raw and logged income scales.

Model

Fit one interpretable regression and read its terms.

Diagnose

Inspect residuals and surprising observations.

Claim

Write one result and one limitation.

Lab 3

Build a comparison for the selected policy track.

RFrom plot to model
ggplot(health, aes(log_income, under5_mortality,
                   color = income_level)) +
  geom_point(alpha = 0.45) +
  geom_smooth(method = "lm", se = FALSE)

fit <- lm(under5_mortality ~ log_income + income_level,
          data = health)
summary(fit)

ggplot(health, aes(...)) identifies the data and maps log income, under-five mortality, and income level to visual properties. Those choices determine what the viewer is invited to compare.

geom_point(alpha = 0.45) draws one mark for each observed row and makes overlapping observations partly visible. It does not correct unequal coverage across countries or years.

geom_smooth(method = "lm", se = FALSE) adds a fitted linear summary. The line describes a pattern in the plotted sample; it is not evidence of a mechanism or policy effect.

lm(...) estimates under-five mortality as a function of log income and income group. summary(fit) prints the estimated terms and diagnostics we will interpret in the units and limits of this specification.

AGENT REVIEW PASS

Use the agent as a second reader, not a statistical judge.

The agent now changes roles again. It is not producing the first analysis and it is not choosing the preferred specification. It is looking for traceable mismatches between the question, code, output, and prose. A useful review makes falsifiable claims: “this filter changes the sample from X to Y” is reviewable; “this analysis seems biased” is not yet a finding.

Starter prompt
Goal: Review this analysis in two separate passes.
Context: Read the policy question, variable dictionary, script, and generated figure.
Pass 1: Check code behavior, missing values, transformations, labels, and reproducibility.
Pass 2: Check whether the written claim matches the descriptive design and model output.
Constraints: Do not rewrite the analysis. Quote the exact evidence for each concern. Do not suggest causal language.
Done when: I have a short list of verified issues, uncertain issues, and checks I can run in R.

Run a counterexample hunt

Before accepting the review, find one observation, subgroup, period, or defensible specification that makes the simple story less complete. The goal is not to destroy the analysis. It is to learn whether the claim survives contact with evidence outside its most convenient summary.

  • Can every concern be tied to code, output, or documentation?
  • Did the agent confuse prediction, association, and causation?
  • Did you inspect at least one surprising observation yourself?
  • Does the final sentence name a limitation?

SLIDES

Lesson deck.

The stable slide address lets the lesson page stay intact while the deck evolves.

LESSON 3 / REVEALJSOPEN FULL SCREEN ↗