Lecture 6: Multiple Linear Regression Adjusted Variable Plots BMTRY 701 Biostatistical Methods II
Graphical Displays in MLR No more one simple scatterplot: need to look at multiple pairs of variables “pairs” in R. but, we cant look at all in regards to the way thet enter the model solution: adjusted variable plot
Adjusted Variable Plots Adjusted variable plots are useful in linear regression for outlier detection and for qualitative evaluation of the fit of a model. With two covariates: Shows the association between X and Y adjusted for another variable, Z. With more than two covariates: Shows the association between X and Y adjusted for many other covariates In our example, association between logLOS and number of nurses, adjusted for number of beds
Approach Assume we want to look at the association of Y and X, adjusted for Z Step 1: Regress Y on X and save residuals (res.xy) Step 2: Regress Z on X and save residuals (res.xz) Step 3: plot res.xy versus res.xz Optional step 4: perform regression of res.xy on res.xz compare slope to that of MLR of Y on X and Z
SENIC
R pairs(~INFRISK+BEDS+logLOS, data=data, pch=16) # adjusted variable plot approach # look at the association between INFRISK and logLOS, # adjusting for BEDS reg.xy <- lm(logLOS ~ BEDS, data=data) res.xy <- reg.xy$residuals reg.xz <- lm(INFRISK ~ BEDS, data=data) res.xz <- reg.xz$residuals plot(res.xz, res.xy, pch=16) reg.res <- lm(res.xy ~ res.xz) abline(reg.res, lwd=2) reg.infrisk.beds <- lm(logLOS ~ BEDS + INFRISK, data=data)
Why is this important or interesting? It shows us the ‘adjusted’ relationship it can help us determine if it is an important variable (at all) if another form of X is more appropriate if the correlation is high vs. low after adjustment we need to/want to adjust for this variable It also informs us about why a variable ‘loses’ significance Most important: check for non-linearity Example: logLOS ~ NURSE
What about BEDS and NURSE? # why NURSE is not associated, after adjustment for BEDS? reg.nurse <- lm(logLOS ~ NURSE, data=data) reg.nurse.beds <- lm(logLOS ~ NURSE + BEDS, data=data) reg.xy <- lm(logLOS ~ BEDS, data=data) res.xy <- reg.xy$residuals reg.xz <- lm(NURSE ~ BEDS, data=data) res.xz <- reg.xz$residuals plot(res.xz, res.xy, pch=16) reg.res <- lm(res.xy ~ res.xz) abline(reg.res, lwd=2)
What about the other way around? ####################### # what about the other way? what about why BEDS is # assoc after adjustment for NURSE? reg.xy <- lm(logLOS ~ NURSE, data=data) res.xy <- reg.xy$residuals reg.xz <- lm(BEDS ~ NURSE, data=data) res.xz <- reg.xz$residuals plot(res.xz, res.xy, pch=16) reg.res <- lm(res.xy ~ res.xz) abline(reg.res, lwd=2) reg.nurse.beds <- lm(logLOS ~ NURSE + BEDS, data=data)
Interpretation in MLR “Adjusted for” “Controlled for “ “Holding all else constant” In MLR, you need to include one of these phrases (or something like one of them) when interpreting a regression coefficient
LOS ~ INFRISK + BEDS > reg.infrisk.beds <- lm(LOS ~ BEDS + INFRISK, data=data) > summary(reg.infrisk.beds) Call: lm(formula = LOS ~ BEDS + INFRISK, data = data) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) < 2e-16 *** BEDS ** INFRISK e-07 *** ---
Hard to interpret with so many decimal places! > data$beds100 <- data$BEDS/100 > reg.infrisk.beds <- lm(LOS ~ beds100 + INFRISK, data=data) > summary(reg.infrisk.beds) Call: lm(formula = LOS ~ beds100 + INFRISK, data = data) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) < 2e-16 *** beds ** INFRISK e-07 *** ---
logLOS ~ INFRISK + BEDS > reg.infrisk.beds <- lm(logLOS ~ BEDS + INFRISK, data=data) > summary(reg.infrisk.beds) Call: lm(formula = logLOS ~ BEDS + INFRISK, data = data) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.926e e < 2e-16 *** BEDS 2.407e e ** INFRISK 6.048e e e-07 *** ---
Hard to interpret with so many decimal places! > data$beds100 <- data$BEDS/100 > reg.infrisk.beds100 <- lm(logLOS ~ beds100 + INFRISK, data=data) > summary(reg.infrisk.beds100) Call: lm(formula = logLOS ~ beds100 + INFRISK, data = data) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) < 2e-16 *** beds ** INFRISK e-07 *** --- Signif. codes: 0 ‘***’ ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: on 110 degrees of freedom Multiple R-squared: , Adjusted R-squared: F-statistic: 31.1 on 2 and 110 DF, p-value: 1.971e-11
How to interpret? Pick two values of BEDS e.g. 100 to 200 e.g. 400 to 500 Estimate the difference in logLOS for each value What do we plug in for INFRISK?
How to interpret? Remember that our inferences are “holding all else constant” To compare two hospitals with the same INFRISK, it doesn’t matter what you put in
How to interpret? Comparing two hospitals whose number of beds differ by 100 and assuming the same infection risk in the two hospitals is the same, the ratio of average LOS in the two hospitals is 1.02 with the hospital with more beds having the longer stay.
difference of 400 beds?
When outcome is log transformed interpretation of coefficients can be made as RATIOS instead of DIFFERENCES Need to exponentiate the coefficient. its interpretation is the ratio for a one-unit difference in the predictor.