Correlation Coefficient Calculator
Enter paired x and y values and the correlation coefficient calculator returns Pearson's r, r-squared and Spearman's rho, with a p-value and a 95% interval to show how sure the number is.
Pearson r
- Pearson r A strong positive linear association, by the common rule of thumb (0.4 moderate, 0.7 strong). What counts as strong differs by field.
- 0.9205
- r-squared 84.72% of the variation in y moves in step with a straight line in x. The rest is unexplained by it.
- 0.8472
- Spearman's rho Pearson's r on the ranks, ties given their average rank. It measures any steady rise or fall, straight or curved. It is close to r, so no single pair or bend is dominating.
- 0.9341
- t statistic and p-value (r = 0) t = r x sqrt((n - 2) / (1 - r^2)) on 6 degrees of freedom, two-sided. p is below 0.05. A correlation this far from zero would be unusual if there were no linear association at all. It says nothing about size, cause or whether a line is the right shape.
- t = 5.769, p = 0.0012
- Spearman p-value The same t formula on rho (t = 6.412), the usual approximation. On very small samples an exact table differs slightly.
- 0.0007
- 95% interval for r Fisher's z transformation. On 8 pairs the plausible range is wide; it narrows as the square root of n - 3 grows.
- 0.6141 to 0.9858
- Sample covariance In x's units times y's units, which is why r divides it by both standard deviations to get a pure number.
- 18.25
- Pairs
- 8
| x | y | Rank of x | Rank of y |
|---|---|---|---|
| 1 | 52 | 1 | 1 |
| 2 | 55 | 2.5 | 2 |
| 2 | 61 | 2.5 | 4 |
| 3 | 58 | 4 | 3 |
| 4 | 67 | 5 | 5 |
| 5 | 70 | 6 | 6 |
| 6 | 74 | 7 | 8 |
| 8 | 73 | 8 | 7 |
- Correlation is not causation. A third factor can drive both variables, or the cause can run the other way; r cannot tell these apart.
- r measures straight-line association only. A strong curve can give an r near zero, so plot the points before reading much into it.
How the Correlation Coefficient Calculator works
A correlation coefficient is one number from -1 to 1 for how closely two variables move together. Pearson's r is the usual one. It is the covariance of x and y divided by both standard deviations, so it has no units:
r = sum of (x - x-bar)(y - y-bar) / sqrt(sum of (x - x-bar)^2 x sum of (y - y-bar)^2)
A worked example. The default data are eight made-up pairs, say hours of study and an exam score. The means are 3.875 and 63.75. The cross-product sum is 127.75, the sum of squares in x is 38.875 and in y it is 495.5, so r = 127.75 / sqrt(38.875 x 495.5) = 0.9205. Squared, that is 0.8472: about 85% of the variation in scores moves in step with a straight line in hours. By the usual rule of thumb (0.4 moderate, 0.7 strong) it is a strong positive association.
Is it more than chance? The test of zero correlation is t = r x sqrt((n - 2) / (1 - r^2)), here 0.9205 x sqrt(6 / 0.1528) = 5.769 on 6 degrees of freedom, a two-sided p-value of 0.0012. That is evidence the association is not zero. It is weak evidence about how big it is: on eight pairs the 95% interval for r runs from 0.614 to 0.986.
Spearman's rho ranks each list and takes Pearson's r of the ranks. Two students both studied 2 hours, so they share ranks 2 and 3 as 2.5 each. On the default data rho is 0.9341. Spearman's rho measures any steady rise or fall, curved or straight, and one extreme pair cannot drag it far, because an extreme value is only ever one rank away from its neighbor.
What r cannot tell you. Correlation is not causation. Students who study more may also sleep more, attend more classes or take an easier course, and any of those could drive both numbers. The data would look the same. And r measures linear association only: for x = -2, -1, 0, 1, 2 and y = x squared, y is fixed exactly by x, yet r is exactly 0, because the rise on one side cancels the fall on the other. Plot the points first.
Correlation Coefficient Calculator FAQ
What does a correlation coefficient of 0.7 mean?
A strong positive linear association by the common rule of thumb: as x rises, y tends to rise, and the points lie fairly close to a line. Squared it is 0.49, so a straight line in x accounts for about half the variation in y. It does not mean x causes y.
What is the difference between Pearson and Spearman correlation?
Pearson's r measures how closely the points follow a straight line. Spearman's rho is Pearson's r on the ranks, so it measures any consistent increase or decrease, linear or not, and is less affected by outliers. When the two differ a lot, look for a curve or an extreme pair.
Is a correlation of 0 the same as no relationship?
No. r = 0 means no linear relationship. y = x squared on x from -2 to 2 is an exact relationship with r = 0. A curve, a cluster or two groups pulling opposite ways can all hide behind a small r.
How many data points do you need for a correlation?
At least three to test anything, since two points always give r = 1 or -1. In practice, small samples give wide uncertainty: with eight pairs and r = 0.92 the 95% interval still runs from about 0.61 to 0.99.