Linear Regression Calculator
Fit an ordinary least-squares line to paired samples and report slope, intercept, and R squared.
Description
Fit an ordinary least-squares line and report its slope, intercept, and R squared.
Simple linear regression estimates a straight-line relationship between paired predictor and response observations. It is useful for trend summaries, calibration examples, and checking a hand-derived least-squares fit.
When to use Linear Regression Calculator
- Estimate change in y for one unit of x
- Summarize a straight-line trend
- Check an ordinary least-squares example
How the calculation works
The slope is sample cross-deviation divided by x deviation sum of squares; the intercept makes the fitted line pass through the sample means. R² is the squared sample correlation for a non-constant response.
ŷ = intercept + slope × x Interpreting the result
Slope carries y-units per x-unit. The intercept is the fitted y at x = 0 and may be meaningless when zero is outside the observed range. R² measures in-sample variance explained, not causation or predictive validity.
Important limitations
- Predictor values must vary.
- Outliers can strongly change all three outputs.
- Residual shape, uncertainty, nonlinearity, and extrapolation risk are not reported.