Skip to content

How strongly are two things related?

Pearson's r, Spearman's ρ and the best-fit line of paired data, on a live scatter plot.

Separate with spaces, line breaks or semicolons.

Same count as x, paired in order.

Pearson r

0.976

A strong positive relationship (r = 0.976): y rises with x. The best-fit line y = 3.673x + 47.6 explains 95.3% of the variation in y.

Scatter plot with the best-fit line

Key values as a table
xyLine yResidual
15251.270.7273
25554.950.05455
36158.622.382
45862.29−4.291
56865.962.036
67069.640.3636
76973.31−4.309
87976.982.018
98080.65−0.6545
108684.331.673

Correlation and line

Pairs
10
Pearson r
0.976
Spearman ρ
0.976
Best-fit line
y = 3.673x + 47.6
Slope
3.673 ± 0.2881
Intercept
47.6 ± 1.787
R²
0.9531
Residual standard deviation
2.616
p-value (r = 0)
< 0.001
y on the line at x = 5.5
67.8

Pearson's r, Spearman's ρ and the best-fit line of paired data, on a live scatter plot.

How to use

  1. Paste the x values in the first box and the matching y values in the second, in the same order; a column copied from a spreadsheet works.
  2. Read Pearson's r and the sentence under it; the scatter plot shows each pair, the best-fit line and how far each point lies from it.
  3. Drag the point on the line, or use the arrow keys on it, to read the line's y at any x.

How it works

Correlation measures how closely two quantities move together along a straight line. Pearson's r runs from −1 (a perfect falling line) through 0 (no linear pattern) to +1 (a perfect rising line). Spearman's ρ is the same calculation on the ranks of the values, so it measures any steady rise or fall, not just a straight one, and is less affected by a single extreme point.

The best-fit line y = a + b·x is the one that makes the squared vertical distances to the points (the residuals) as small as possible: b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)², a = ȳ − b·x̄, where x̄ and ȳ are the means. R², the square of r, is the share of the variation in y that the line accounts for. For the example, hours of study 1 to 10 against exam scores, b = 303 ÷ 82.5 ≈ 3.67 points per hour, a ≈ 47.6 and r ≈ 0.976, so the line explains about 95 % of the spread in scores. The methods follow the NIST/SEMATECH e-Handbook of Statistical Methods.

The p-value tests whether the true correlation could be zero, using t = r√((n − 2) ÷ (1 − r²)) with n − 2 degrees of freedom. A strong correlation does not show that one thing causes the other, a curved relationship can have r near 0, and a line should not be trusted far outside the range of the data.

Worked example

What are the best-fit line and the correlation for x = 1 2 3 4 5 and y = 2 4 5 4 5?

  1. The means are x̄ = 3 and ȳ = 4.
  2. The slope is b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)² = 0.6, and the intercept is a = ȳ − b·x̄ = 2.2.
  3. Pearson's r = 0.77, so R² = 60%.

y = 2.2 + 0.6·x with r = 0.77: the line accounts for 60% of the variation in y.

Frequently asked questions

What is a strong correlation?

As a rule of thumb, |r| above 0.7 is strong, 0.3 to 0.7 moderate, 0.1 to 0.3 weak and below 0.1 negligible. What counts as strong also depends on the field: in physics r = 0.9 can be poor, in social science r = 0.4 can matter.

What happens if some cells are not numbers?

The calculator leaves out the whole pair containing a non-number and lists the rejected entry. Check the remaining pairs, since dropping observations can change the relationship.

Should I sort my two columns first?

Keep each x value beside its matching y value. Sorting either column separately changes the pairs and can create a misleading correlation.

Why is no correlation shown when every y value is the same?

Correlation needs variation in both quantities. A constant y still gives a horizontal fitted line, but Pearson’s r and Spearman’s ρ are undefined.

How many pairs can I enter?

Enter between 3 and 500 matching pairs. A small sample can give an unstable result, so inspect the scatter plot as well as the coefficient.

Send feedback