Pearson Correlation Calculator
Calculate pearson correlation with instant, accurate results and clear step-by-step output.
X has 8 values, Y has 8 values, using first 8 paired.
About
The Pearson product-moment correlation coefficient (r) measures the strength and direction of a linear relationship between two continuous variables. It ranges from −1 (perfect negative linear) through 0 (no linear relationship) to +1 (perfect positive linear). Pearson r is the most widely used correlation coefficient and the foundation of linear regression.
Mathematically, r is the covariance of X and Y divided by the product of their standard deviations: r = cov(X,Y) / (σ_X × σ_Y). Equivalently, r = Σ((x−x̄)(y−ȳ)) / √(Σ(x−x̄)² × Σ(y−ȳ)²). The numerator captures how X and Y vary together; the denominator normalizes so the result is dimensionless and bounded in [−1, +1]. The sign of r matches the sign of the covariance, indicating direction.
R² — the coefficient of determination — is the square of r. It represents the proportion of variance in Y explained by X (or vice versa) in a linear model. An r of 0.8 gives R² of 0.64, meaning 64% of the variance in Y is explained by X. R² is the more intuitive effect-size measure for prediction; r preserves the direction of the relationship (sign of the slope).
The standard null-hypothesis test sets H₀: ρ = 0 (true population correlation is zero). The test statistic t = r × √((n−2)/(1−r²)) follows a Student's t distribution with n−2 degrees of freedom under H₀. The two-tailed p-value gives the probability of observing |r| this large or larger if the null were true. Small p suggests rejecting H₀ — but with large n, even trivial r values become statistically significant, so always report effect size alongside p-value.
Pearson r assumes linearity, continuous variables, no significant outliers, roughly normal distributions of both variables (for inference), and homoscedastic residuals. Violate any and consider alternatives: Spearman ρ for ordinal or non-monotonic data, Kendall τ for small samples with ties, point-biserial for binary vs continuous, or regression for predictor-control scenarios. Always plot a scatter plot first — a U-shaped relationship can have r near zero despite a strong deterministic link. Correlation does not imply causation; the observed association may be driven by a third confounder, reverse causality, or coincidence.
How to Use
- 1Enter your X values, comma separatedType the X variable values, separated by commas or whitespace. Example: 1, 2, 3, 4, 5, 6, 7, 8. The parser tolerates newlines and trailing commas.
- 2Enter your Y values, comma separatedType the Y variable values for the same observations, in the same order as X. X and Y must have the same number of values — paired observations are required.
- 3Read the Pearson r and R²The hero shows r and its direction (positive / negative / none). Below it: R² (proportion of variance explained), standard error of estimate, and the regression slope.
- 4Check the t-statistic and p-value for significanceThe t-statistic tests the null hypothesis that the true correlation is zero. The two-tailed p-value is computed exactly using the Student's t CDF with n−2 degrees of freedom.
- 5Interpret with the comparison tableThe table shows common effect-size conventions (small, medium, large) and the minimum r needed for significance at α = 0.05 by sample size — useful for sanity-checking whether your result is meaningful.
Formula
Pearson r (sample correlation):
r = Σ((x − x̄)(y − ȳ)) / √(Σ(x − x̄)² × Σ(y − ȳ)²)
Equivalent form:
r = cov(X, Y) / (σ_X × σ_Y)
Covariance:
cov(X, Y) = Σ((x − x̄)(y − ȳ)) / (n − 1)
Coefficient of determination:
R² = r²
Null hypothesis test:
H₀: ρ = 0 vs H₁: ρ ≠ 0
t = r × √((n − 2) / (1 − r²)) with df = n − 2
Two-tailed p-value (exact, via regularized incomplete beta function):
p = 2 × (1 − F_t(|t|, df)) = I(df/(df+t²), df/2, 0.5)
Least-squares regression line:
β₁ = cov(X, Y) / σ_X² (slope)
β₀ = ȳ − β₁ × x̄ (intercept)
Standard error of estimate:
SE = √(Σ(yᵢ − ŷᵢ)² / (n − 2))
Where:
- x̄, ȳ = sample means of X and Y
- σ_X, σ_Y = sample standard deviations
- n = number of paired observations (n ≥ 3)
- F_t = CDF of Student's t with df degrees of freedom
- I = regularized incomplete beta function
Worked Example
For X = (1, 2, 3, 4, 5, 6, 7, 8) and Y = (2.1, 3.9, 6.2, 7.8, 10.1, 12.0, 14.1, 16.2):
- n = 8, x̄ = 4.5, ȳ = 9.05
- cov(X, Y) ≈ 6.30
- σ_X² ≈ 5.25, σ_Y² ≈ 25.24, σ_X × σ_Y ≈ 11.50
- r ≈ 6.30 / 11.50 ≈ 0.9978 (very strong positive)
- R² ≈ 0.9956 — 99.56% of variance in Y explained by X
- t = 0.9978 × √(6 / (1 − 0.9956)) ≈ 0.9978 × √1363.6 ≈ 36.86
- df = 6, p-value ≈ 0.0000 (highly significant)
- Slope β₁ ≈ 6.30 / 5.25 ≈ 2.00 (best-fit line y = β₀ + 2.00x)
- Intercept β₀ ≈ 9.05 − 2.00 × 4.5 ≈ 0.05
- SE of estimate ≈ 0.18 — residuals are very small
Tips
- Always plot a scatter plot before computing Pearson r — a curvilinear relationship (U-shape) can have r near zero despite a strong deterministic link.
- Report r, R², p-value, and n together. A p < 0.05 with r = 0.10 is statistically significant but practically meaningless for most purposes.
- Check for outliers — a single extreme point can inflate or deflate r dramatically. Try computing r with and without outliers to assess robustness.
- Use Spearman ρ instead of Pearson r if the relationship is monotonic but not linear, or if either variable is ordinal or has heavy outliers.
- Statistical significance depends heavily on sample size. With n = 1000, r = 0.10 is significant; with n = 10, you need r ≥ 0.632 for significance at α = 0.05.
- Correlation does not imply causation. A third variable (confounder) may drive both X and Y. Controlled experiments or causal inference methods are required for causal claims.
Common Mistakes
- Reporting p-value without effect size — with large n, even trivial r is significant. Always report r and R² with p.
- Assuming linearity from r alone — a U-shaped or exponential relationship can have r near zero.
- Ignoring outliers — a single extreme point can shift r dramatically. Use Spearman ρ or robust regression.
- Interpreting correlation as causation — only controlled experiments or causal inference methods establish causation.
- Computing r on non-paired data — X and Y must be paired observations of the same n units. Mixing unpaired X and Y gives meaningless r.
- Using Pearson for ordinal or rank data — use Spearman ρ or Kendall τ instead.
Frequently Asked Questions
- What does Pearson correlation measure?
- Pearson r measures the strength and direction of a linear relationship between two continuous variables, ranging from −1 (perfect negative linear) through 0 (no linear relationship) to +1 (perfect positive linear). It is the most widely used correlation coefficient and is computed as the covariance of X and Y divided by the product of their standard deviations. Pearson r only captures linear association — a curvilinear relationship can have r near zero despite a strong deterministic link.
- What is the difference between r and R²?
- r is the correlation coefficient (range −1 to +1). R² (coefficient of determination) is r squared (range 0 to 1). R² represents the proportion of variance in Y that is explained by X in a linear model — if r = 0.8, then R² = 0.64, meaning 64% of the variance in Y is explained by X. R² is the more intuitive effect-size measure for prediction, while r preserves direction.
- How is the p-value computed?
- Under the null hypothesis (true correlation is zero), the test statistic t = r × √((n−2)/(1−r²)) follows a Student's t distribution with n−2 degrees of freedom. The two-tailed p-value is the probability of observing |t| this large or larger under that distribution. The calculator computes this exactly using the regularized incomplete beta function for the Student's t CDF.
- What does a significant p-value mean?
- A small p-value (typically < 0.05) means the observed correlation is unlikely under the null hypothesis of no linear relationship. It does NOT mean the correlation is strong — with large n, even trivial r values become statistically significant. Always report effect size (r and R²) alongside p-value. A p < 0.05 with r = 0.1 is statistically significant but practically meaningless for most purposes.
- When is Pearson correlation inappropriate?
- Pearson assumes (1) linearity, (2) continuous variables, (3) no significant outliers, (4) roughly normal distributions of both variables (for inference), and (5) homoscedastic residuals. Violate any and consider alternatives: Spearman ρ for ordinal or non-monotonic data, Kendall τ for small samples with ties, point-biserial for binary vs continuous, or regression for predictor-control scenarios.
- How many data points do I need?
- Theoretically 3, but practically you want at least 10–20 for stable estimates and meaningful inference. With n = 3, r is essentially a function of two points and tells you nothing. With n = 30+, the central limit theorem makes the t-test p-value reliable even for non-normal data. Small samples require larger |r| for significance — see the comparison table for thresholds.
Covariance and correlation
Covariance measures how two variables vary together: cov(X,Y) = Σ((x−x̄)(y−ȳ)) / (n−1). It is unit-dependent and hard to interpret. Pearson correlation normalizes covariance by the product of standard deviations: r = cov(X,Y) / (σ_X × σ_Y). This makes r dimensionless and bounded in [−1, +1]. A perfect positive linear relationship gives r = 1; perfect negative gives r = −1.
Coefficient of determination R²
R² is the square of Pearson r. It represents the proportion of variance in Y explained by X (or vice versa) in a linear model — the "coefficient of determination." An r of 0.8 gives R² of 0.64, meaning 64% of the variance is shared. R² is the more intuitive effect-size measure for prediction, while r preserves the direction of the relationship (sign of the slope).
Null hypothesis test
The standard test of Pearson correlation sets H₀: ρ = 0 (true population correlation is zero). The test statistic t = r × √((n−2)/(1−r²)) follows a Student's t distribution with n−2 degrees of freedom under H₀. The two-tailed p-value gives the probability of observing |r| this large or larger if the null were true. Small p suggests rejecting H₀.
Causation vs correlation
"Correlation does not imply causation" — the most cited rule in introductory statistics. A non-zero Pearson r means two variables are linearly associated, but the cause could be a third confounder, reverse causality, or pure coincidence. Establishing causation requires controlled experimentation or causal inference methods (instrumental variables, regression discontinuity, propensity matching). Always report correlation alongside effect size and avoid causal language for observational data.
| Effect size | |r| convention | R² | Notes |
|---|---|---|---|
| Small (Cohen) | |r| ≈ 0.10 | 0.01 | Detectable in n ≥ 100 samples |
| Medium (Cohen) | |r| ≈ 0.30 | 0.09 | Detectable in n ≥ 30–50 samples |
| Large (Cohen) | |r| ≈ 0.50 | 0.25 | Detectable in n ≥ 15–20 samples |
| Very large | |r| ≈ 0.70 | 0.49 | Half of variance explained |
| Near-perfect | |r| ≈ 0.90 | 0.81 | Strong linear association |
| Min |r| for p < 0.05 | n=10: 0.632 | — | Critical r for significance at α=0.05 |
Authoritative References
- NIST/SEMATECH — e-Handbook of Statistical Methods— nist.govNIST engineering statistics handbook covering Pearson correlation, R², hypothesis testing, and the assumptions underlying linear regression analysis.
- Wikipedia — Pearson correlation coefficient— WikipediaDefinition of Pearson r, the relationship to covariance, the sampling distribution under the null hypothesis, and effect-size interpretation.
- Laerd Statistics — Pearson correlation— statistics.laerd.comPractical guide to running and interpreting Pearson correlation in SPSS, including effect-size interpretation and assumptions (linearity, normality, no outliers).
- OpenIntro Statistics — Correlation and regression— openintro.orgOpenIntro Statistics textbook — free chapter on correlation and linear regression with worked examples and intuition for R² and p-values.
Try our other free calculators
CalcGenius has 1,200+ free, ad-free, browser-based calculators for finance, health, math, science, and everyday life. No sign-up required.