Information Technology Reference
In-Depth Information
See Also
See
Recipe 1.20
for simple linear regression.
1.22 Getting Regression Statistics
Problem
You want the critical statistics and information regarding your regression, such as
R
2
,
the
F
statistic, confidence intervals for the coefficients, residuals, the ANOVA table,
and so forth.
Solution
Save the regression model in a variable, say
m
:
>
m <- lm(y ~ u + v + w)
Then, use the following functions to extract regression statistics and information from
the model:
anova(m)
ANOVA table
coefficients(m)
Model coefficients
coef(m)
Same as
coefficients(m)
confint(m)
Confidence intervals for the regression coefficients
deviance(m)
Residual sum of squares
effects(m)
Vector of orthogonal effects
fitted(m)
Vector of fitted
y
values
residuals(m)
Model residuals
resid(m)
Same as
residuals(m)
summary(m)
Key statistics, such as
R
2
, the
F
statistic, and the residual standard error (
σ
)
vcov(m)
Variance-covariance matrix of the main parameters