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() and cor.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() and broom::glance()

Slides

View slides in new tab Download PDF

Embedded slides

After class

Practice:

  1. Pick two numeric variables in a dataset you’ve been working with (or use palmerpenguins::penguins). Compute their correlation with cor() and cor.test(). Is the relationship what you expected?
  2. Fit a simple linear model with lm(). Interpret the slope in plain language — what does a one-unit increase in x predict for y?
  3. Use broom::tidy() to extract the model coefficients. Use broom::glance() to get the R². Report these with inline code in a Quarto document.
  4. 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.