17: Correlation & Simple Regression
Content for Monday, June 1, 2026
Before class
📖 Reading:
ImportantAssignment 8 is due today
Assignment 8: Storytelling Report — due Sunday, May 31 at 11:59 PM.
During class
We’ll cover:
- From eyeballing to numbers: why we need correlation and regression
- Correlation with
cor()andcor.test()- Pearson’s r — what it is and what it isn’t
- Correlation matrices and heatmaps
- Correlation ≠ causation (with psychology examples)
- Simple linear regression with
lm()- Interpreting slope, intercept, and R²
- Scatterplots with
geom_smooth(method = "lm")
- Tidying model output with
broom::tidy()andbroom::glance()
Slides
View slides in new tab Download PDFEmbedded slides
After class
✅ Practice:
- Pick two numeric variables in a dataset you’ve been working with (or use
palmerpenguins::penguins). Compute their correlation withcor()andcor.test(). Is the relationship what you expected? - Fit a simple linear model with
lm(). Interpret the slope in plain language — what does a one-unit increase in x predict for y? - Use
broom::tidy()to extract the model coefficients. Usebroom::glance()to get the R². Report these with inline code in a Quarto document. - Create a scatterplot with
geom_smooth(method = "lm"). Add informative labels and a title that tells the story.
NoteCorrelation guidelines
- |r| < 0.3 — weak
- 0.3 ≤ |r| < 0.7 — moderate
- |r| ≥ 0.7 — strong
These are rough guidelines, not rigid cutoffs. Context and sample size matter.