Correlation (Pearson and Spearman)
Measure how strongly, and in which direction, two variables move together.
7 min read
Try it
One click opens the “Exam scores” sample dataset with this test selected and the variables filled in. Or use your own data.
Correlation measures how strongly two variables move together, and in which direction. For example: do people who study longer tend to score higher?
When to use it
- You have two or more numeric variables measured on the same people.
- You want the relationship, without labelling one variable as the predictor (to predict, use multiple regression).
Reading a correlation coefficient
r runs from −1 to +1.
- The sign gives the direction: positive means both rise together; negative means one rises as the other falls.
- The size gives the strength. Cohen's (1988) benchmarks: |r| = .10 small, .30 medium, .50 large.
- r² is the proportion of shared variance: r = .82 gives r² = .67, so the two variables share 67% of their variance.
Pearson or Spearman?
| Pearson's r | Spearman's ρ | |
|---|---|---|
| Use for | Numeric data | Ordinal data, or data with outliers |
| Measures | Linear relationships | Monotonic relationships, using ranks |
| Assumptions | Linear relationship, no severe outliers | Fewer |
Lucidstat uses Pearson by default; switch to Spearman under "Advanced options". If any variable is a Likert item, Lucidstat shows a chip suggesting Spearman.
Confidence intervals for r
Lucidstat computes the 95% CI with Fisher's z transformation, as R cor.test does. The interval is not symmetric around r, because r is bounded by −1 and 1.
Worked example
The "Exam scores" sample (40 students) correlates study hours, anxiety and exam score.
| Variable | 1 | 2 | 3 |
|---|---|---|---|
| 1. Study hours | — | ||
| 2. Anxiety | −.44** | — | |
| 3. Exam score | .82*** | −.56*** | — |
| Pair | r | p | 95% CI |
|---|---|---|---|
| Study hours – Anxiety | −.44 | .004 | [−.66, −.15] |
| Study hours – Exam score | .82 | < .001 | [.68, .90] |
| Anxiety – Exam score | −.56 | < .001 | [−.74, −.30] |
How to read it
- Study hours has a large positive correlation with exam score (r = .82): students who study longer tend to score higher.
- Anxiety has a large negative correlation with exam score (r = −.56).
- Study hours has a medium negative correlation with anxiety (r = −.44).
Pearson correlations (n = 40) showed 3 significant associations: Study hours and Anxiety, r(38) = −.44, p = .004 (a medium negative relationship), Study hours and Exam score, r(38) = .82, p < .001 (a large positive relationship) and Anxiety and Exam score, r(38) = −.56, p < .001 (a large negative relationship).
ผลการวิเคราะห์สหสัมพันธ์แบบ Pearson (n = 40) พบว่า ชั่วโมงอ่านหนังสือมีความสัมพันธ์ทางลบกับความวิตกกังวลในระดับปานกลางอย่างมีนัยสำคัญทางสถิติ (r(38) = −.44, p = .004), ชั่วโมงอ่านหนังสือมีความสัมพันธ์ทางบวกกับคะแนนสอบในระดับใหญ่อย่างมีนัยสำคัญทางสถิติ (r(38) = .82, p < .001) และความวิตกกังวลมีความสัมพันธ์ทางลบกับคะแนนสอบในระดับใหญ่อย่างมีนัยสำคัญทางสถิติ (r(38) = −.56, p < .001)
Common mistakes
- Not looking at a scatterplot. A curved relationship can give r near 0 even when the variables are clearly related, and a single outlier can change r a lot.
- Using Pearson for a single ordinal item. Consider Spearman.
- Reading r = .30 as "explains 30%". The correct figure is r² = .09, or 9%.
References
- Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum.
- Fisher, R. A. (1921). On the "probable error" of a coefficient of correlation deduced from a small sample. Metron, 1, 3–32.
Try it
One click opens the “Exam scores” sample dataset with this test selected and the variables filled in. Or use your own data.