Unit 9, lesson 65

Multiple Regression and Adjusted Associations

How multiple regression describes one response with several predictors, how a partial regression coefficient gives an adjusted association, and how indicator variables, a reference group and omitted variables shape that reading.

  • Video 65
  • Multiple Regression and Model Building

Delivery trips on route B take longer on average than trips on route A. Is route B slower, or are its trips simply longer? A comparison of the two route averages cannot tell, because it mixes route with distance. Multiple regression puts distance and route into one model for the same response, so that each coefficient compares trips that agree on the other predictor. This lesson shows how to read such coefficients, how to bring a category into the model through a reference group, and why an adjusted comparison is still not automatically a causal effect.

Key terms

Multiple regression

Definition A multiple linear regression model describes one numerical response YY with several predictors x1,…,xpx_1, \dots, x_p,

Yi=β0+β1xi1+⋯+βpxip+εi,\begin{aligned} Y_i &= \beta_0 + \beta_1 x_{i1} + \cdots \\[0.4em] &\quad + \beta_p x_{ip} + \varepsilon_i , \end{aligned}

where the error εi\varepsilon_i has mean 00 given the predictors. Least squares chooses b0,…,bpb_0, \dots, b_p to minimize SSE=∑(yi−y^i)2\text{SSE} = \sum (y_i - \hat{y}_i)^2. The design has p+1p + 1 columns, the column of ones and one column for each predictor. If none of them is a linear combination of the others, the minimizer is unique. The residuals ei=yi−y^ie_i = y_i - \hat{y}_i are orthogonal to every column, so ∑ei=0\sum e_i = 0 and ∑xijei=0\sum x_{ij} e_i = 0 for each predictor. When the minimizer is unique and n>p+1n > p + 1, the residual degrees of freedom are n−p−1n - p - 1 and the residual variance is estimated by

s2=SSEn−p−1.s^2 = \frac{\text{SSE}}{n - p - 1} .

Standard errors, tests and intervals need the same error conditions as in simple regression, namely independent errors with constant variance and, for exact t and F procedures, normal errors. With large samples, tests and intervals for the coefficients remain approximately valid without normal errors, but a prediction interval for one new observation does not.

In plain words There is one response and several predictors. The word multiple refers to the predictors, not to several responses. The fit is still least squares, now with one coefficient per column, and each estimated coefficient uses up one residual degree of freedom.

Example In a constructed data set of six trips, xx is the distance in kilometers and g=1g = 1 for route B and 00 for route A. Least squares gives y^=5+2x+3g\hat{y} = 5 + 2x + 3g in minutes.

RouteDistance xx (km)ggTime (min)FittedResidual
A11006677−1-1
A220011119922
A330010101111−1-1
B1111991010−1-1
B22111414121222
B331113131414−1-1

The residuals sum to 00, their products with gg sum to 00, and their products with distance sum to 00, because each route contributes (−1)(1)+2(2)+(−1)(3)=0(-1)(1) + 2(2) + (-1)(3) = 0. These are the three normal equations. The fit has SSE=6+6=12\text{SSE} = 6 + 6 = 12 and 6−2−1=36 - 2 - 1 = 3 residual degrees of freedom, so s2=12/3=4 min2s^2 = 12/3 = 4 \ \text{min}^2 and s=2s = 2 minutes.

Partial regression coefficient

Definition In a multiple regression, the coefficient bjb_j of a predictor xjx_j is called a partial regression coefficient. When xjx_j appears in no other term of the model, such as an interaction or a power, bjb_j is the change in the fitted response when xjx_j increases by one unit while every other predictor in the model stays fixed, measured in response units per unit of xjx_j. Equivalently, bjb_j is the least-squares slope of yy on the residuals from regressing xjx_j on the other columns of the design, including the column of ones. So it uses only the part of xjx_j that the other predictors do not explain linearly, and its value depends on which other predictors are in the model.

In plain words A partial coefficient compares fitted values for units that differ by one unit in this predictor and match on every other predictor in the model. When xjx_j is nearly a linear combination of the other predictors, which is called multicollinearity, little of its variation is left over. Then bjb_j rests on little information and has a large standard error, even when fitted values at predictor combinations like those in the data are estimated well.

Example In y^=5+2x+3g\hat{y} = 5 + 2x + 3g, the distance coefficient says that among trips on the same route, each extra kilometer goes with 22 more fitted minutes. Removing the part of distance explained by route leaves x−2x - 2 in each route of the table, because both routes have mean distance 22. The slope of time on these residuals is

∑(xi−2)yi∑(xi−2)2=84=2.\frac{\sum (x_i - 2) y_i}{\sum (x_i - 2)^2} = \frac{8}{4} = 2 .

Here distance is uncorrelated with route, so the least-squares slope of time on distance alone is also 22. In the changed data of the next card the two slopes differ.

Adjusted association

Definition The association between the response and a predictor adjusted for other predictors is the comparison of fitted mean responses between units that differ in that predictor but have the same values of the other predictors in the model. For a least-squares fit of y^=b0+bxx+bgg\hat{y} = b_0 + b_x x + b_g g with a group indicator gg, the residuals sum to 00 within each group, so the raw difference between the group mean responses splits exactly as

yˉB−yˉA=bg+bx(xˉB−xˉA).\begin{aligned} \bar{y}_B - \bar{y}_A &= b_g \\[0.4em] &\quad + b_x (\bar{x}_B - \bar{x}_A) . \end{aligned}

The adjusted difference bgb_g is conditional on the predictors in the model and on its form, here a straight line in xx with the same slope in both groups. The data support it directly only where the groups overlap in xx.

In plain words Adjusting means comparing like with like, as far as the model’s predictors go. The raw difference mixes the group difference with differences in the other predictors. Trips of the same distance on the two routes can still differ in other ways, such as time of day or traffic, so an adjusted association is still an association and not automatically a causal effect.

Example In changed constructed data, route A trips of 11 and 22 km take 77 and 99 minutes, and route B trips of 33 and 44 km take 1414 and 1616 minutes, exactly on y^=5+2x+3g\hat{y} = 5 + 2x + 3g. The raw difference is 15−8=715 - 8 = 7 minutes, while the adjusted difference is 33 minutes. The remaining 2⋅(3.5−1.5)=42 \cdot (3.5 - 1.5) = 4 minutes go with route B trips being 22 km longer on average. No trip on one route shares a distance with a trip on the other, so the comparison at a common distance extends at least one route’s line beyond its own data and rests on the straight-line, equal-slope form.

Indicator variable and reference group

Definition An indicator variable for a category equals 11 for units in that category and 00 for all other units. To include a categorical predictor with kk categories in a model with an intercept, choose one category as the reference group and include k−1k - 1 indicators, one for each other category. Units in the reference group have every indicator equal to 00. In a model with no interactions involving the indicators, each indicator’s coefficient is the difference in fitted mean response between its category and the reference group at equal values of the other predictors. Including all kk indicators together with the intercept makes the design columns linearly dependent, because the indicators add up to the column of ones, and then the coefficients are not unique. Dropping the intercept and keeping all kk indicators is another valid coding, in which each indicator’s coefficient is that group’s own intercept.

In plain words Each indicator is an on or off switch for one category. The reference group is the baseline that every other group is compared with, so a report should name it. The 00 and 11 only record membership, and the coefficient of an indicator is measured in the units of the response.

Example In y^=5+2x+3g\hat{y} = 5 + 2x + 3g the indicator marks route B, so route A is the reference group. The intercept 55 is the predicted time of a route A trip of distance 00, which lies outside the 11 to 33 km in the data and has little practical meaning. At 22 km route A predicts 5+4=95 + 4 = 9 minutes and route B predicts 9+3=129 + 3 = 12 minutes. Now add an indicator IAI_A for route A next to IB=gI_B = g and the intercept. For every number cc, the coefficients 5+c5 + c for the intercept, 22 for distance, −c-c for IAI_A and 3−c3 - c for IBI_B give exactly the same fitted values, so the data cannot choose among them.

Omitted variable

Definition An omitted variable is a variable left out of a regression model that is related to the response and to one or more of the included predictors. Leaving it out can change the coefficients of those predictors. For least-squares fits with an intercept on the same data, let the long model contain an extra predictor zz with coefficient bzb_z, and let δx\delta_x be the coefficient of an included predictor xx in the least-squares regression of zz on the included predictors. Then the coefficient of xx in the short model without zz is

bxshort=bxlong+bz δx,b_x^{\text{short}} = b_x^{\text{long}} + b_z \, \delta_x ,

so the coefficient changes exactly when both bzb_z and δx\delta_x are nonzero. An omitted common cause of a predictor and the response is a confounder of that comparison.

In plain words A coefficient describes an association given the variables in the model and no others, so adding or removing a variable can change the other coefficients. Adding more variables does not guarantee a causal reading. Unmeasured confounders, measurement error in the predictors, and adjusting for a variable that is itself a consequence of the predictor can all still distort the comparison.

Example In the changed data, drop distance and regress time on the route indicator alone. The route coefficient becomes 77, the raw difference. Distance had coefficient 22 in the long model, and the regression of distance on the indicator has coefficient 3.5−1.5=23.5 - 1.5 = 2, so 7=3+2⋅27 = 3 + 2 \cdot 2. Dropping route instead gives a distance slope of 3.23.2 minutes per km, which is 2+3⋅0.42 + 3 \cdot 0.4, where 0.40.4 is the slope of the route indicator on distance. In each short model, the remaining predictor picks up part of the association of the one that was left out.

Check yourself

  1. Using y^=5+2x+3g\hat{y} = 5 + 2x + 3g, with xx in km, g=1g = 1 for route B and route A as the reference group, predict the time of a 1 km route B trip and of a 3 km route A trip. Why is the difference between these predictions not 33 minutes?
Show the answer

The route B trip has predicted time 5+2+3=105 + 2 + 3 = 10 minutes and the route A trip has 5+6=115 + 6 = 11 minutes. The difference, B minus A, is −1-1 minute, which equals 3+2(1−3)3 + 2(1 - 3). The route term adds 33 minutes, but the route B trip is 22 km shorter, which is worth −4-4 minutes. The coefficient 33 compares trips at the same distance, and these two trips differ in distance as well as route.

  1. A least-squares fit with an intercept, distance and the route B indicator to a large set of trips gives y^=5+2x+3g\hat{y} = 5 + 2x + 3g. In the same data, route B trips take 77 minutes longer on average than route A trips. By how much do the average distances of the two routes differ? Does the fit show that moving a trip from route A to route B would add 33 minutes?
Show the answer

Because the model contains the intercept and the route indicator, the residuals sum to zero within each route, so each route’s mean time equals the fitted value at that route’s mean distance. Hence 7=3+2(xˉB−xˉA)7 = 3 + 2(\bar{x}_B - \bar{x}_A), and route B trips are 22 km longer on average. The fit does not show a causal effect. The 33 minutes is an association adjusted for distance only. Route B trips may also differ in time of day, traffic or load, and unless routes were assigned at random, those differences can be part of the 33 minutes. The value also relies on the straight-line form with a common slope.

  1. Trips now use three routes, A, B and C. An analyst fits an intercept, distance and the indicators IAI_A, IBI_B and ICI_C, and the software reports that one coefficient cannot be estimated. Explain why and fix the model. After refitting with route A as the reference group, the fit is y^=6+2x+3IB−IC\hat{y} = 6 + 2x + 3I_B - I_C. Compare route C with route B at the same distance.
Show the answer

Every trip is on exactly one route, so IA+IB+IC=1I_A + I_B + I_C = 1 for every trip, which is the intercept column. The design columns are linearly dependent, and infinitely many coefficient vectors give the same fitted values. Dropping one indicator, here IAI_A, makes route A the reference group and removes this dependence. In the refitted model, at equal distance, route B trips are predicted 33 minutes longer than route A trips and route C trips 11 minute shorter. So route C trips are predicted −1−3=−4-1 - 3 = -4 minutes relative to route B, that is, 44 minutes shorter than route B trips of the same distance. This comparison is not a single coefficient, but it follows from the two.

How this lesson connects