← Course home
MODULE 8 · FIRST-YEAR LEVEL

Correlation and the direction of association

What can we infer when two variables vary together?

70–90 minutesConcepts first, R optionalSynthetic data

Learning outcomes

Conceptual lesson

Correlation summarises how two numerical variables co-vary. Pearson's r ranges from −1 to +1 and describes the direction and strength of linear association. A value near zero indicates little linear association, not necessarily the absence of all possible relationships. Spearman rank correlation is another option when ranks or robustness to extremes are relevant.

Inspect a scatterplot before computing a coefficient. One outlier can greatly change r. Aggregated data can even hide a reversed within-group pattern (Simpson's paradox). Limited range and measurement reliability also influence correlations.

A correlation coefficient cannot establish causation. Prior knowledge, selection or a third variable might influence both study time and scores. Consider magnitude and uncertainty alongside design.

Worked research example

Plot study hours against post-quiz score in the fictional data, then compute Pearson's correlation. A positive r does not justify “forcing students to study longer raises their grades” without further research.

Common reasoning trap

r=0 does not rule out every kind of association, and r=0.7 does not mean 70% of outcomes were caused by one variable.

Independent practice

  1. Inspect a scatterplot and describe the pattern.
  2. Calculate Pearson and Spearman correlations; consider why they might differ.
  3. Report an association without turning it into a causal claim.

Explain your reasoning, not only the number.

Optional R lab

Save the synthetic CSV in the working folder before running the script. Base R only.

CSV · Download R script

# Statistics Lab / ferdo — synthetic data (no real student records)
# Save stats_synthetic.csv in your working directory.
d <- read.csv("stats_synthetic.csv", stringsAsFactors = TRUE)
stopifnot(nrow(d) == 36, all(c("score_pre","score_post","group") %in% names(d)))
# Groups are observational labels: differences cannot establish a treatment effect.

plot(d$study_hours, d$score_post, pch=19,
     xlab="Study hours", ylab="Post-quiz score")
cor(d$study_hours, d$score_post, method="pearson")
cor(d$study_hours, d$score_post, method="spearman")
cor.test(d$study_hours, d$score_post)

Stretch: mathematical track

Compare covariance, which depends on measurement units, with standardised correlation.

Exit ticket

Write one defensible claim and one limitation from this week's example.

Student workbook for this module

Four written problems, marking guide and a formative four-question quiz.

Open week 8 workbook →

Optional mathematical derivations

Extend this topic with worked mathematics, written exercises and base R checks.

Math M8 · Full math pathway