Linear Regression Calculator

Provide paired observations to compute the least-squares best-fit line, correlation, and predicted values for new inputs.

Predicted y ≈ 10.6000

Regression equation

y = -0.2000 + (1.8000)x

R² = 0.9878, r = 0.9939

Fitted values and residuals
xActual yPredicted yResidual
12.00001.60000.4000
23.00003.4000-0.4000
35.00005.2000-0.2000
47.00007.00000.0000
59.00008.80000.2000

How to Use This Calculator

  1. Enter paired observations with each line containing x and y.
  2. Review the regression equation, slope, intercept, and R² summary.
  3. Inspect residuals to evaluate how well the model fits each data point.
  4. 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.