Correlation Coefficient Calculator

Correlation Coefficient Calculator

Paste x and y pairs for Pearson r and r², Spearman’s ρ and Kendall’s τb, with a p value, a confidence interval for r, a scatter plot, a ranks table and an outlier check.

Separate x and y with a comma, space or tab. A header row becomes the names.

Every figuretap a card to copy its value

Scatter plot

Ranks table

Pearson r = Sxy ÷ √(Sxx × Syy), from the sums of squares and products of deviations from the means. Spearman ρ applies the same formula to the ranks, with ties sharing their average rank. Kendall τb = (P − Q) ÷ √((P + Q + T)(P + Q + U)). The p values use t with n − 2 degrees of freedom for r and ρ, and a tie corrected normal approximation for τb. The interval for r uses Fisher’s z with standard error 1 ÷ √(n − 3). Strength words follow Schober and colleagues (2018). The CSV, image and printed report contain the values you entered, nothing preloaded.

How to use this tool

Paste your pairs, one per line with x first: 12, 7.4 and 12 7.4 both work, as do two columns copied from a spreadsheet, and a header row such as Height and Weight becomes the names on the chart. The ranks table shows how much r would change without each pair.

The input people most often get wrong is the pairing. Each line must hold two measurements of the same case: the same student, the same day, the same test specimen. Sort one spreadsheet column without the other and the pairs no longer belong together, so r measures nothing. Then choose what to lead with: Spearman for ranks, rating scales or a curve that keeps rising, Pearson for straight line relationships between measurements.

What the calculation is doing

Pearson's r compares how x and y vary together with how much each varies alone: r = Sxy ÷ √(Sxx × Syy), where Sxx and Syy are the sums of squared deviations from the means and Sxy sums the products of the deviations. It lies between −1 and +1, has no units and ignores changes of scale or origin. r² is the share of the variation in y that a straight line accounts for.

The p value uses t = r√(n − 2) ÷ √(1 − r²) with n − 2 degrees of freedom, which assumes roughly normal data. The interval uses Fisher's z transform, z = ½ ln((1 + r) ÷ (1 − r)), which is close to normal with a standard error of 1 ÷ √(n − 3). Tanh turns the interval back into r, which is why it sits lopsided, longer towards zero. The approximation is good from about 10 pairs; below that, treat it as a rough guide.

Spearman's ρ ranks each variable, 1 for the smallest, and applies the same formula to the ranks. Tied values share the average of the ranks they cover, so two values tied for 3rd and 4th both get 3.5. Kendall's τb counts pairs of points in the same order on both variables (P) and in opposite order (Q), with T and U the pairs tied on x only or y only: τb = (P − Q) ÷ √((P + Q + T)(P + Q + U)). Both measure whether y rises with x, not whether it rises in a straight line.

Four scatter plots of Anscombe's quartet, each with 11 points, the same fitted line y = 3 + 0.5x and a Pearson r of 0.816 or 0.817: set I is a straight line trend with scatter and Spearman rho 0.818; set II lies exactly on a curve, with rho 0.691; set III is a perfect line plus one outlier, with rho 0.991 and an r of 1.000 once the outlier is removed; set IV has ten points at x = 8 and one at x = 19, with rho 0.500 and no r at all without that last point
Same r, four different stories. In set IV a single measurement decides the answer, which is why the calculator reports how much r changes when each pair is left out.

Why one number can hide four different stories

Frank Anscombe built his quartet in 1973 to show that summary statistics can match while the data are nothing alike. All four have 11 pairs, the same means, the same least squares line and an r of 0.816 or 0.817. Set I is what r was designed for. Set II is an exact curve. Set III is a perfect line spoiled by one point; remove it and r becomes 1.000. In set IV, ten points show no relationship at all and the eleventh creates the whole correlation.

The reason is how r is built: it is the average product of each pair's standardised scores. Points in the top right and bottom left quarters around the means add to r, the other two quarters subtract, and a point far from both means contributes a very large product. The point at x = 19 in set IV sits three standard deviations from the mean of x, so it dominates. The formula measures how well a line fits; it never checks that the pattern is a line.

Ranks cap that influence, because no rank can exceed n. So ρ for set III is 0.991, recognising the ten points that line up, while r is dragged to 0.816. When r and ρ differ by more than 0.1 the tool says so. And no coefficient shows cause: quantities that both follow the season or the age of a structure correlate strongly without either one driving the other.

Critical values of r and how wide the interval is

The smallest r, ignoring sign, that is significant in a two tailed test, and the 95% Fisher interval around an r of 0.5. With 15 pairs or fewer, an r of 0.5 is still compatible with no correlation at all.

Pairs, nSignificant at 5%at 1%95% interval for r = 0.5
50.8780.959−0.68 to 0.96
80.7070.834−0.32 to 0.89
100.6320.765−0.19 to 0.86
150.5140.641−0.02 to 0.81
200.4440.5610.07 to 0.77
250.3960.5050.13 to 0.75
300.3610.4630.17 to 0.73
400.3120.4030.22 to 0.70
500.2790.3610.26 to 0.68
1000.1970.2560.34 to 0.63
2000.1390.1820.39 to 0.60
5000.0880.1150.43 to 0.56

A worked example you can check on paper

The default data are Anscombe's set I. The x values sum to 99, a mean of 9, and the y values to 82.51, a mean of 7.50091. The x deviations run from −5 to +5, so Sxx = 2 × (1 + 4 + 9 + 16 + 25) = 110; working through the pairs gives Syy = 41.2727 and Sxy = 55.01. Then r = 55.01 ÷ √(110 × 41.2727) = 55.01 ÷ 67.379 = 0.81642, and r² = 0.66654, so the line y = 3.0001 + 0.50009x accounts for 66.7% of the variation in y.

For significance, t = 0.81642 × √9 ÷ √(1 − 0.66654) = 4.241, and with 9 degrees of freedom the two tailed p is 0.00217. For the interval, z = ½ ln(1.81642 ÷ 0.18358) = 1.1460, the standard error is 1 ÷ √8 = 0.35355, and 1.1460 ± 1.960 × 0.35355 gives 0.453 to 1.839, which tanh turns into 0.424 to 0.951.

No values are tied, so the rank shortcut is exact. The rank differences d are 0, 1, 4, −3, 0, 1, −2, 0, −2, 2, −1; their squares sum to 40, and ρ = 1 − 6 × 40 ÷ (11 × 120) = 0.818. For Kendall, 45 of the 55 pairs of points are in the same order on both variables and 10 are not, so τb = (45 − 10) ÷ 55 = 0.636.

Mistakes that catch people out

Reading r as the slope. r says how tightly the points hug a line, not how steep it is; the slope is r × sy ÷ sx, so the same r fits a slope of 0.1 or 100.

Treating a small p value as a strong link. With 1,000 pairs, r = 0.10 gives p = 0.0015 yet explains 1% of the variation. Report r and its interval, not just p.

Using the shortcut formula with ties. 1 − 6Σd² ÷ (n(n² − 1)) is exact only when nothing is tied. On the OpenStax exam data, which has several tied scores, it gives 0.593 against the correct 0.586.

Correlating a narrow range. If every specimen comes from one mix, or every student passed, the spread of x shrinks and r falls even when the underlying relationship is strong.

Mixing groups or correlating averages. Pooling groups with different means can create a correlation found in neither group, and correlating averages instead of individual values inflates r.

Popular calculations

Each link opens the calculator with those pairs filled in. The published sets reproduce their sources; the shapes and tied data are small illustrations of one effect each.

Anscombe's quartet

Textbook and published examples

Perfect, curved and tricky shapes

Ranked and tied data

How this was checked

The Anscombe sets come from section 1.1.6 of the NIST/SEMATECH Handbook of Statistical Methods, checked value for value against the anscombe file in the R source code, and the tool reproduces the handbook: r of 0.816 for sets I to III and 0.817 for set IV, the line y = 3 + 0.5x and residual standard deviations of 1.237 and 1.236. It also matches the OpenStax Introductory Statistics exam example (r = 0.6631, p = 0.026), the Penn State STAT 505 Fisher interval for r = 0.77153 with 37 pairs (0.5967 to 0.8764), the Wikipedia Spearman example of IQ against hours of television (Σd² = 194, ρ = −0.176, p = 0.627), and the tied examples in the SciPy documentation, ρ = 0.8207827 with p = 0.0885870 and τb = −0.4714045 with p = 0.2827455, to 12 decimal places or better.

A separate script checked 2,997 random data sets, many heavily tied or offset: r matched the raw sums formula and the average product of z scores within 3 × 10⁻¹⁵, ρ matched brute force ranking, τb matched a direct count of sign products, and p values matched the closed form t distribution of Abramowitz and Stegun within 2 × 10⁻¹³. Critical values matched 54 of 56 cells of the University of Connecticut r table, the other two differing by one in the printed last digit. In 20,000 simulations of 10 uncorrelated pairs, p fell below 0.05 in 4.91% of runs, and the 95% Fisher interval covered a true correlation of 0.6 in 94.95% of runs with 20 pairs. Every address in the lists above was opened to confirm its title and answer.

Common questions

What is a good correlation coefficient?

A common convention, from Schober and colleagues (2018), calls 0.10 to 0.39 weak, 0.40 to 0.69 moderate, 0.70 to 0.89 strong and 0.90 or more very strong, and the authors warn that the cutoffs are arbitrary. Two instruments measuring the same thing should agree far more closely than two human behaviours.

What is the difference between Pearson and Spearman correlation?

Pearson's r measures how well a straight line fits the values. Spearman's ρ is the same calculation on the ranks, so it measures any steadily rising or falling trend and resists outliers. For 2, 4, 8 and so on up to 1,024 against 1 to 10, ρ = 1.000 while r = 0.799. Kendall's τb also works on order and suits small samples with many ties.

How do you calculate the correlation coefficient by hand?

Sum the products of the deviations from the two means to get Sxy, and the squared deviations to get Sxx and Syy; then r = Sxy ÷ √(Sxx × Syy). For the default data, 55.01 ÷ √(110 × 41.2727) = 0.8164.

What does r squared tell you?

It is the share of the variation in y that a straight line in x accounts for. An r of 0.816 gives r² = 0.667: about 67% explained and 33% not. A high r² does not prove the pattern is straight, as Anscombe's set II shows.

How many data points do you need for a correlation?

The calculator needs 3 pairs for r and 4 for an interval, but precision takes far more. For an r of 0.5 the 95% interval is −0.19 to 0.86 with 10 pairs, 0.17 to 0.73 with 30 and 0.34 to 0.63 with 100.

Does a correlation of zero mean there is no relationship?

No, only that there is no straight line trend. The U shaped data y = x² for x from −4 to 4 give r = 0 and ρ = 0, although y is fixed exactly by x.

Related Calculators and Reference