Linear Correlation Coefficient Calculator

This linear correlation coefficient calculator gives Pearson r for paired data, with r², a significance test, a 95% confidence interval and a scatter plot.

Checks on your data

  • Correlation measures straight-line association only. A curve can have r near 0 and still be a perfect relationship, so look at the scatter plot. Correlation does not show that x causes y.
  • With fewer than 10 pairs, r is unstable and the confidence interval will be wide.

Results

Pearson correlation r
0.997649
very strong positive
Coefficient of determination r²
0.995304
99.53% of the variation in y
Sample size n
8
t statistic
35.662
df = 6
p-value (two-tailed)
3.241×10^-8
95% confidence interval for ρ
0.98651 to 0.99959
Spearman rank correlation
1
Line of best fit
y = 0.171429 + 1.97857x
Scatter plot with line of best fit (r = 0.9976)
510152468xy
Show step-by-step solution
  1. Means: x̄ = 4.5, ȳ = 9.075.
  2. Sxy = Σ(x − x̄)(y − ȳ) = 83.1, Sxx = 42, Syy = 165.195.
  3. r = Sxy ÷ √(Sxx × Syy) = 83.1 ÷ √(42 × 165.195) = 0.997649.
  4. t = r √(n − 2) ÷ √(1 − r²) = 35.662 with 6 degrees of freedom, giving a two-tailed p-value of 3.2414 × 10^-8.
  5. The confidence interval applies Fisher’s z-transform: z′ = arctanh(r), standard error 1 ÷ √(n − 3), then back-transform with tanh.
Range−1 to 1
r = 0No linear trend
r²Share of variation explained
Testt with n − 2 df

What Is Linear Correlation Coefficient?

The linear correlation coefficient r measures how closely paired data follow a straight line. It runs from −1 for a perfect downward line, through 0 for no linear trend, to +1 for a perfect upward line.

Paste your x and y values in matching order. The calculator returns r and r², the t statistic and two-tailed p-value, a Fisher z confidence interval for the true correlation and the Spearman rank correlation as a cross-check.

A scatter plot with the line of best fit is shown, because r alone cannot reveal curves or outliers.

How to Use the Linear Correlation Coefficient Calculator

  1. Paste the x values.
  2. Paste the y values in the same order.
  3. Read r, r², the p-value and the interval.
  4. Check the scatter plot for curves and outliers.

Linear Correlation Coefficient Formula

Pearson r

r=∑(x−xˉ)(y−yˉ)∑(x−xˉ)2∑(y−yˉ)2r=\frac{\sum (x-\bar x)(y-\bar y)}{\sqrt{\sum (x-\bar x)^2\sum (y-\bar y)^2}}

Test statistic

t=rn−21−r2t=\frac{r\sqrt{n-2}}{\sqrt{1-r^2}}

Linear Correlation Coefficient Variables Explained

SymbolMeaningNotes
rSample correlation coefficient
r²Share of variance explained
ρPopulation correlation
nNumber of pairs

Linear Correlation Coefficient Worked Example

For x = 1 to 8 and y = 2.3, 4.1, 5.8, 8.4, 9.7, 12.5, 13.6, 16.2, the points rise almost on a straight line. The calculator gives r = 0.998, so r² = 0.995: about 99.5% of the variation in y is explained by the straight-line relationship with x.

With the example values loaded in the calculator above, the steps are:

  1. Means: x̄ = 4.5, ȳ = 9.075.
  2. Sxy = Σ(x − x̄)(y − ȳ) = 83.1, Sxx = 42, Syy = 165.195.
  3. r = Sxy ÷ √(Sxx × Syy) = 83.1 ÷ √(42 × 165.195) = 0.997649.
  4. t = r √(n − 2) ÷ √(1 − r²) = 35.662 with 6 degrees of freedom, giving a two-tailed p-value of 3.2414 × 10^-8.
  5. The confidence interval applies Fisher’s z-transform: z′ = arctanh(r), standard error 1 ÷ √(n − 3), then back-transform with tanh.

Result: Pearson correlation r = 0.997649.

How to Read a Correlation Coefficient

The sign of r gives the direction and its size gives the strength of a straight-line relationship. For x = 1 to 8 and y = 2.3 to 16.2, r = 0.998 and r² = 0.995, so about 99.5% of the variation in y is explained by the line.

The p-value tests whether the true correlation could be zero. The confidence interval for ρ shows how precisely r is estimated, and it is wide for small samples. If the Spearman value is close to r, the relationship does not depend on the exact numerical spacing of the data.

Where Linear Correlation Coefficient Is Used

Reporting r

State r with its p-value and a confidence interval.

Checking linearity

Compare Pearson and Spearman and look at the scatter plot.

Business and science

Test whether two measures move together.

Homework

Verify r by hand from the sums.

Common Linear Correlation Coefficient Mistakes to Avoid

  • Always look at the scatter plot. A curve can have r near 0.
  • Correlation does not show cause.
  • One outlier can change r a lot.
  • With under 10 pairs, treat r as rough.

Linear Correlation Coefficient Terms and Definitions

ρ
The population correlation that the sample r estimates.

Linear Correlation Coefficient FAQs

How do you calculate the linear correlation coefficient?

Divide the sum of cross-products of deviations by the square root of the product of the two sums of squared deviations.

What is a good correlation coefficient?

It depends on the field. As a rough guide, the size is weak below 0.4, moderate from 0.4 to 0.7 and strong above 0.7.

What is the difference between r and r²?

r gives direction and strength. r² is the proportion of variance in y accounted for by the line.

When should I use Spearman instead of Pearson?

Use Spearman for ranked data, clear outliers, or a relationship that is steadily rising or falling but not straight.

Related calculators

Last updated 2026-11-09. See our disclaimer.