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.
Fit a regression with two predictors
Compare marginal and adjusted slopes, then check predictions on observations that did not train the model.
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
x₂ slopes
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
Shared range 10 to 33. Points above the diagonal have positive residuals.
Row ledger and CSV
| Line | Split | Observed | Fitted | Residual |
|---|---|---|---|---|
| 2 | Training | 10 | 10 | 0 |
| 3 | Training | 14 | 14 | 0 |
| 4 | Training | 15 | 15 | 0 |
| 5 | Training | 25 | 25 | 0 |
| 6 | Training | 23 | 23 | 0 |
| 7 | Training | 33 | 33 | 0 |
| 8 | Holdout | 19 | 18 | 1 |
| 9 | Holdout | 25 | 27 | −2 |
How to use this calculator
- 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.
- Read the fitted plane and compare each single-predictor slope with its adjusted slope while the other predictor is held fixed.
- Check the variance inflation factor. Large values indicate that the adjusted slopes can be sensitive to small changes in the training data.
- 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
Linear Regression Calculator
Fit a least-squares line, inspect scatter and residual plots, and calculate Student-t confidence and prediction intervals. Paste paired data and export the full ledger.
Quartic Regression & Held-Out Fit Calculator
Fit a quartic equation to observed pairs, compare degrees 1 through 4 on leave-one-out error, and find the lowest degree within your RMSE limit.
Pearson Correlation Coefficient Calculator
Calculate Pearson's r to measure the strength and direction of a linear relationship between two variables.
Quadratic Regression Calculator
Fit a quadratic regression to paired data and compare it with a straight line. Inspect residuals, exact coefficients and the fitted turning point.
