Multiple Linear Regression Calculator

Paste two predictor columns and one outcome. See how a predictor’s slope changes when the model accounts for the other column, and measure prediction error on rows left out of the fit.

Regression

Fit a regression with two predictors

Paste observations

Paste x1, x2, y and an optional split as comma- or tab-separated columns. Add holdout as the fourth value to score a row separately. Other rows train the fit.

Model and prediction error

Fitted plane

ŷ = 10 − 2x₁ + 3x₂

x₁ slopes

Sign reverses

Marginal152/35
Adjusted−2

x₂ slopes

Marginal86/41
Adjusted3

Each pair of bars shares a zero line and uses that predictor’s units. Adjusted slopes hold the other predictor fixed.

Variance inflation factor 21.74242

For both predictors. Higher values indicate more sensitivity to correlated predictors.

Training RMSE
0
6 training rows
Holdout RMSE
1.581139
2 held-out rows
Training R²
1
Variation explained in the training data
Adjusted R²
1
Accounts for two predictors
Observed versus fitted

Shared range 10 to 33. Points above the diagonal have positive residuals.

Observed y versus fitted yFilled circles are training rows and outlined diamonds are holdout rows. Both axes use the same scale. Above the dashed diagonal, observed values exceed predictions.Fitted yObserved y
Training Holdout Exact match
Row ledger and CSV
Exact fitted values and row residuals
LineSplitObservedFittedResidual
2Training10100
3Training14140
4Training15150
5Training25250
6Training23230
7Training33330
8Holdout19181
9Holdout2527−2

How to use this calculator

  1. Paste x1, x2 and y as comma- or tab-separated rows. Use an optional x1,x2,y,split header and add holdout to rows you want to score separately.
  2. Read the fitted plane and compare each single-predictor slope with its adjusted slope while the other predictor is held fixed.
  3. Check the variance inflation factor. Large values indicate that the adjusted slopes can be sensitive to small changes in the training data.
  4. Read the observed-versus-fitted plot and separate training and holdout errors. Open the row ledger to inspect exact predictions and export the results.

The Formula

The mathematical logic powering this calculation is:

Fit ŷ = b₀ + b₁x₁ + b₂x₂ by minimizing the squared training residuals. For centered training columns, let Sᵢⱼ be the sum of pairwise products. Solve the 2×2 centered normal equations with determinant Δ = S₁₁S₂₂ − S₁₂². The slopes are b₁ = (S₁yS₂₂ − S₂yS₁₂)/Δ and b₂ = (S₂yS₁₁ − S₁yS₁₂)/Δ. Set b₀ = mean(y) − b₁mean(x₁) − b₂mean(x₂).

The marginal slopes are S₁y/S₁₁ and S₂y/S₂₂. The variance inflation factor is S₁₁S₂₂/Δ for either predictor when there are two predictors. Δ = 0 gives an exactly rank-deficient training design, so the adjusted slopes are not uniquely determined. A predictor with zero training variation is reported separately.

For both splits, residual is observed y minus fitted y. Mean absolute error averages the magnitudes, and RMSE is the square root of the mean squared residual. Training R² is 1 − SSE/Syy with nonconstant training y. Adjusted R² uses 1 − (1 − R²)(n − 1)/(n − 3), and needs more than three training rows. R² is undefined with constant training y. Holdout RMSE uses only the points held out before fitting.

The input limit is 120 rows and at least three train rows. Enter signed decimal values from −1,000,000 to 1,000,000 with up to six decimal places. With three columns the row trains the fit. With four columns use train or holdout. Means, slopes, collinearity checks, fit diagnostics and table values are rational. The chart and display use numerical approximations. Observational associations alone do not establish a causal effect.

Worked Example

If you input:

  • Dataset: Six training observations and two holdout observations at (2, 4, 19) and (5, 9, 25)

Result:

The fit is ŷ = 10 − 2x₁ + 3x₂. The marginal x₁ slope is 152/35, so its sign reverses after adjustment. Predictions 18 and 27 for the holdout rows give residuals +1 and −2, with RMSE about 1.581139.

Frequently Asked Questions

Why can a slope change sign after adjustment?

The single-predictor slope includes patterns associated with the omitted predictor. The adjusted slope compares points at the same value of the other predictor. Correlated predictors can make these two comparisons differ substantially.

What does a large variance inflation factor mean?

A predictor is close to a linear function of the other column, so their separate slope estimates can be sensitive to small data changes. VIF is a diagnostic, and the plausibility of a model also depends on the data and use case.

Do holdout rows affect the fitted plane?

Only training rows set the coefficients and the training diagnostics. Holdout rows receive predictions from that finished plane and have separately reported errors.

Why is adjusted R squared missing with three training rows?

Three independent rows can identify a three-parameter plane but leave zero residual degrees of freedom. Adjusted R² needs more rows. Both R² measures also require variation in training outcomes.

Which points agree with the prediction?

The chart has the same scale on both axes. Points on the diagonal have observed y equal to fitted y. Points above it have a positive residual and points below it have a negative residual.

Can I enter more than two predictors?

This worksheet fits exactly two predictor slopes and an intercept. It shows the separate unadjusted comparisons and uses an explicit two-variable collinearity check.

Similar Calculators