Linear Regression Calculator
Provide paired observations to compute the least-squares best-fit line, correlation, and predicted values for new inputs.
Regression equation
y = -0.2000 + (1.8000)x
R² = 0.9878, r = 0.9939
| x | Actual y | Predicted y | Residual |
|---|---|---|---|
| 1 | 2.0000 | 1.6000 | 0.4000 |
| 2 | 3.0000 | 3.4000 | -0.4000 |
| 3 | 5.0000 | 5.2000 | -0.2000 |
| 4 | 7.0000 | 7.0000 | 0.0000 |
| 5 | 9.0000 | 8.8000 | 0.2000 |
How to Use This Calculator
- Enter paired observations with each line containing x and y.
- Review the regression equation, slope, intercept, and R² summary.
- Inspect residuals to evaluate how well the model fits each data point.
- Use the prediction input to estimate y for new x values within the observed range.
Formulas
Slope b = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)²
Intercept a = ȳ − b x̄
Predicted value ŷ = a + b x
R² = 1 − SSres / SStot
Full Description
Linear regression fits a straight line that minimizes the sum of squared residuals between observed and predicted values. It is widely used for forecasting and quantifying relationships between variables.
R² measures the proportion of variance in y explained by the model, while the correlation coefficient captures direction and strength of the linear association.
Frequently Asked Questions
Do I need to sort the data?
No. The order of pairs does not affect the regression fit.
Can the model handle duplicate x values?
Yes, as long as there is variation in x overall. If all x values are identical, the slope cannot be estimated.
What about outliers?
Large outliers can distort the fit. Inspect residuals and consider robust methods if outliers dominate the data.
How far can I extrapolate?
Predictions outside the observed x range may be unreliable. Use caution and domain knowledge when extrapolating.