📉 Linear Regression & Correlation Calculator
Fit a least-squares regression line to your paired (x, y) data, slope, intercept, the equation, correlation r and r², with a scatter plot and the fitted line.
8 valid points parsed.
Regression equation
y = 1.99048x + 0.0428571
1.99048
Slope (b)
0.0428571
Intercept (a)
0.99941
Correlation r
0.99882
r² (fit)
r² means about 99.9% of the variation in y is explained by x.
Least-squares fit with Pearson’s r and r². Correlation is not causation. 🔒 Computed entirely in your browser.
How the linear regression & correlation calculator works
Paste your x and y values and the calculator finds the least-squares line y = a + bx that minimises the squared vertical distances to the points. The slope is b = Σ(xᵢ−x̄)(yᵢ−ȳ) ÷ Σ(xᵢ−x̄)², the covariance of x and y divided by the variance of x, and the intercept follows from a = ȳ − b·x̄, forcing the line through the point of averages (x̄, ȳ). It reports the slope and intercept, the regression equation, Pearson’s correlation coefficient r and the coefficient of determination r² (the share of variance explained), and draws a scatter plot with the fitted line so you can see the fit. For paired data with slope b, note that r and b share the same sign.
The visual differentiator: a scatter plot with the fitted line, plus the exact coefficients and r², the kind of at-a-glance fit a chatbot can’t draw and often miscomputes.
Frequently asked questions
What is linear regression?
A method that fits a straight line y = a + bx to paired data by minimising the sum of squared vertical distances from the points to the line (least squares). The slope b and intercept a describe the best-fit relationship.
What do r and r² mean?
r is Pearson’s correlation coefficient (−1 to +1), measuring the strength and direction of the linear relationship. r² (r squared) is the proportion of the variance in y explained by x, an r² of 0.8 means the line explains 80% of the variation.
How do I read the regression equation?
y = a + bx: a is the predicted y when x is 0 (the intercept), and b is the change in y per one-unit increase in x (the slope). Plug in an x to predict its y.
Does correlation imply causation?
No. A strong r means x and y move together, not that one causes the other, a lurking third variable or coincidence can produce correlation. Regression describes association, not cause.
How much data do I need?
At least two points define a line, but more points give a more reliable fit and a meaningful r². Paste as many paired values as you have; the tool handles them all.
Is my data uploaded?
No, the fit, statistics and chart are all computed in your browser.
What is the difference between r and r²?
r (from −1 to +1) gives both the strength and the direction of the linear relationship; r² (from 0 to 1) is r squared and gives only the proportion of variance in y explained by x. An r of −0.9 and +0.9 both give r² = 0.81, so r² drops the sign.
Should I use the line to predict outside my data range?
Be cautious, extrapolating far beyond the observed x-values assumes the linear relationship continues, which often fails. The fit is most reliable for predictions within the range of the data you provided (interpolation).
What can make a linear fit misleading?
Outliers can pull the least-squares line noticeably, and a curved (non-linear) relationship can still show a moderate r while the straight line fits poorly. Always look at the scatter plot, not just r², before trusting the line.