Home ↓
CalculatorsVerified

Math & Geometry

Correlation Coefficient Calculator (Pearson r and p-value)

The Pearson correlation coefficient, usually written r, measures how closely two variables follow a straight-line relationship. It ranges from minus 1, a perfect negative linear relationship in which one variable falls as the other rises, through 0, no linear relationship, to plus 1, a perfect positive linear relationship. It was developed by Karl Pearson in the 1890s, building on work by Francis Galton, and is used across science, medicine, economics and data analysis to summarise how two measurements move together, such as height and weight, study hours and exam scores, or advertising spending and sales. The coefficient is the covariance of the two variables divided by the product of their standard deviations, which removes the units so that r is comparable between datasets. Squaring it gives r squared, the proportion of the variation in one variable that is explained by a linear relationship with the other. To judge whether an observed correlation could have arisen by chance, the calculator converts r to a t statistic with n minus 2 degrees of freedom and gives the two-sided p-value. Enter the two lists of paired values in the same order. For x values 1 to 5 and y values 2, 4, 5, 4 and 5, r is about 0.775, r squared is 0.6, meaning 60 percent of the variation in y is linearly associated with x, and the p-value is about 0.12, not significant with only five pairs. Always look at a scatter plot as well: Pearson r captures only linear patterns, can be distorted by a single outlier and can be near zero for strong curved relationships.

How to use this calculator

  1. Type or paste the x values.
  2. Type or paste the matching y values in the same order.
  3. Make sure both lists have the same number of values.
  4. Read r, r² and the p-value.
  5. Plot the data to check for curves and outliers.

Correlation is not causation

A strong correlation does not show that one variable causes the other. Both may be driven by a third factor, the direction of causation may be reversed, or the relationship may be coincidental, especially when many variables are examined. Ice cream sales and drowning rates are correlated because both rise in hot weather, not because one causes the other.

Establishing causation requires careful study design, such as randomised experiments, or methods that account for confounding factors in observational data.

Alternatives to Pearson r

Spearman's rank correlation measures how well the relationship can be described by any increasing or decreasing function, using ranks rather than raw values, which makes it robust to outliers and suitable for ordinal data. Kendall's tau is another rank-based measure.

For predicting one variable from another, linear regression gives the equation of the best-fitting line, and its r² is the square of the Pearson correlation when there is one predictor.

Formula & method

r = Σ(x − x̄)(y − ȳ) ÷ √[Σ(x − x̄)² × Σ(y − ȳ)²]r² = share of the variation in y explained by a straight-line relationship with xt = r × √(n − 2) ÷ √(1 − r²), with n − 2 degrees of freedomSample covariance = Σ(x − x̄)(y − ȳ) ÷ (n − 1)

r = Σ(x − x̄)(y − ȳ) ÷ √[Σ(x − x̄)² Σ(y − ȳ)²]. t = r√(n − 2) ÷ √(1 − r²), df = n − 2. Covariance = Σ(x − x̄)(y − ȳ) ÷ (n − 1).

Worked example

Five pairs of values

  1. x̄ = 3, ȳ = 4; Σ(x − x̄)(y − ȳ) = 6; Σ(x − x̄)² = 10; Σ(y − ȳ)² = 6.
  2. r = 6 ÷ √(10 × 6) = 0.7746; r² = 0.6.
  3. t = 0.7746 × √3 ÷ √0.4 = 2.121, df = 3, p = 0.124.

Answer: The correlation is moderately strong but not significant with five pairs.

Frequently asked questions

What does a correlation of 0.8 mean?

A strong positive linear relationship; about 64% of variation is shared.

Can r be greater than 1?

No. It always lies between −1 and +1.

What is r squared?

The proportion of variance in one variable explained by a linear relationship with the other.

How many data points do I need?

At least 3, but many more for reliable conclusions; small samples give unstable r.

Is a significant correlation important?

Not necessarily; with large samples even weak correlations are significant.

Does correlation detect curved relationships?

Poorly; Pearson r measures linear association only.