We can use the names()
function in order to find out what other pieces of information are stored in lm.fit
.
Although we can extract these quantities by name—e.g. lm.fit$coefficients
—it is safer to use the extractor
functions like coef()
to access them.
> names(lm.fit)
[1] "coefficients" "residuals" "effects"
[4] "rank" "fitted.values" "assign"
[7] "qr" "df.residual " "xlevels "
[10] "call" "terms" "model"
> coef(lm.fit)
(Intercept) lstat
34.55 -0.95
Try calling the coefficients of the following model:
Assume that:
MASS
library has been loadedBoston
dataset has been loaded and attached