Pearson correlation
Association and correlation · reference distribution: t(n−2)
When to use it
Measure and test the linear relationship between two quantitative variables.
Null hypothesis
There is no linear correlation: ρ = 0.
Assumptions
- Linear relationship
- Bivariate normality (for the test)
- No influential extreme values
Test statistic
t = \dfrac{r\sqrt{n - 2}}{\sqrt{1 - r^2}}Effect size
r itself; r² is the share of the variance of one variable explained by the other.
How to report it
r(28) = .42, p = .021
In R and Python
R
cor.test(x, y)
Python
stats.pearsonr(x, y)
In Python, stats is scipy.stats and np is numpy.
Variants and alternatives
- Spearman correlation, for monotonic relationships or ordinal data
Where it sits in the catalog
Association and correlation. Instead of comparing groups, they measure whether two variables move together, and how strongly.
In the decision tree
- What do you want to do? Measure the relationship between two variables
- What kind of variables are they? Both numeric
- Is the relationship linear, without strong extreme values? Yes