STATISTICS CALCULATOR

Linear Regression Calculator

Enter paired x and y observations to fit an ordinary least-squares line with an intercept, then supply an x value for a point prediction.

Calculator

One x, y pair per line; at least two pairs.
YOUR RESULTS
Predicted y at entered x9
Fitted slope
2
Fitted intercept
1
R squared
1
Sum of squared residuals
0
Prediction position
Extrapolation beyond observed x range

Page guide

Predicted y at entered x and interpretation

The fitted slope and intercept define y = a + bx. Residual sum measures squared vertical errors, and R squared summarizes the fit when y varies. A separate label identifies extrapolation beyond observed x values.

The formula

b = Σ(xᵢ − x̄)(yᵢ − ȳ)/Σ(xᵢ − x̄)²; a = ȳ − bx̄; fitted y = a + bx.

Estimate slope from centered cross-products divided by centered x squares, then choose the intercept so the line passes through the two column means. Evaluate that fitted line at the selected prediction x.

Verified worked example

The pairs (1, 3), (2, 5), and (3, 7) fit y = 1 + 2x exactly. At x = 4 the predicted value is 9, labeled extrapolation because 4 exceeds the observed range.

How to use this calculator

  1. Enter at least two x, y rows, keeping each observation paired.
  2. Enter the x value at which you want a point prediction.
  3. Read the fitted coefficients and prediction, checking the extrapolation label and model limitations.

Linear Regression input conventions

Ordinary least squares chooses the line that minimizes the sum of squared vertical residuals. Every entered row receives equal weight, and an intercept is always included. At least two distinct x values are necessary. Two pairs can define a line exactly but provide no independent evidence that a linear model describes a larger population.

Interpreting predicted y at entered x

Predictions beyond the observed x interval extend the fitted line without new evidence. Even inside that interval, a small residual sum does not establish causal influence or rule out curvature and unequal variance. Inspect a scatter plot and residual pattern when the result informs a decision. R squared is undefined for a constant y column, although its constant fitted line and prediction remain valid. This page returns a point prediction, not a prediction interval.

Assumptions & limitations

What this calculation assumes

  • The fit is ordinary unweighted least squares with an intercept and one predictor.

What to keep in mind

  • Unweighted simple regression with an intercept; no confidence intervals, multivariable fitting, or model diagnostics.

Common questions

Is this the line between two endpoints?

With two pairs it is. With more pairs it fits all observations by least squares and usually does not pass through every point.

Can I force the intercept to zero?

No. This implementation estimates an intercept. A through-origin regression is a different model and should be chosen only when its assumptions are appropriate.

What happens when every y value is the same?

If x varies, the fitted slope is zero and the prediction is that constant y. R squared is undefined because the y column has no variation to explain.

Sources & further reading

Reviewed on