Pearson Correlation Calculator

Measure linear relationship strength.

Independent variable

Dependent variable

Load example data:

Enter paired X and Y values to calculate correlation

Minimum 3 pairs required, both columns must have equal length

What Is Pearson Correlation?

Pearson correlation coefficient (rr) measures the strength and direction of the linear relationship between two continuous variables. It quantifies how closely data points follow a straight line.

Question answered: "How strongly are these two variables linearly related?"

Examples:

  • "How strongly does study time relate to exam scores?"
  • "Is there a relationship between height and weight?"
  • "Do advertising spending and sales move together?"

The Correlation Coefficient

rr ranges from -1 to +1:

ValueInterpretation
r = +1Perfect positive correlation
r = +0.7 to +1Strong positive
r = +0.4 to +0.7Moderate positive
r = +0.2 to +0.4Weak positive
r = 0No linear relationship
r = -0.2 to -0.4Weak negative
r = -0.4 to -0.7Moderate negative
r = -0.7 to -1Strong negative
r = -1Perfect negative correlation

Understanding Direction

Positive correlation (r>0r > 0): As X increases, Y tends to increase. Example: Height and weight

Negative correlation (r<0r < 0): As X increases, Y tends to decrease. Example: Price and demand

Zero correlation (rβ‰ˆ0r \approx 0): No linear pattern. Note: Non-linear relationships may have rβ‰ˆ0r \approx 0!

The Formula

r=βˆ‘i=1n(xiβˆ’xΛ‰)(yiβˆ’yΛ‰)βˆ‘i=1n(xiβˆ’xΛ‰)2Γ—βˆ‘i=1n(yiβˆ’yΛ‰)2r = \frac{\sum_{i=1}^{n}(x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum_{i=1}^{n}(x_i - \bar{x})^2 \times \sum_{i=1}^{n}(y_i - \bar{y})^2}}

Or equivalently:

r=SxySxxΓ—Syyr = \frac{S_{xy}}{\sqrt{S_{xx} \times S_{yy}}}

Where:

  • SxyS_{xy} = sum of cross-products of deviations
  • SxxS_{xx} = sum of squared deviations for X
  • SyyS_{yy} = sum of squared deviations for Y

Example Calculation

Data: Study hours (X) and exam scores (Y)

HoursScore
265
370
472
580
685

Calculations:

  • xΛ‰=4\bar{x} = 4, yΛ‰=74.4\bar{y} = 74.4
  • Sxy=36S_{xy} = 36, Sxx=10S_{xx} = 10, Syy=258.8S_{yy} = 258.8

r=3610Γ—258.8=3650.87=0.708r = \frac{36}{\sqrt{10 \times 258.8}} = \frac{36}{50.87} = 0.708

Strong positive correlation: more study hours associate with higher scores.

Coefficient of Determination (r2r^2)

r2=proportion of variance in Y explained by Xr^2 = \text{proportion of variance in Y explained by X}

For r=0.708r = 0.708: r2=0.50r^2 = 0.50

Interpretation: 50% of variation in exam scores is "explained" by study hours.

The remaining 50% is due to other factors.

Testing Significance

Is the correlation significantly different from zero?

t=rΓ—nβˆ’21βˆ’r2t = r \times \sqrt{\frac{n-2}{1-r^2}}

With df=nβˆ’2df = n - 2

For r=0.708r = 0.708, n=5n = 5:

t=0.708Γ—30.50=0.708Γ—2.45=1.73t = 0.708 \times \sqrt{\frac{3}{0.50}} = 0.708 \times 2.45 = 1.73

P-value β‰ˆ0.18\approx 0.18 (not significant at Ξ±=0.05\alpha = 0.05)

With only 5 points, even moderate correlation may not be significant.

Use correlation p-value calculator for precise values.

Sample Size and Significance

Sample Sizer needed for p < 0.05
100.63
200.44
300.36
500.28
1000.20
5000.09

Small correlations become significant with large samples. Always report rr alongside p-value.

Correlation β‰  Causation

Critical warning: Correlation does not imply causation.

Possible explanations for correlation:

  1. X causes Y
  2. Y causes X
  3. Third variable causes both
  4. Coincidence

Example: Ice cream sales and drowning deaths are correlated. Reality: Hot weather causes both. Ice cream doesn't cause drowning.

When Pearson Correlation Fails

Non-Linear Relationships

A perfect parabolic relationship may have r=0r = 0.

Always plot your data first!

Outliers

Single extreme points can dramatically change rr.

Outliers may inflate or mask true correlation.

Restricted Range

If X has limited variability, correlation is attenuated.

Studying only honors students may hide the full correlation between study time and grades.

Heteroscedasticity

If Y's spread changes across X values, Pearson rr may be misleading.

Assumptions

Linearity

The relationship between X and Y is linear.

Check with scatterplot.

Continuous Variables

Both X and Y are measured on interval or ratio scales.

For ordinal data, use Spearman correlation.

Bivariate Normality

For significance testing, the joint distribution should be approximately normal.

No Significant Outliers

Outliers disproportionately influence rr.

Homoscedasticity

The variance of Y is constant across levels of X.

Applications

Research and Science

Testing hypothesized relationships between variables.

"Is there evidence of a relationship between exposure and outcome?"

Finance

Measuring how assets move together.

Portfolio diversification relies on low or negative correlations.

Quality Control

Relating process parameters to output quality.

"How strongly does temperature affect product strength?"

Psychology

Validating measurement instruments.

Test-retest reliability, convergent validity.

Medicine

Relating biomarkers to outcomes.

"How well does this marker predict disease severity?"

Correlation Matrix

For multiple variables, compute all pairwise correlations:

X₁Xβ‚‚X₃
X₁1.000.72-0.35
Xβ‚‚0.721.00-0.18
X₃-0.35-0.181.00

Matrix is symmetric; diagonal is always 1.

Partial Correlation

Control for a third variable:

rxy.zr_{xy.z} = correlation between X and Y, holding Z constant.

Reveals whether X-Y relationship persists after accounting for Z.

Confidence Interval for r

Use Fisher's z-transformation:

zβ€²=12ln⁑(1+r1βˆ’r)z' = \frac{1}{2} \ln\left(\frac{1+r}{1-r}\right)

SESE of zβ€²=1/nβˆ’3z' = 1/\sqrt{n-3}

Calculate CI in z-space, then transform back.

Comparing Correlations

To test if two correlations differ:

Convert both to zβ€²z' (Fisher transformation)

z=z1β€²βˆ’z2β€²1n1βˆ’3+1n2βˆ’3z = \frac{z'_1 - z'_2}{\sqrt{\frac{1}{n_1-3} + \frac{1}{n_2-3}}}

Reporting Results

APA format:

"There was a strong positive correlation between study hours and exam scores, r(3) = .71, p = .18. However, with only 5 participants, this correlation did not reach statistical significance."

For significant results:

"Hours of sleep was significantly correlated with reaction time, r(98) = -.45, p < .001, indicating that less sleep was associated with slower responses."

Historical Context

Karl Pearson developed this correlation coefficient in the 1890s, building on earlier work by Francis Galton.

Galton first used the concept of correlation to study heredityβ€”how parent and offspring characteristics relate.

Pearson formalized the mathematics and gave us the formula still used today. His work established correlation as a fundamental tool for understanding relationships between variables.

Common Mistakes

Confusing Correlation with Causation

The most common error. Always consider alternative explanations.

Ignoring Non-Linearity

A scatterplot reveals patterns that rr misses.

Over-Interpreting Small Correlations

With large nn, trivially small rr can be "significant."

Reporting r2r^2 as rr

r=0.30r = 0.30 is not the same as r2=0.30r^2 = 0.30.

Related Calculations

Summary

Pearson correlation coefficient (rr) measures the linear relationship between two continuous variables, ranging from -1 (perfect negative) to +1 (perfect positive). Calculate using the formula involving cross-products of deviations, then test significance using a t-test with df=nβˆ’2df = n-2. Always visualize data with a scatterplot firstβ€”rr only captures linear relationships. Report both rr and p-value, recognize that correlation does not imply causation, and be cautious with outliers. For ordinal data or non-linear monotonic relationships, use Spearman correlation instead.