Lesson 106 — Multiple regression
Model with p predictors, OLS matrix solution, adjusted R², multicollinearity, variable selection and assumption diagnostics.
Used in: Stochastik LK alemão (Klasse 12) · H2 Mathematics Singapura (§15) · econometria introdutória
In multiple regression with predictors, the OLS estimator is the matrix solution to the normal equations. Each coefficient measures the effect of on holding the other predictors fixed — the so-called partial effect.
Rigorous notation, full derivation, hypotheses
Rigorous definition
Multiple linear regression model
"The multiple regression model is . The coefficient measures the expected change in per unit change in when all other predictors are held constant." — OpenIntro Statistics, §8.1, p. 362
Fit metrics
Inference
Matrix representation of the model: . The first column of 1s in generates the intercept .
Worked examples
Exercise list
42 exercises · 10 with worked solution (25%)
- Ex. 106.1Application
Regression: (price in R$ thousands, area in m², bedrooms, floor). Interpret each coefficient.
Show solution
See the reference indicated in fonte for detailed solution. - Ex. 106.2ApplicationAnswer key
Using , calculate the prediction and residual for an apartment of 80 m², 3 bedrooms, 5th floor with observed price of R$ 450 thousand.
Show solution
See the reference indicated in fonte for detailed solution.Show step-by-step (with the why)
See the reference indicated in fonte for step-by-step. - Ex. 106.3Application
, predictors, , . Calculate and .
Show solution
. Compare with : the penalized fit drops slightly. - Ex. 106.4ApplicationAnswer key
. Three models with predictors and . Calculate adjusted for each and identify the preferable one.
Show solution
M1: . With : . M2: . M3: . M3 has higher : preferable among the three. - Ex. 106.5ApplicationAnswer key
, , , . Build the ANOVA table and test the model at 5% level.
Show solution
; ; ; ; . Critical value : reject . - Ex. 106.6ApplicationAnswer key
Auxiliary regressions for 3 predictors: , , . Calculate the VIFs and identify severe multicollinearity.
Show solution
. ; ; . : predictor 3 exhibits severe multicollinearity. - Ex. 106.7Application
Regression of ENEM score on family income () and participation in tutoring program (: 1=yes, 0=no): , . Interpret .
Show solution
The dummy coefficient indicates that participating in the program is associated with 12.4 more points in the score, controlling for family income. Causal effect requires appropriate experimental design.Show step-by-step (with the why)
- Model with dummy: where if treated, if control.
- is the average difference in between treated and control, controlling for .
- With : the program is associated with an average increase of 12.4 points in the score, given the same level of family income.
- Observation: this is still not causal effect — requires randomization or quasi-experimental design.
- Ex. 106.8ApplicationAnswer key
, , , . Test at 5% level (two-tailed).
Show solution
t-test: . With , . Since , we reject . The predictor is significant at 5% level. - Ex. 106.9Application
, , , . Build 95% CI for . Use .
Show solution
95% CI for : . The CI does not contain 0: is significant at 5% level. - Ex. 106.10Application
Four of the five residuals from a regression are: ; ; ; . What is the fifth residual?
Show solution
Sum of residuals is always zero in any regression with intercept: . The sum of four known residuals is . Therefore the fifth residual is . Verification: . Correct. - Ex. 106.11Understanding
Which statement about and adjusted is CORRECT?
Show solution
never falls when adding predictors (mathematical property of OLS). penalizes for number of predictors and can fall when the added predictor is weak. That is why is the appropriate criterion for comparing models with different numbers of predictors. - Ex. 106.12Understanding
What is the main practical effect of multicollinearity in multiple regression?
Show solution
Multicollinearity does not bias estimators (they remain BLUE), but makes nearly singular, inflating and therefore the . Individual -tests lose power, but the global -test and predictions remain reliable. - Ex. 106.13Understanding
Which statement about partial coefficients in multiple regression is CORRECT?
Show solution
The phenomenon is called "sign reversal" or suppression effect. It occurs when is correlated with such that controlling for reveals the true relationship of with . Classic example: positive correlation between fire trucks and damage — controlling for fire size, the effect can change. - Ex. 106.14Modeling
Regression of monthly household spending (R$ thousands) on 4 socioeconomic predictors: , , . Calculate , and .
Show solution
; . . - Ex. 106.15Modeling
Model: (salary in R$ thousands, experience in years, =1 if woman). Calculate salaries for (a) man, 10 years; (b) woman, 10 years. How to add interaction to check if the gap varies with experience?
Show solution
See the reference indicated in fonte for detailed solution.Show step-by-step (with the why)
- Non-interaction model: one line with equal slope for men and women.
- For men (): . For women (): .
- Salary difference between genders is constant at R\$ 8 thousand for any experience level.
- To test if the difference varies with experience, add the interaction term .
- Observation: the interaction model is . If is significant, the gender difference varies with experience.
- Ex. 106.16Modeling
A researcher has a regression model with 2 predictors (, ) and considers adding a third predictor. Describe two criteria to decide whether to include it.
Show solution
Compare models with and without : if rises when including , keep it. Alternative: do partial -test for . If p-value less than 0.05, is significant given the others. AIC criterion: , lower is better. Use VIF to check if introduces severe multicollinearity. - Ex. 106.17Challenge
Prove that the hat matrix is idempotent: .
Show solution
The hat matrix is symmetric () and idempotent (). Idempotence: . This confirms that is an orthogonal projection: applying it twice gives the same result. - Ex. 106.18Challenge
Data: observations with , , . Write the design matrix and state the procedure to calculate (matrix inversion by hand not required — describe the steps).
Show solution
Build the matrices with the given data, calculate the product and obtain . This exercise is best solved with a matrix calculator or R/Python.Show step-by-step (with the why)
- With , : build (column of 1s, column , column ).
- Calculate (3×3 matrix).
- Calculate .
- Calculate (3×1 vector).
- Multiply: .
- Fun fact: in real applications, is computed numerically via QR decomposition, not direct inversion (more numerically stable).
- Ex. 106.19Proof
Prove that in any regression with intercept, , using the orthogonality .
Show solution
We must show that . Since and the first column of is a vector of 1s (), we have . The first row of is , therefore . - Ex. 106.20Challenge
Show that adding a predictor to the model increases if and only if the test statistic of the new predictor is greater than 1.
Show solution
Formula for change in when adding a predictor: increases if and only if the partial of the new predictor is greater than 1. Equivalently: of augmented model of reduced model . This shows that the criterion is less conservative than the -test at 5% level (which requires ). - Ex. 106.21Application
A multiple model predicts baby weight () with predictors: smoking cigarettes () and parity (, number of previous children). The coefficient of measures which effect?
Show solution
In multiple regression, the coefficient of "smoking" measures the partial effect — the expected change in baby weight per unit change in smoking, holding parity constant. Each coefficient is a conditional effect given the other predictors in the model. - Ex. 106.22ApplicationAnswer key
Research with 55 Duke University students models GPA as a function of: study hours per night, number of classes missed and gender. What does the coefficient of "study hours" represent in this multiple model?
Show solution
In a model with multiple predictors (GPA, study hours, classes missed, gender), the coefficient of each variable controls for the others. The coefficient of study hours represents the partial effect of one additional hour of study, holding the other variables (classes missed, gender) constant. - Ex. 106.23Application
Lumber mills estimate tree volume (in cubic feet) from diameter and height. A multiple regression model includes diameter (), height () and the product diameter height (). What is the role of the term in the model?
Show solution
Model with 3 predictors: diameter (), height () and interaction diameter×height (). The adjusted should be high due to the strong geometric relationship between these dimensions and volume.Show step-by-step (with the why)
- Model: where = diameter, = height, = diameter × height.
- Wood volume is the response variable .
- The product is an interaction term that allows the effect of diameter on volume to depend on height.
- With all three predictors, the model better captures the nonlinear relationship between dimensions and volume.
- Ex. 106.24ApplicationAnswer key
Comparing the simple model (smoking only) with the multiple model (smoking + parity) for baby weight: can the smoking coefficient differ in the two models? Why?
Show solution
In simple regression, the smoking coefficient absorbs also the confounding effect of parity (smoking mothers tend to have more or fewer children). In the multiple model, controlling for parity, the smoking coefficient captures only the partial effect. Coefficients can differ due to confounding. - Ex. 106.25Understanding
Why can adjusted decrease when we add a new predictor to the multiple regression model?
Show solution
. Adding a predictor reduces SSE, but also reduces the degrees of freedom . If the SSE reduction is small, the ratio can increase, making decrease.Show step-by-step (with the why)
- Formula: .
- When adding a predictor: , so (denominator decreases).
- SSE also decreases (more predictors reduce errors).
- If the SSE reduction is small (uninformative predictor), the ratio can increase.
- In that case, decreases — penalizing the model for including a redundant predictor.
- Ex. 106.26Modeling
Researchers investigate school absenteeism () as a function of lack of discipline () and distance from school to student's home (, in km). Write the multiple regression model and interpret each coefficient.
Show solution
Absenteeism as a function of lack of discipline and distance from school. Model: . The coefficient measures the effect of lack of discipline on absenteeism controlling for distance. The coefficient measures the effect of distance controlling for discipline. The intercept is the expected absenteeism when both variables are zero. - Ex. 106.27Understanding
What is the main practical effect of multicollinearity in a multiple regression model?
Show solution
When predictors are highly correlated, the matrix becomes nearly singular, amplifying coefficient standard errors. OLS estimators remain unbiased, but have very high variance, making individual -tests powerless to detect real effects. - Ex. 106.28ApplicationAnswer key
The VIF (Variance Inflation Factor) of a predictor is 5. What does this mean for the standard error of the estimated coefficient?
Show solution
The Variance Inflation Factor is , where is the of regressing on the other predictors. means that is 5 times larger than without collinearity; so the SE is times larger. - Ex. 106.29Modeling
A researcher wants to model ENEM score () of students as a function of: family income (), parental education (), weekly study hours () and school type (: 1=private, 0=public). Write the model, identify possible multicollinearity and describe how to verify it.
Show solution
Model: . Check multicollinearity between income and parental education via VIF.Show step-by-step (with the why)
- Proposed predictors to forecast ENEM scores: family income, parental education, study hours, school type (public/private).
- Check multicollinearity: income and parental education may be highly correlated. Calculate for each predictor.
- If for any predictor, consider removing the most collinear or using principal components.
- Check assumptions: plot residuals vs. fitted (homoscedasticity), QQ-plot (normality), plot residuals vs. order (independence).
- Ex. 106.30Modeling
Explain the variable selection strategies forward selection and backward elimination. Which criterion is more recommended when you have many candidate predictors?
Show solution
In stepwise selection, start without predictors (or with all) and add (or remove) predictors one by one by AIC criterion or partial -test p-value. Forward selection includes first the most significant predictor, then the second most significant given the first, etc. Backward elimination starts with all and removes the least significant. The AIC criterion balances fit and parsimony: . - Ex. 106.31ApplicationAnswer key
In the model of the previous exercise, the variable is a dummy (1=private, 0=public). How to interpret the coefficient ?
Show solution
When (private), increases by compared to (public), holding the other predictors constant. is the expected average difference between the two school categories, partially adjusted for income, parental education and study hours. - Ex. 106.32Understanding
What is the relationship between SST (total variation), SSR (variation explained by regression) and SSE (variation of residuals)?
Show solution
In the variance decomposition: , where SST = total sum of squares, SSR = regression sum of squares (explained) and SSE = sum of squared residuals (unexplained). By definition, . - Ex. 106.33ApplicationAnswer key
A multiple regression model with predictors fitted to observations has and . Calculate the global statistic and conclude at 5% level (critical value ).
Show solution
. We reject : the 3 predictors significantly explain the variation in Y. (Resp: )Show step-by-step (with the why)
- Data: , , , .
- Degrees of freedom: , .
- F statistic: .
- Critical value: . Since , we reject .
- Conclusion: the set of 3 predictors significantly explains the variation in Y at 5% level.
- Ex. 106.34Modeling
Tree volume in an orchard (in cubic feet) is modeled as a function of diameter (, in inches) and height (, in feet). Based on the multiple model, interpret the coefficient . What does an indicate about the fit?
Show solution
Model: . Each coefficient is the partial effect holding the other dimension constant. A high confirms that larger trees have larger volume, as geometrically expected.Show step-by-step (with the why)
- Base model: . With , : is .
- Data: diameter, height (in feet), volume (cubic feet).
- Calculate numerically and interpret: per extra unit of diameter (height fixed), volume changes by cubic feet.
- Check . If high (>0.90), the model fits well. Plot residuals vs. fitted to check homoscedasticity.
- Ex. 106.35Challenge
In a model with three predictors where (perfect multicollinearity), explain why the OLS solution does not exist. What does statistical software do in this situation?
Show solution
If (exact linear combination of the others), the matrix has determinant zero and is not invertible. The OLS solution does not exist. On the computer, the software detects perfect multicollinearity and automatically discards the redundant variable. - Ex. 106.36Challenge
A multiple regression model with 15 predictors and observations has . Explain why this high can be misleading and how cross-validation provides a more honest measure of predictive power.
Show solution
The cross-validation RMSE (leave-one-out or k-fold) is more honest than in-sample because it measures error on data not used in fitting. A model with many predictors can have (overfitting) but high out-of-sample RMSE. Adjusted and AIC penalize complexity, but only cross-validation directly estimates prediction error. - Ex. 106.37Application
In a multiple model, the intercept is not significant at 5% level. Should it be removed from the model? What is the interpretation of the intercept?
Show solution
The intercept is the predicted value of when all predictors are zero. In many practical contexts, this makes no sense (height = 0, income = 0). Still, the intercept is necessary to correctly center the regression and should be kept even when not significant, to avoid bias in the other coefficients. - Ex. 106.38Proof
Derive the normal equations from the minimization of with respect to . Use the result to show that residuals are orthogonal to the columns of .
Show solution
The normal equations are . Multiplying on the left by : . To verify : , so . This implies (first row of is 1s). - Ex. 106.39Proof
Define the hat matrix . Prove that is idempotent () and symmetric. What is the trace of and what does it represent geometrically?
Show solution
The hat matrix is . Fitted values are and residuals . Properties: (1) is symmetric: ; (2) is idempotent: (orthogonal projection); (3) eigenvalues of are 0 and 1; (4) (number of estimated parameters). - Ex. 106.40Understanding
Which diagnostic plot specifically verifies the normality assumption of errors in a multiple regression model? What do we observe in this plot when normality is satisfied?
Show solution
The QQ-plot (quantile-quantile plot) of residuals versus quantiles of a standard normal distribution should show points on a diagonal line if errors are normally distributed. Deviations at the tails indicate skewness or heavy tails. It is one of the standard diagnostic plots for the normality assumption (N in the LINE mnemonic). - Ex. 106.41Modeling
For the model of exercise 106.33 (, , , ): calculate and adjusted . Compare the two and interpret the difference.
Show solution
For the regression with , , , : . . . The model explains 57.6% of Y variance after penalizing for complexity. - Ex. 106.42Challenge
In a model with predictors, each coefficient is tested at level . What is the probability of at least one Type I error (false positive) under the global ? How does Bonferroni adjustment correct this?
Show solution
With predictors, the individual -test of at level has probability of false positive per predictor. With independent tests and : probability of at least one false positive . Corrections: Bonferroni (), Holm (sequential procedure), or false discovery rate control (Benjamini-Hochberg FDR).
Sources
- OpenIntro Statistics (4th ed.) — Diez, Çetinkaya-Rundel, Barr · CC-BY-SA · Chapter 8 (Multiple and logistic regression). Primary source for coefficient interpretation, , multicollinearity and dummy variables.
- Statistics — OpenStax — Illowsky, Dean · CC-BY · Chapter 13 (Linear Regression and Correlation — Multiple). Source for ANOVA tables of multiple regression and global F-test.
- Probabilidade e Estatística — Wikilivros — collaborative · CC-BY-SA · Multiple regression section. Portuguese-language reference with matrix notation compatible with Brazilian engineering curriculum.