Correlation Coefficient
calculator.
See how closely two sets of paired numbers follow a straight line, with Pearson's r.
| # | X values | Y values |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | ||
| 9 | ||
| 10 | ||
| 11 |
- p-value, two-tailed
- 0.0022
- 95% interval for r
- 0.424 to 0.951
- Pairs
- 11
This is a large positive link: r² says 66.7% of the variation in Y goes with X along a straight line. With 11 pairs, p = 0.0022, so it passes the 5% level. Leaving out pair 3 moves r the most, to 0.8852.
Scatter plot and fitted line
Drag the marked point11 pairs with r = 0.8164 and the line y = 3.0001 + 0.5001x. Pair 1 is at (10, 8.04). The table of pairs gives the same data.
Working
- 1Find the meansMean of x = 9Mean of y = 7.5009
- 2Add the products and squares around the meansSxy = 55.01Sxx = 110Syy = 41.2727
- 3Divide Sxy by the root of Sxx times Syyr =55.01√(110 × 41.2727)= 0.8164
- 4Turn r into t, with 9 degrees of freedomt =0.8164 × √9√(1 − 0.6665)= 4.2415
- 5The p-value is the two-tailed area beyond tp = 0.0022
- 6Fisher's z gives the 95% interval, turned back into r0.424 to 0.951
- 7Check: slope times SD of x over SD of y gives r back0.5001 × 3.31662.0316= 0.8164
r with each pair left out
| Pair left out | ||
|---|---|---|
| 1: (10, 8.04) | 0.8149 | −0.0016 |
| 2: (8, 6.95) | 0.8148 | −0.0016 |
| 3: (13, 7.58) | 0.8852 | +0.0688 |
| 4: (9, 8.81) | 0.8357 | +0.0193 |
| 5: (11, 8.33) | 0.8131 | −0.0033 |
| 6: (14, 9.96) | 0.7762 | −0.0402 |
| 7: (6, 7.24) | 0.8432 | +0.0268 |
| 8: (4, 4.26) | 0.751 | −0.0654 |
A large change points to the pair to check first.
Without the pair that matters most
Pair 3, at (13, 7.58), changes r by 0.0688, more than any other.
How big is this r?
- Cohen's bands for r
- 0.10 small, 0.30 medium, 0.50 large
- This r
- 0.8164, large
- r needed at the 5% level, 11 pairs
- ±0.602
Bands from Cohen (1992), set for behavioral research, so your field may expect far more. The r needed comes from the t test on r, and matches the critical value in OpenStax, Introductory Statistics, section 12.4.
How it's worked out
Pearson's r runs from −1, where every point lies on a falling line, through 0, where there is no straight-line trend, to +1, where every point lies on a rising line. It has no units, so it does not matter whether you measure in inches or meters.
It comes from three sums around the means of x and y, written with and .
Next comes a t test, which asks how often a sample of this size would show so large an r if there were no link at all. The two-tailed p-value uses n − 2 degrees of freedom.
The interval for r uses Fisher's z transform. It turns r into z, builds a symmetric interval on that scale with a standard error of , and turns the limits back into r. That takes at least 4 pairs.
Worked examples
Maya tracks study hours and test scores
Maya asks eight classmates for their study hours (1, 2, 3, 4, 5, 6, 7, 8) and scores (52, 55, 61, 64, 70, 71, 78, 83). The data give r = 0.994 and r² = 0.988, with t = 22.68 on 6 degrees of freedom.
The p-value is below 0.001, and the 95% interval for the true correlation runs from 0.967 to 0.999. The fitted line adds about 4.38 points per hour. That does not show that extra hours cause higher scores, since students who study more may differ in other ways.
Ben works five pairs by hand
Ben has x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5. The means are 3 and 4, which give the three sums.
That looks strong, but p = 0.124. With only 5 pairs, r has to reach ±0.878 to pass the 5% level, and 0.775 falls short. His 95% interval runs from −0.34 to 0.984, which still includes 0.
Anscombe's third data set hides an outlier
Anscombe's four data sets share nearly the same r, at 0.816, 0.816, 0.816, 0.817, yet they look nothing alike when plotted. One rises in a clean line with scatter, one bends, one is a straight line with a single stray point, and one is a vertical stack with one far point.
In the third, r is 0.816. Leave out pair 3, at (13, 12.74), and r rises to 0.999997, because the other ten pairs lie almost exactly on a line. In the fourth, the far point at (19, 12.5) is the only reason r exists at all: leave it out and every remaining x is 8, so no correlation can be worked out.
Reading your result
Look at the plot before the number. r only measures straight-line association. Anscombe's four sets are the classic warning, as the same r can come from very different patterns.
Read size and direction together. The sign gives the direction, and the distance from 0 gives the size. Cohen's bands call 0.10 small, 0.30 medium and 0.50 large. They were set for behavioral research, so a physical measurement may need far more.
Read r² as a share. r² is the share of variation in y that the straight line accounts for. Maya's r² of 0.988 means the line explains about 99% of the spread in her scores.
Significance depends on the number of pairs. The r needed at the 5% level falls from 0.878 at 5 pairs to 0.632 at 10, 0.444 at 20, 0.279 at 50 and 0.197 at 100. So a small r can be significant in a large sample, and a large r may not be in a small one.
Common mistakes
- Treating r as proof of cause. Strong correlation does not suggest that x causes y. A third factor can drive both, or the cause can run the other way.
- Reading r = 0 as "no relationship". For x from −2 to 2, y = x² fits perfectly, yet r = 0. There is a clear pattern, just not a straight line.
- Comparing r across different ranges. Cut Maya's data down to 3 to 6 hours and r falls from 0.994 to 0.969, simply because x varies less.
- Using it on dependent data. The test assumes independent errors. Time series or repeated measures on one person need other methods.
- Pairing the columns wrongly. Each x must sit beside its own y. Sorting one column on its own changes r completely.
Questions people ask
Sources
- OpenStax, Introductory Statistics 2e, section 12.3, The Regression Equation
- OpenStax, Introductory Statistics 2e, section 12.4, Testing the Significance of the Correlation Coefficient
- R documentation, cor.test
- R documentation, anscombe data sets
- Cohen, J. (1992), A power primer, Psychological Bulletin 112(1), 155-159
- Miot, H. A. (2018), Correlation analysis in clinical and experimental studies, J Vasc Bras 17(4), 275-279