Linear regression finds the straight line that comes closest to a set of paired observations, and turns a scatter of points into an equation you can use to predict. This calculator computes that line by ordinary least squares and reports everything needed to judge it: slope, intercept, the correlation coefficient, r-squared, and the standard error of the estimate.
Arb Digital added the standard error of the estimate deliberately, because it is the number most often left out. R-squared expresses fit as a proportion, which sounds precise but says nothing about how wrong a single prediction is likely to be. The standard error answers that directly, in the units you actually measured.
What This Linear Regression Calculator Does
Paste your X and Y columns and the tool fits the equation y = a + bx, where b is the slope and a is the intercept. The slope is the average change in Y for a one-unit increase in X. The intercept is the fitted value of Y when X equals zero, which is meaningful only if zero is a value X can plausibly take.
Alongside the equation you get four diagnostics. Correlation r measures the strength and direction of the linear relationship. R-squared is the share of variation in Y explained by the line. The standard error of the estimate is the typical size of a residual — the vertical distance between a real point and the fitted line. The result subtitle also gives a plain-English reading of the fit and a prediction at any X value you enter.
How to Use It
- Put the predictor in X and the outcome in Y. The choice matters: regressing Y on X gives a different line from regressing X on Y, because least squares minimises vertical distances only.
- Keep the pairs aligned. The first X belongs with the first Y. Check the pair count in the subtitle if a value looks to have been dropped.
- Read the equation in the result panel — it is the line in the form you would type into a spreadsheet or a report.
- Enter a prediction value. Keep it within the observed range of X unless you have a solid reason to believe the relationship continues beyond it.
- Judge the fit using both r-squared and the standard error before you rely on any prediction the line produces.
The Formula and a Worked Example You Can Check
The least-squares slope is b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)², and the intercept follows from the fact that the line always passes through the point of means: a = ȳ − b × x̄. The standard error of the estimate is √(Σ(y − ŷ)² ÷ (n − 2)), dividing by n − 2 because two parameters were estimated from the data.
Work through the default data. X is 10, 12, 15, 18, 20, 22, 25, 30 with a mean of 19.0, and Y is 14, 17, 19, 25, 24, 29, 31, 38 with a mean of 24.625. The cross-product sum Σ(x − x̄)(y − ȳ) is 369 and Σ(x − x̄)² is 314, so the slope is 369 ÷ 314 = 1.1752. The intercept is 24.625 − 1.1752 × 19 = 2.2970. The fitted line is therefore y = 2.2970 + 1.1752x.
For the fit statistics, Σ(y − ȳ)² is 441.875 and the residual sum of squares is 8.2412, giving r² = 1 − (8.2412 ÷ 441.875) = 0.9813 and r = 0.9906. The standard error of the estimate is √(8.2412 ÷ 6) = 1.1720. Predicting at X = 24 gives 2.2970 + 1.1752 × 24 = 30.50. Every one of those numbers appears in the tool on load, and the method is the ordinary least-squares procedure documented in the NIST/SEMATECH e-Handbook of Statistical Methods.
Reading the Fit in Plain English
An r-squared of 0.98 means the line accounts for 98% of the variation in Y, which is exceptionally tight and rare outside controlled measurement. Values between 0.5 and 0.8 are common in business and social data; below about 0.3 the line is describing a weak tendency rather than a dependable relationship.
The standard error of the estimate translates that into something you can act on. Here it is 1.172, meaning a typical prediction from this line misses the actual value by a little over one unit of Y. Since Y ranges from 14 to 38, that is a genuinely accurate model. Compare a different data set with the same r-squared but Y values in the millions, and a "98% fit" might still leave predictions tens of thousands out. Roughly two thirds of observations fall within one standard error of the fitted line, and about 95% within two, so doubling that number gives a rough working interval for a single prediction.
What the Slope Does and Does Not Say
The slope is a rate of change, not a statement of cause. A slope of 1.1752 says that in this data, each additional unit of X is associated with about 1.18 more units of Y on average. Whether increasing X would produce that change depends entirely on how the data was generated — an experiment supports the causal reading, observational data usually does not.
Two further cautions. The slope is an average across the whole observed range and can hide a relationship that flattens or steepens at the edges, which is exactly the pattern of diminishing returns. And the slope carries units: change X from days to weeks and the slope changes by a factor of seven while the relationship is untouched. Always state the units alongside the coefficient. To check whether the relationship is linear at all, compare the Pearson and Spearman coefficients in the correlation coefficient calculator; a large gap between them means a straight line is the wrong shape.
Extrapolation: Where Regression Fails Loudly
A fitted line knows nothing beyond the range of the data it was built on. The default data covers X from 10 to 30, so a prediction at X = 24 is interpolation and is well supported. A prediction at X = 200 is extrapolation, and the model has no evidence that the same straight-line relationship holds there.
The failure is not just imprecision — it is often nonsense. Extend most business regressions far enough and they predict negative costs, impossible conversion rates, or unbounded growth. The intercept is a special case of the same problem: it is the fitted value at X = 0, and if your X values run from 10 to 30, that point is outside the data. Here the intercept of 2.297 is arithmetically correct and substantively meaningless as a real-world quantity. Report it as a component of the equation, not as a finding.
Residuals: The Check Most People Skip
Least squares will fit a line to any data you give it, including data with no linear relationship at all. The way to tell whether the line belongs is to look at the residuals — the gaps between observed and fitted values. In a good fit they scatter randomly around zero with roughly constant spread.
Three patterns signal trouble. A curved pattern in the residuals means the true relationship bends and a straight line is systematically wrong in different parts of the range. A fan shape, where residuals grow as X grows, means the variance is not constant — the model is more reliable at one end than the other, and standard errors computed from it are unreliable. Penn State's STAT 501 regression methods course notes illustrate both patterns with residual plots. A single point far from the others in the X direction can act as a lever, pulling the entire line towards itself; removing it and refitting is a quick way to see how much of the result depends on that one observation. Screening for such points with the z-score calculator before fitting is a cheap safeguard.
Testing Whether the Slope Is Real
A non-zero slope in a sample does not prove a relationship in the population. The standard test uses t = b ÷ SE(b), where the standard error of the slope is the standard error of the estimate divided by √Σ(x − x̄)². For the default data that is 1.1720 ÷ √314 = 0.0661, giving t = 1.1752 ÷ 0.0661 = 17.77 on 6 degrees of freedom — overwhelming evidence that the slope is not zero.
This test is mathematically identical to testing whether the correlation coefficient is zero, so the two always agree. It is also worth remembering that significance and usefulness are different: with a few hundred observations, a slope explaining 4% of the variation will pass the test comfortably. Convert a test statistic into a probability with the p-value calculator, and build an interval around a fitted value using the confidence interval calculator rather than quoting a single predicted number as if it were exact.
Arb Digital publishes a growing library of free calculators for statistics, maths, and analysis — no sign-up, no limits, and every formula documented on the page.
Browse All Free Tools Contact Arb DigitalCommon Mistakes to Avoid
- Predicting outside the observed range of X — the line has no evidence about behaviour beyond the data it was fitted to.
- Interpreting the intercept when X = 0 is impossible — it is a mathematical anchor, not a meaningful prediction.
- Judging a model by r-squared alone — the standard error of the estimate says how wrong a typical prediction will be, which is what actually matters.
- Swapping X and Y — regressing Y on X and X on Y give different lines, because least squares minimises vertical distance only.
- Reading a slope as a causal effect — observational data supports association, and causation requires a design that rules out confounders.
Related Free Tools From Arb Digital
Measure association strength first with the correlation coefficient calculator, then check the spread of each variable using the standard deviation calculator or the variance calculator. Screen for influential outliers with the z-score calculator, place an interval around a prediction with the confidence interval calculator, and test significance with the p-value calculator. Everything else lives in the free online tools hub.
Frequently Asked Questions
It depends entirely on the field. Physical measurements routinely exceed 0.95, while human behaviour data with an r-squared of 0.3 can still be useful. Judge the model against the standard error of the estimate and against what alternatives are available, not against a universal threshold.
It is the typical distance between an observed value and the fitted line, expressed in the units of Y. Roughly two thirds of points fall within one standard error of the line, which makes it the most practical measure of predictive accuracy.
The intercept is the fitted value of Y when X equals zero. If zero lies outside the range of your data, or cannot occur in reality, the intercept is only a mathematical anchor for the line rather than an interpretable quantity.
You can compute a number, but the model provides no evidence to support it. Relationships that are linear over the observed range frequently bend, flatten, or reverse outside it, and extrapolated predictions often produce impossible values.
No. It quantifies how Y varies with X in the data you supplied. Causation depends on how the data was collected: an experiment with random assignment supports a causal reading, observational data generally does not.
At least three, since the standard error requires n − 2 degrees of freedom, but that is a bare minimum rather than a recommendation. With fewer than about 10 points the slope is unstable and a single observation can change the fit substantially.
The correlation r ranges from −1 to +1 and carries the direction of the relationship. R-squared is its square, always between 0 and 1, and represents the proportion of variance in Y explained by the line. An r of −0.8 and an r of +0.8 both give an r-squared of 0.64.
This tool is provided for education and general analysis. Results depend on your data meeting the assumptions of least-squares regression, and it is not a substitute for professional statistical advice on a specific study.