Free calculator

Correlation & Regression Calculator

Paste pairs of x and y values to get the correlation coefficient, R², the line of best fit and its significance, plus a scatter plot you can download.

  • Pearson & Spearman
  • Line of best fit
  • p-value
  • Free

Your data (x, y pairs)

One pair per line: x, y or x y. Paste two columns straight from Excel or Google Sheets. 10 pairs

Chart & prediction

Result

Predicted y for x = 5.5: 75.8782

There is a very strong positive relationship between Hours studied and Exam score, and it is statistically significant (p < 0.05). Correlation alone doesn’t prove that one causes the other.

Hours Studied vs Exam Score12345678Hours studied5060708090Exam scoreŷ = 48.4706 + 4.9832x · r = 0.992 · R² = 0.985

Your data is saved in this browser only. Nothing is uploaded.

Step-by-step solutionShow
  1. 1

    Find the means

    x̄ = 4.2, ȳ = 69.4 (n = 10)

  2. 2

    Sums of squares and cross-products

    Sxx = Σ(x − x̄)² = 47.6, Syy = Σ(y − ȳ)² = 1,200.4, Sxy = Σ(x − x̄)(y − ȳ) = 237.2

  3. 3

    Correlation coefficient

    r = Sxy ÷ √(Sxx · Syy) = 237.2 ÷ √(47.6 × 1,200.4)

    = 0.992312

  4. 4

    Slope and intercept

    b = Sxy ÷ Sxx = 4.983193, a = ȳ − b·x̄ = 69.4 − 4.983193 × 4.2 = 48.470588

  5. 5

    Test for significance

    t = r·√(n − 2) ÷ √(1 − r²) = 22.6781, df = 8

    Two-tailed p-value = < 0.0001. Since p < 0.05, the correlation is significant.

Formulas

QuantityFormula
Correlationr = Sxy ÷ √(Sxx · Syy)
Slopeb = Sxy ÷ Sxx
Intercepta = ȳ − b·x̄
Line of best fitŷ = a + b·x
Significance testt = r·√(n − 2) ÷ √(1 − r²), df = n − 2

Sxx = Σ(x − x̄)², Syy = Σ(y − ȳ)² and Sxy = Σ(x − x̄)(y − ȳ).

How to interpret r

|r|Strength (rule of thumb)
0.9 – 1.0Very strong
0.7 – 0.9Strong
0.5 – 0.7Moderate
0.3 – 0.5Weak
0 – 0.3Very weak or none

These cut-offs vary between fields. Always look at the scatter plot too: one outlier can create or hide a correlation.

Before you trust the result

  • Check the scatter plot is roughly straight. A curved relationship can have r near 0 even though x and y are closely linked.
  • Look for outliers that pull the line toward them.
  • Don’t extrapolate far beyond the range of your x values.

To summarize each variable on its own, use the descriptive statistics calculator.

What different correlations look like

r ≈ 0.95strong positiver ≈ 0.5moderate positiver ≈ 0no linear relationshipr ≈ −0.85strong negative
What correlation coefficients look like. r measures how tightly the points follow a straight line, not how steep it is.

Worked example: study hours and exam scores

For the default data (10 students), r = 0.992 and R² = 0.985: hours studied explain about 98% of the variation in scores. The line of best fit is ŷ = 48.47 + 4.98x, so each extra hour of study goes with about 5 more points, and a student who studies 5.5 hours is predicted to score about 75.9.

Now add one unusual student who studied 20 hours but scored 40. The correlation drops to −0.25. A single outlier can wipe out, or even reverse, a strong relationship. That’s why you should always look at the scatter plot.

Common mistakes to avoid

  • Assuming causation. A strong r shows the variables move together, not that one causes the other.
  • Ignoring curved relationships. r only measures straight-line association. A perfect U-shape can have r near 0.
  • Extrapolating. Predictions far outside the observed x range are unreliable.
  • Confusing r with the slope. A steep line can have a weak r, and a shallow line a strong r.

Do it in other software

SoftwareHow
Excel / Google Sheets=CORREL(xs, ys), =RSQ(ys, xs), =SLOPE(ys, xs), =INTERCEPT(ys, xs); LINEST for the full regression.
TI-84Turn on DiagnosticOn (CATALOG), then STAT › CALC › LinReg(ax+b) L1, L2 to see r and r².
Pythonscipy.stats.pearsonr(x, y) for r and p; numpy.polyfit(x, y, 1) for the line; scipy.stats.spearmanr for Spearman’s rho.

Related tools: Descriptive Statistics Calculator, Standard Deviation Calculator, Z-Score Calculator, Histogram Maker and Mean, Median & Mode Calculator.

Frequently asked questions

What does the correlation coefficient r mean?

r measures the strength and direction of a straight-line relationship, from −1 to 1. Values near 1 mean a strong positive relationship, near −1 a strong negative one, and near 0 little or no linear relationship.

What is R²?

R² (r squared) is the proportion of the variation in y that the line of best fit explains. R² = 0.81 means 81% of the variation in y is accounted for by its linear relationship with x.

What is the p-value for a correlation?

It tests whether the correlation could plausibly be zero in the population. A p-value below 0.05 is usually called statistically significant. It uses a t-test with n − 2 degrees of freedom.

What is the difference between Pearson and Spearman correlation?

Pearson's r measures linear relationships between the values themselves. Spearman's rho is Pearson's r applied to the ranks, so it captures any consistently increasing or decreasing relationship and is less affected by outliers.

Does correlation mean causation?

No. Two variables can move together because a third factor drives both (ice cream sales and drownings both rise in summer), or purely by chance. Correlation is a reason to investigate, not proof of cause.

Related tools