Day 20 — Association, residuals and limits
Plant ecologists often need the dry mass of leaves, but drying and weighing destroys the leaf. Leaf area is easy to measure from a photo or scan. If area and mass go together, a line can describe how. We collected one leaf from each of 18 plants and measured both. Do larger leaves have more dry mass, and how much more per cm²?
Today you will:
lm();Day 19 used a line as a measuring tool for prepared standards. Today the same code describes a biological pattern, and the interpretation changes. Week 5 turns to the computer itself.

> library(readr)
> leaves <- read_csv("data/leaf-mass.csv", show_col_types = FALSE)
> leaf_fit <- lm(dry_mass_mg ~ leaf_area_cm2, data = leaves)
> coef(leaf_fit)
(Intercept) leaf_area_cm2
9.476606 4.110117
lm() as Day 19: response (mass) on the left of ~, area on the right.
“Across 18 plants, leaves with larger area had greater dry mass: within the observed range (2.96 to 14.68 cm²), each additional 1 cm² was associated with about 4.11 mg more fitted dry mass. The study was observational, so this does not show that increasing leaf area would increase mass.”
| Claim | Supported? |
|---|---|
| “Larger leaves tended to have more dry mass in this sample.” | Yes, a description of the association. |
| “Adding 1 cm² of area causes 4.11 mg extra mass.” | No: nothing was manipulated; other factors vary too. |
| “Every 8 cm² leaf weighs 42.36 mg.” | No: that is a fitted mean; leaves scatter by several mg. |
| “A 30 cm² leaf will weigh about 133 mg.” | No: far outside the observed areas. |
| Design | Day | Output |
|---|---|---|
| Two independent groups | 16–17 | Mean difference, Welch CI |
| Same unit measured twice | 18 | Mean within-unit change, paired CI |
| Prepared standards → reading | 19 | Calibration line, inverse estimate |
| Two measured variables | 20 | Slope with units, residuals |
Name the unit, the outcome and its units before choosing a function.
| Concept | Key fact |
|---|---|
| Observational data | Both variables measured, nothing assigned: the line describes, it does not show cause |
| Fit | lm(dry_mass_mg ~ leaf_area_cm2, data = leaves): mass ≈ 9.48 + 4.11 × area |
| Slope | 4.11 mg per cm² of fitted mean mass; 0.0411 mg per mm² is the same line |
| Intercept | Fitted mass at area 0, outside the data; not a measured leaf |
| Residual | Observed − fitted mass (mg); look for curvature or a point far away |
| Prediction | Fitted mean, only within 2.96–14.68 cm² (8 cm² → 42.36 mg) |
| Sensitivity | Without A18: slope 4.065; keep A18 in the main result |
| Choosing a method | Design and question first: groups, pairs, calibration or association |
Next (Day 21, how a computer works and how big data are): from the analysis to the machine that stores and processes the data.
Now: open the Day 20 exercises. Make association-report.Rmd with the plot and line, the slope in a sentence with units, the residual plot and a labelled A18 check; save output/day20-leaf-line.png and render.