Scales translate data values into positions, colors, and sizes.
Map or set?
# Map a variable to coloraes(color = income_level)# Set every point to one colorgeom_point(color ="#a51c30")
Mapping creates a legend because color carries information.
Choose the encoding
Year
Income level
Under-five mortality
Country name
Which belongs on position, color, facet, or label? Which should not be encoded at all in the first plot?
Build one layer at a time
p <-ggplot( health_analysis,aes(log_income, under5_mortality))p +geom_point()
Run after every meaningful layer. A plot object can be inspected and extended.
Improve the points
p +geom_point(aes(color = income_level),alpha =0.45,size =1.8 )
Opacity reduces overplotting. Color introduces a grouped comparison.
Label the evidence
p +geom_point(aes(color = income_level), alpha =0.45) +labs(title ="Income and under-five mortality",subtitle ="Observed country-years, 2000-2022",x ="Log GDP per capita, PPP",y ="Deaths per 1,000 live births",color ="Income level" )
Why log income?
GDP per capita is strongly right-skewed. Equal dollar changes do not have equal meaning across the distribution.
health <- health |>mutate(log_income =log(gdp_per_capita_ppp))
A log transformation changes the scale and coefficient interpretation. It does not repair measurement or design problems.
Predict the transformation
Two countries have GDP per capita of 1,000 and 10,000. Two others have 10,000 and 100,000.
On a log scale, which pair is farther apart?
A. First pair
B. Second pair
C. Equal distance
D. Depends on the log base
Add a fitted line
p +geom_point(aes(color = income_level), alpha =0.45) +geom_smooth(method ="lm",formula = y ~ x,se =FALSE,color ="#151515" )
The line summarizes a fitted relationship. It is not a policy mechanism.
What does the line hide?
Different years.
Repeated observations from the same economy.
Unequal coverage.
Income groups.
Regional patterns.
Measurement error.
Possible nonlinear relationships.
Which hidden feature could change the story most for your policy track?
Facet with purpose
p +geom_point(alpha =0.35) +facet_wrap(~ income_level) +labs(x ="Log GDP per capita, PPP",y ="Deaths per 1,000 live births")
Faceting supports within-group comparisons but can reduce direct across-group comparison.
Plot checkpoint
With a partner, improve one plot for your track:
Name the sample.
Use one intentional encoding.
Label both units.
Write a factual title.
Add one caption limitation.
8 MINUTES
From picture to model
fit <-lm( under5_mortality ~ log_income + income_level,data = health_analysis)summary(fit)
The model summarizes conditional associations in the analysis sample.
Read the formula
outcome ~ predictor + comparison group
Left side: what varies.
Right side: variables used to summarize that variation.
+: included together, not added arithmetically.
Reference group: the omitted category used for comparison.
Coefficients have units
For a model with log income:
A one-unit increase in log GDP per capita is associated with an estimated change of β deaths per 1,000 live births, comparing observations at the same included income level.
The sentence must use the coefficient actually produced by the model.
Interpret or overreach?
A Higher observed income is associated with lower mortality in this sample.
B Increasing national income will reduce mortality by the fitted amount.
C The coefficient summarizes a conditional linear relationship.
D Income level explains every cross-country difference.
Which statements are defensible from this model alone?
Surprise can reveal a data problem, an omitted factor, or a genuinely unusual case.
Diagnose in context
For a surprising observation, check:
Indicator definition and unit.
Missing or imputed inputs.
Duplicate keys.
Country and year context.
Whether the transformation is valid.
Whether the model form is too simple.
Do not delete an observation merely because it is inconvenient.
Two different agent reviews
Code review
sample construction,
missingness,
transformations,
labels,
reproducibility.
Statistical review
units,
specification,
residuals,
claim strength,
limitations.
A second reader, not a judge
The agent should look for traceable mismatches:
the question names one population but the code filters another,
the caption names all countries but the model drops missing rows,
the coefficient is described in the wrong units,
the prose says “caused” while the design is associational.
“This analysis seems biased” is not yet a finding.
Weak review prompt
Is my analysis correct?
The question is too broad. The agent may rewrite the analysis, mix code with interpretation, or offer generic praise.
Bounded review prompt
Goal: Review this analysis in two separate passes.Context: Read the policy question, dictionary, script, and figure.Pass 1: Check code behavior, sample, missingness, labels, and reproducibility.Pass 2: Check whether the claim matches the descriptive design and output.Constraints: Do not edit. Quote evidence for each concern. Do not suggest causal language.Done when: Issues are classified as verified, uncertain, or rejected,with an R check I can run for each.
Accept no untraceable critique
For every agent concern, ask:
Which file or output supports it?
Which line or value should I inspect?
What R check can confirm it?
Is the concern about code, data, statistics, or writing?
What evidence would make me reject the concern?
Counterexample hunt
Find one:
country-year,
subgroup,
period,
scale,
or defensible specification
that makes the headline less complete.
Does it overturn the claim, narrow it, or identify the next question?
4 MINUTES
One-minute claim
Write two sentences:
The strongest result your current evidence supports.
The most important reason not to overinterpret it.
Exchange with a partner and underline any causal verb.