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 with several predictors ,
where the error has mean given the predictors. Least squares chooses to minimize . The design has 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 are orthogonal to every column, so and for each predictor. When the minimizer is unique and , the residual degrees of freedom are and the residual variance is estimated by
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, is the distance in kilometers and for route B and for route A. Least squares gives in minutes.
| Route | Distance (km) | Time (min) | Fitted | Residual | |
|---|---|---|---|---|---|
| A | |||||
| A | |||||
| A | |||||
| B | |||||
| B | |||||
| B |
The residuals sum to , their products with sum to , and their products with distance sum to , because each route contributes . These are the three normal equations. The fit has and residual degrees of freedom, so and minutes.
Partial regression coefficient
Definition In a multiple regression, the coefficient of a predictor is called a partial regression coefficient. When appears in no other term of the model, such as an interaction or a power, is the change in the fitted response when increases by one unit while every other predictor in the model stays fixed, measured in response units per unit of . Equivalently, is the least-squares slope of on the residuals from regressing on the other columns of the design, including the column of ones. So it uses only the part of 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 is nearly a linear combination of the other predictors, which is called multicollinearity, little of its variation is left over. Then 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 , the distance coefficient says that among trips on the same route, each extra kilometer goes with more fitted minutes. Removing the part of distance explained by route leaves in each route of the table, because both routes have mean distance . The slope of time on these residuals is
Here distance is uncorrelated with route, so the least-squares slope of time on distance alone is also . 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 with a group indicator , the residuals sum to within each group, so the raw difference between the group mean responses splits exactly as
The adjusted difference is conditional on the predictors in the model and on its form, here a straight line in with the same slope in both groups. The data support it directly only where the groups overlap in .
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 and km take and minutes, and route B trips of and km take and minutes, exactly on . The raw difference is minutes, while the adjusted difference is minutes. The remaining minutes go with route B trips being 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 for units in that category and for all other units. To include a categorical predictor with categories in a model with an intercept, choose one category as the reference group and include indicators, one for each other category. Units in the reference group have every indicator equal to . 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 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 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 and only record membership, and the coefficient of an indicator is measured in the units of the response.
Example In the indicator marks route B, so route A is the reference group. The intercept is the predicted time of a route A trip of distance , which lies outside the to km in the data and has little practical meaning. At km route A predicts minutes and route B predicts minutes. Now add an indicator for route A next to and the intercept. For every number , the coefficients for the intercept, for distance, for and for 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 with coefficient , and let be the coefficient of an included predictor in the least-squares regression of on the included predictors. Then the coefficient of in the short model without is
so the coefficient changes exactly when both and 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 , the raw difference. Distance had coefficient in the long model, and the regression of distance on the indicator has coefficient , so . Dropping route instead gives a distance slope of minutes per km, which is , where 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
- Using , with in km, 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 minutes?
Show the answer
The route B trip has predicted time minutes and the route A trip has minutes. The difference, B minus A, is minute, which equals . The route term adds minutes, but the route B trip is km shorter, which is worth minutes. The coefficient compares trips at the same distance, and these two trips differ in distance as well as route.
- A least-squares fit with an intercept, distance and the route B indicator to a large set of trips gives . In the same data, route B trips take 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 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 , and route B trips are km longer on average. The fit does not show a causal effect. The 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 minutes. The value also relies on the straight-line form with a common slope.
- Trips now use three routes, A, B and C. An analyst fits an intercept, distance and the indicators , and , 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 . Compare route C with route B at the same distance.
Show the answer
Every trip is on exactly one route, so 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 , makes route A the reference group and removes this dependence. In the refitted model, at equal distance, route B trips are predicted minutes longer than route A trips and route C trips minute shorter. So route C trips are predicted minutes relative to route B, that is, minutes shorter than route B trips of the same distance. This comparison is not a single coefficient, but it follows from the two.