Pearson Correlation Calculator

Pearson Correlation Calculator

Measure the strength of a straight-line relationship between two variables: Pearson's r with its p-value, 95% confidence interval, r² and a scatter plot.

r = Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)² Σ(y − ȳ)²)

In the same order, so each X lines up with its Y. At least 3 pairs.

Enter paired X and Y values

What is the Pearson Correlation?

Pearson's r measures how closely two variables follow a straight line, on a scale from −1 to +1. +1 is a perfect rising line, −1 a perfect falling line and 0 no straight-line pattern at all.

It's covariance with the units stripped out, so height in centimetres or inches gives the same r. That makes it easy to compare relationships measured in completely different units.

r only captures straight-line patterns. A perfect U-shape can have r = 0, and a single outlier can create or destroy a strong r, which is why the scatter plot matters as much as the number.

Pearson Correlation Formula

As given in OpenStax Introductory Statistics, sections 12.3 and 12.4; Fisher's z interval as in Fisher (1915). See Sources.

1. Sums of products and squares

Sxy = Σ(x − x̄)(y − ȳ) · Sxx = Σ(x − x̄)² · Syy = Σ(y − ȳ)²

2. r and its test

r = Sxy ÷ √(Sxx × Syy)
t = r √((n − 2) ÷ (1 − r²)), df = n − 2

3. Confidence interval via Fisher's z

z = atanh(r) ± 1.96 ÷ √(n − 3), then back with tanh

Worked Example: Revision Hours and Exam Marks

Given:
Eight students' revision hours 1, 2, 3, 4, 5, 6, 7, 8 and marks 52, 55, 61, 62, 68, 70, 74, 79.
Step 1:
Sums:
x̄ = 4.5, ȳ = 65.125 · Sxy = 158.5 · Sxx = 42 · Syy = 604.875
Step 2:
r:
158.5 ÷ √(42 × 604.875) = 158.5 ÷ 159.39 = 0.9944
Step 3:
Test and interval:
t = 23.1, df 6, p < 0.001 · 95% CI 0.968 to 0.999
Result:
r = 0.994, a very strong positive relationship

r² = 98.9%: almost all the variation in marks lines up with revision time in this small class. Real classes are rarely this tidy, and a strong r still wouldn't prove revision caused the marks.

Smallest Significant r by Sample Size

Two-tailed, 5% level. With small samples only strong correlations reach significance; with large ones, even weak ones do.

Critical values of r
Pairs (n)|r| needed
50.878
100.632
200.444
300.361
500.279
1000.197
1,0000.062

Common Pearson Correlation Mistakes

  • Reading correlation as causation. Ice-cream sales and drownings correlate because both rise in summer, not because one causes the other.
  • Skipping the scatter plot. Very different patterns can share the same r. Anscombe's quartet has four datasets with r = 0.82 that look nothing alike.
  • Using r for curved relationships. A strong curve can give a weak r. Use Spearman's ρ for monotonic curves, or fit a curve.
  • Mixing groups. Combining two groups with different averages can create a correlation that exists in neither, or hide one that exists in both.

Pearson Correlation FAQs

What is a strong correlation?

Rough guide for |r|: below 0.3 weak, 0.3–0.5 moderate, 0.5–0.7 fairly strong, above 0.7 strong. What counts as strong depends on the field.

What does r² mean?

The share of variation in one variable that lines up with the other in a straight-line fit. r = 0.7 gives r² = 49%.

Does the order of X and Y matter?

No. r is symmetric: swapping X and Y gives the same value.

What are the assumptions of the test?

Independent pairs, a roughly straight-line relationship and approximately normal data. Outliers can distort it badly.

When should I use Spearman instead?

For ranked or ordinal data, for curved but steadily rising or falling relationships, or when outliers are a worry.

Why is the confidence interval lopsided?

r is bounded by −1 and 1, so intervals near the ends are squeezed. Fisher’s z transformation handles this.

How do I calculate r in Excel?

=CORREL(x_range, y_range) or =PEARSON(x_range, y_range).

Can r be significant but tiny?

Yes. With 1,000 pairs, r = 0.07 is significant at 5% but explains under 1% of the variation.

Sources

Related Tools