Multiple Regression
calculator.
Fit one outcome to several predictors at once, and see what each one adds.
- Adjusted R²
- 0.9741
- F test p-value
- < 0.0001
- Residual SE
- 1.5371
The predictors together explain 98% of the variation in Y, and the F test puts that beyond chance at the 5% level. Weight has the largest standardized coefficient, 1.56.
Coefficients
| Term | Estimate | SE | t | p | VIF | Overlap |
|---|---|---|---|---|---|---|
| InterceptSE 51.1413t 1.338 | 68.4461 | 51.1413 | 1.338 | 0.2226 | – | Not applicable |
| HeightSE 0.4626t −1.205 | −0.5572VIF 78.25 | 0.4626 | −1.205 | 0.2675High | 78.25 | High |
| WeightSE 0.4232t 3.28 | 1.3878VIF 78.25 | 0.4232 | 3.28 | 0.0135High | 78.25 | High |
VIF above 10 is high, and 5 is also a common cutoff. Below that the overlap reads as low.
Actual against fitted
Each dot compares a Y you entered with the model's prediction, and dots on the diagonal are predicted exactly. R² = 0.9799, and the typical miss is 1.5371. A curve or a funnel suggests a missing term or an uneven spread.
Predict a new case
- Predicted Y
- 70
- 95% interval, average Y
- 68.8506 to 71.1494
- 95% interval, one new Y
- 66.188 to 73.812
Reach a target Y
- Height, with the others as above
- 143.921
The fit with one predictor left out
| Leave out | R² | Adjusted R² | Change |
|---|---|---|---|
| HeightR² 0.9757 | 0.9757 | 0.9727 | −0.0015 |
| WeightR² 0.949 | 0.949 | 0.9426 | −0.0315 |
A rise in adjusted R² means the model does better without that predictor.
Fitted values and residuals
| Actual Y | Row | Fitted Ŷ | Residual |
|---|---|---|---|
| 68Row 1 | 1 | 68.0854 | −0.0854 |
| 72Row 2 | 2 | 72.2386 | −0.2386 |
| 63Row 3 | 3 | 59.7791 | 3.2209 |
| 66Row 4 | 4 | 66.9814 | −0.9814 |
| 80Row 5 | 5 | 79.1674 | 0.8326 |
| 55Row 6 | 6 | 55.3526 | −0.3526 |
| 88Row 7 | 7 | 87.4839 | 0.5161 |
| 62Row 8 | 8 | 63.6588 | −1.6588 |
Working
- 1Count rows and predictorsn = 10, k = 2, so 7 degrees of freedom are left
- 2Solve the least-squares equationsb = (XTX)−1XTY
- 3Read off each coefficientIntercept: 68.4461Height: −0.5572Weight: 1.3878
- 4Compare the misses with the total spreadR² = 1 −16.538822= 0.9799
- 5Divide the mean squares to test the model as a wholeF =402.7312.3626= 170.463
- 6Check: the misses cancel and the sums of squares add upSum of residuals = 4.402 × 10⁻¹⁰805.462 + 16.538 = 822
How it's worked out
Multiple linear regression predicts an outcome Y from several predictors together. Each coefficient answers one question: how much does Y change for one extra unit of this predictor, with the others held fixed? Typical uses are a house price from size and bedrooms, crop yield from rain and fertilizer, or sales from ads in several channels. With a single predictor, the linear regression tool shows more about the line.
In matrix form, Y is the column of outcomes and X holds the predictors, with a first column of ones for the intercept. The tool inverts the matrix by Gauss-Jordan elimination with partial pivoting. With n rows and k predictors, the residual variance is below.
Each t statistic is a coefficient over its standard error, on n − k − 1 degrees of freedom. The F statistic tests whether the predictors together explain more than chance would.
The variance inflation factor comes from fitting predictor j on all the other predictors, and is the R² of that fit. It shows how much overlap with the others has inflated the variance of that coefficient. A standardized coefficient rescales each slope by the spreads of its predictor and of Y, so you can compare predictors measured in different units.
Worked examples
Pricing ten homes from size and bedrooms
Ten homes have a price in thousands of dollars, a size in hundreds of square feet and a count of bedrooms. The fit is Ŷ = 102.62 + 11.096·Size (×100 sq ft) + 1.3077·Bedrooms. R² is 0.991 and adjusted R² is 0.989, with F = 390.9 on 2 and 7 degrees of freedom.
The size coefficient, 11.096, means each extra 100 square feet adds about $11,096 to the predicted price for homes with the same number of bedrooms. Its p-value is below 0.0001. The bedroom coefficient has p = 0.744 and a VIF of 4.74: larger homes tend to have more bedrooms, so the two share information and the bedroom effect is hard to pull apart from size.
Size has a standardized coefficient of 0.97 and bedrooms 0.03. Leave bedrooms out and adjusted R² goes from 0.9886 to 0.9899, so this model does better without them.
A 1,500 square foot home with 3 bedrooms comes out at 273, with a 95% interval of 262.5 to 283.4 for one home. To reach a price of 300 with 3 bedrooms, the model asks for a size of 17.4. As a check, the residuals add to 5.0022 × 10⁻¹².
Height and weight that overlap
A score Y is measured with height and weight in ten people. Together they explain 98% of the variation, yet the height coefficient comes out at −0.557, which looks as if taller people score lower. Weight has a coefficient of 1.388.
The clue is the VIF of 78.3 on both. In this data, weight rises almost in step with height, so the model struggles to tell them apart, and the height coefficient has p = 0.268. Leave height out and R² only falls from 0.9799 to 0.9757. Leave weight out and it falls further, to 0.949. The fit predicts well; the single coefficients are what you should not lean on.
One predictor, as a check on the method
With a single predictor the method becomes simple regression, so a published result makes a good test. Anscombe's set I has a line of y = 3.00 + 0.500x and an R² of 0.67. This engine gives Ŷ = 3.0001 + 0.50009·X and 0.67, so they agree. With one predictor there is no VIF to report and nothing to leave out.
Reading your result
R² and adjusted R². R² is the fraction of variance the model explains. It never falls when you add a predictor, even a useless one. Adjusted R² penalizes extra terms, so compare models with it.
p-values. Each one tests whether that coefficient differs from zero, given the other predictors. A predictor can be useful alone and still not be significant once a correlated predictor joins the model.
VIF. A VIF above 10 is often called high, and a cutoff of 5 is also common. A high figure does not stop the model from predicting well, but it makes that coefficient unstable. Its square root is how much the standard error has grown because of the overlap.
Actual against fitted. Dots should scatter evenly around the diagonal. A curve or a funnel suggests a missing term or an uneven spread.
Common mistakes
- Too few rows. A common rule asks for at least 10 to 20 times as many rows as predictors. With fewer, the estimates are probably unstable and unlikely to replicate.
- Fishing through many predictors. Adding many invites what that same guide calls capitalizing on chance, where some look significant by luck. The risk grows as the sample shrinks.
- Comparing raw coefficients. A coefficient for a value in thousands and one for a value in units cannot be compared directly. Use the standardized figures.
- The wrong kind of data. The tests assume the residuals are independent, with even spread and a roughly normal shape. Data over time, grouped data or a yes or no outcome call for other models, such as logistic regression. A coefficient shows association, not cause, and predictions outside your data can be badly wrong.
Questions people ask
Sources
- Wikipedia, Ordinary least squares
- R documentation, summary.lm (stats package)
- Wikipedia, Variance inflation factor
- NIST/SEMATECH e-Handbook, section 4.1.4.1, Linear least squares regression
- TIBCO Statistica documentation, Assumptions, limitations and practical considerations
- Wikipedia, Anscombe's quartet