
HIGHER DIMENSIONS 169
Exercise 4.6
Modify the following function pairslm() so that it calculates the resid-
uals of the regression of all original variables in matrix x by regression
after the new variable x$fit and produces a scatterplot matrix of these
residuals.
pairslm <- function(model, x, ... )
{ x$fit <- lm(model, x)$fit; pairs(x, ...) }
Add title, legends, etc.
Use the “trees” data set as an example.
We discussed the transition from p
0
to p
0
+ 1 variable. The scatterplot matrix allows us to get a
quick overview of a (not too large) number of candidates (three potential additional regressors
in our case). The transition from p to p −1 for the elimination ...