Correlation Coefficient Calculator

Paste paired X and Y data for Pearson r, r², Spearman ρ, the t statistic and two-tailed p-value, a strength rating and a scatter plot with fitted line.

Free No Signup Required Browser-Based
Example datasets

Separate values with spaces, commas or new lines. The first X pairs with the first Y, and so on.

Pearson correlation coefficient
r = 0.8164
Strong positive linear relationship · statistically significant at α = 0.05 (p = 0.0022)
r²
0.6665
66.7% of variance shared
95% CI for r
0.424 to 0.951
Fisher z method
Spearman ρ
0.8182
p ≈ 0.0021
n (pairs)
11
df = 9
t statistic
4.2415
9 degrees of freedom
p-value (two-tailed)
0.0022
Covariance (sample)
5.501

Least-squares line: y = 3.0001 + 0.5001x. Means: x̄ = 9, ȳ = 7.5009. Sample SDs: sx = 3.3166, sy = 2.0316.

49144.267.5510.84XY
Check the plot before trusting r: a curve, a cluster or one far-off point can produce the same coefficient as a clean straight line.
Show the ranks used for Spearman ρ
#XYRank XRank Y
1108.0477
286.9554
3137.58106
498.8169
5118.3388
6149.961110
767.2435
844.2611
91210.84911
1074.8242
1155.6823

Tied values share the average of the ranks they cover. ρ is the Pearson correlation of these two rank columns.

What Correlation Coefficient Calculator Does

This correlation calculator takes paired X and Y data and returns Pearson’s r with a 95% confidence interval, r², Spearman’s rank correlation ρ, the t statistic and the two-tailed p-value on n − 2 degrees of freedom. A scatter plot with the least-squares line shows whether a straight line is a fair summary of the points. Paste two lists, or two columns copied from a spreadsheet; the calculation runs in your browser as you type.

The example datasets are published ones, so you can check the output against a known answer. Anscombe’s set I gives r = 0.8164, t = 4.2415 on 9 degrees of freedom and p = 0.00217, with a 95% interval of 0.424 to 0.951. R’s cor.test reports the same figures for that data. Set II has almost the same r, 0.8162, but its points lie on a curve. The plot makes that obvious, and the drop in Spearman’s ρ from 0.818 to 0.691 hints at it, while r alone gives no sign.

At least 3 pairs are needed, and neither variable can be constant. With 2 points r is always +1 or −1, and a column with no spread has no correlation to measure.

How to Use Correlation Coefficient Calculator

  1. Paste X values and Y values as two lists, or switch to two columns copied from a spreadsheet
  2. Check that each X has one matching Y; the calculator needs at least 3 pairs
  3. Read Pearson r, its strength rating and the two-tailed p-value
  4. Compare Spearman ρ with r and look at the scatter plot for curves or outliers
  5. Open the rank table to see how tied values were ranked for Spearman ρ

Formula Used by Correlation Coefficient Calculator

Pearson correlation coefficient

r = Σ(xᵢ − x̄)(yᵢ − ȳ) ÷ √[ Σ(xᵢ − x̄)² × Σ(yᵢ − ȳ)² ]

xᵢ, yᵢ
The i-th pair of values
x̄, ȳ
The mean of the x values and of the y values
n
Number of pairs

Worked example

x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5.

  1. x̄ = 3, ȳ = 4
  2. x − x̄ = −2, −1, 0, 1, 2 and y − ȳ = −2, 0, 1, 0, 1
  3. Σ(x − x̄)(y − ȳ) = 4 + 0 + 0 + 0 + 2 = 6
  4. Σ(x − x̄)² = 10 and Σ(y − ȳ)² = 6
  5. r = 6 ÷ √60 = 0.7746

Result: r = 0.7746 and r² = 0.60. The least-squares line is y = 2.2 + 0.6x.

Significance test for r

t = r × √(n − 2) ÷ √(1 − r²), with n − 2 degrees of freedom; two-tailed p = 2 × P(T > |t|)

T
A Student’s t random variable with n − 2 degrees of freedom

Worked example

The same five pairs, r = 0.7746.

  1. t = 0.7746 × √3 ÷ √0.4 = 2.1213
  2. df = 5 − 2 = 3
  3. Two-tailed p = 0.1240

Result: p = 0.124, so the correlation is not significant at the 0.05 level with only five pairs.

Spearman rank correlation

ρ = Pearson r of the ranks of x and the ranks of y, with tied values given the average of the ranks they occupy

Worked example

The same five pairs.

  1. Ranks of x: 1, 2, 3, 4, 5
  2. y = 2, 4, 5, 4, 5. The two 4s share positions 2 and 3, so each gets 2.5; the two 5s share 4 and 5, so each gets 4.5
  3. Ranks of y: 1, 2.5, 4.5, 2.5, 4.5
  4. Pearson r of the two rank columns = 0.7379

Result: ρ = 0.7379, with p ≈ 0.155 from the same t approximation.

95% confidence interval for r (Fisher z)

z = atanh(r); z ± 1.96 ÷ √(n − 3); convert both ends back with tanh

Worked example

Anscombe set I: r = 0.8164, n = 11.

  1. z = atanh(0.8164) = 1.1460
  2. 1.96 ÷ √8 = 0.6930
  3. 1.1460 − 0.6930 = 0.4530 and 1.1460 + 0.6930 = 1.8389
  4. tanh(0.4530) = 0.4244 and tanh(1.8389) = 0.9507

Result: 95% CI 0.424 to 0.951, matching R’s cor.test.

One Rule of Thumb for |r|

Example cut-offs from Schober, Boer and Schwarte (2018). The authors describe such cut-offs as arbitrary and inconsistent, so treat the label as a rough guide.

|r|Label
0.00–0.10Negligible
0.10–0.39Weak
0.40–0.69Moderate
0.70–0.89Strong
0.90–1.00Very strong

Source: Schober, Boer and Schwarte (2018), Anesthesia & Analgesia 126(5)

Critical Values of r (Two-Tailed)

The smallest |r| that is significant at each level, from t = r√(n − 2) ÷ √(1 − r²) with n − 2 degrees of freedom.

n (pairs)dfα = 0.05α = 0.01
530.8780.959
1080.6320.765
15130.5140.641
20180.4440.561
30280.3610.463
50480.2790.361
100980.1970.256

Same r, Different Data: Anscombe Sets I and II

Both sets use the same 11 x values. Computed with this calculator.

DatasetPearson rSpearman ρp (Pearson)
Set I (roughly straight)0.81640.81820.00217
Set II (curved)0.81620.69090.00218

How to Read Your Result

Sign and size

A positive r means y tends to rise as x rises; a negative r means it tends to fall. The size says how tightly the points hug a straight line, from 0 (no linear pattern) to 1 (every point on the line). It says nothing about the slope: a nearly flat line and a steep one can both have r = 0.99.

Significant is not the same as strong

The p-value tests whether the population correlation could be zero, and it depends heavily on sample size. With 100 pairs, r = 0.197 is significant at 0.05, yet r² = 0.039 means the line accounts for under 4% of the variation. With 5 pairs, r = 0.7746 is not significant. Report r and its confidence interval as well as p.

When Pearson and Spearman disagree

Spearman’s ρ only asks whether y rises (or falls) steadily as x rises, so a consistent curve can score high on ρ and lower on r. One extreme point usually moves r much more than ρ. If the two differ by a lot, look at the scatter plot before choosing which to report.

Always look at the plot

Anscombe built his four datasets in 1973 to show that identical summary statistics can come from completely different patterns. Sets I and II above share r ≈ 0.816 and p ≈ 0.002, but only set I is a fair fit for a straight line.

Limitations & Accuracy Notes

  • The Pearson p-value and confidence interval assume independent pairs drawn from a roughly bivariate normal population. Time series, repeated measurements on the same person and clustered data break the independence assumption and make p too small.
  • The Spearman p-value uses the t approximation, as in Wikipedia’s worked example. For very small samples, exact permutation tables can give a somewhat different value.
  • The confidence interval needs at least 4 pairs and is an approximation that improves as n grows.
  • Kendall’s tau, partial correlation and weighted correlation are not calculated.
  • A restricted range of x (for example, only tall people) lowers r compared with the full population, and a few outliers can raise or lower it sharply.
  • Correlation measures association. It does not show that one variable causes the other.

Frequently Asked Questions

How do you calculate the correlation coefficient?

Subtract the mean from every x and every y, multiply each pair of deviations and add them up, then divide by the square root of (sum of squared x deviations × sum of squared y deviations). For x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5 that is 6 ÷ √(10 × 6) = 0.7746.

How do you find the p-value for a correlation?

Convert r to t = r√(n − 2) ÷ √(1 − r²) and look it up in the t distribution with n − 2 degrees of freedom, doubling the one-tail area for a two-tailed test. For Anscombe’s first dataset, r = 0.8164 with n = 11 gives t = 4.2415 on 9 df and p = 0.00217, the same as R’s cor.test.

What is a strong correlation coefficient?

One widely cited table (Schober, Boer and Schwarte, 2018) calls |r| below 0.10 negligible, 0.10–0.39 weak, 0.40–0.69 moderate, 0.70–0.89 strong and 0.90–1.00 very strong. The authors themselves call these cut-offs arbitrary, so judge r against what is normal in your field.

What is the difference between Pearson and Spearman correlation?

Pearson r measures how well the points fit a straight line and uses the raw values. Spearman ρ ranks each variable first and correlates the ranks, so it measures any steady upward or downward trend, straight or curved, and is less swayed by a single extreme value.

What does r squared mean?

r² is the share of the variation in one variable that a straight-line fit on the other accounts for. r = 0.7746 gives r² = 0.60, so the line accounts for 60% of the variance in y. It is never negative, so it loses the direction of the relationship.

Is a correlation of 0.77 significant?

It depends on the sample size. With 5 pairs, r = 0.7746 gives p = 0.124, not significant at 0.05, because with 3 degrees of freedom r has to reach 0.878. With 11 pairs the cut-off falls to 0.602, and with 30 pairs to 0.361.

Does correlation prove causation?

No. A correlation can come from a third variable that drives both, from reverse causation, or from chance in a small sample. A significant r only says the linear association is unlikely to be zero in the population the data came from.

References & Further Reading

By OnlineToolHubs Team • Updated October 2026