Correlation & Regression Calculator
Least-squares regression fits the line that minimises squared errors: for x = 1 to 5 and y = 2, 4, 5, 4, 5 the line is 2.2 + 0.6x, with r = 0.775.
Same number of values as X, in the same order.
2.2 + 0.6x
- Pearson correlation r
- 0.774597
- R² (coefficient of determination)
- 0.6
- Slope b
- 0.6
- Intercept a
- 2.2
- Sample covariance
- 1.5
- n
- 5
Step-by-step solution
- x̄ = 3, ȳ = 4
- Σ(x − x̄)(y − ȳ) = 6, Σ(x − x̄)² = 10, Σ(y − ȳ)² = 6
- b = 6 ÷ 10 = 0.6; a = ȳ − b x̄ = 2.2
- r = 6 ÷ √(10 × 6) = 0.774597
Correlation & Regression Formula
b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)², a = ȳ − b x̄
r = Σ(x − x̄)(y − ȳ) ÷ √[Σ(x − x̄)² Σ(y − ȳ)²]
Worked Example
x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5:
- x̄ = 3, ȳ = 4
- Σ(x − x̄)(y − ȳ) = 6, Σ(x − x̄)² = 10, Σ(y − ȳ)² = 6
- b = 6 ÷ 10 = 0.6; a = ȳ − b x̄ = 2.2
- r = 6 ÷ √(10 × 6) = 0.774597
R² (coefficient of determination): 0.6 · Slope b: 0.6 · Intercept a: 2.2 · Sample covariance: 1.5 · n: 5
Reading r, r² and the regression line
The correlation coefficient r runs from −1 to +1 and measures how closely the points follow a straight line; r² is the share of the variation in y that the line explains. A slope b tells you how much ŷ changes per unit of x. Correlation is not causation, a single outlier can move r a long way, and the line should not be used far outside the range of x you measured. Plot the data first: a curved pattern can give a low r even when x and y are strongly related.
Frequently asked questions
What is the difference between correlation and regression?
Correlation r measures the strength and direction of a linear relationship (−1 to 1). Regression gives the equation to predict y from x.
What does R² mean?
The share of the variation in y explained by the line: R² = 0.6 means 60 %. For simple regression R² = r².
How do I do this in Excel or R?
Excel: =CORREL(x, y), =SLOPE(y, x), =INTERCEPT(y, x). R: cor(x, y) and lm(y ~ x).
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, National Institute of Standards and Technology .
Last reviewed: . Factors are stored exactly and computed with 50-digit decimal arithmetic. See how we verify conversion factors.
Cite this page
APA
Scientific Converters. (2026, October 15). Correlation & Regression Calculator. Retrieved October 25, 2026, from https://scientificconverters.com/calculators/correlation-regression-calculator/
IEEE
Scientific Converters, "Correlation & Regression Calculator," scientificconverters.com. Accessed: Oct. 25, 2026. [Online]. Available: https://scientificconverters.com/calculators/correlation-regression-calculator/