Peter von Rohr
9 Dec 2014
R
?attitude
pairs plot
Let us assume that
rating
which contains the overall rating of a given survey is of special interest in a way that we want to find the relation of this variable to all other variablesresponse
predictor
variableslm()
using the following syntaxfm1 <- lm(rating ~ ., data = attitude)
lm
which has different methods that can be applied to, such assummary()
to get a summary of the model resultscoef()
which is an accessor for the coefficientsresiduals()
which shows the residuals?lm
for a complete listsummary()
method shows all important characteristics of a linear model objectsummary(fm1)
lm
function which produced the summary shown##
## Call:
## lm(formula = rating ~ ., data = attitude)
Min
)Median
)Max
)1Q
, 3Q
)##
## Residuals:
## Min 1Q Median 3Q Max
## -10.9418 -4.3555 0.3158 5.5425 11.599
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 10.7871 11.5893 0.9308 0.3616
## complaints 0.6132 0.161 3.809 9e-04
## privileges -0.0731 0.1357 -0.5382 0.5956
## learning 0.3203 0.1685 1.9009 0.0699
## raises 0.0817 0.2215 0.369 0.7155
## critical 0.0384 0.147 0.2611 0.7963
## advance -0.2171 0.1782 -1.218 0.2356
##
## Residual standard error: 7.07 on 23 degrees of freedom
## Multiple R-squared: 0.733 , Adjusted R-squared: 0.663
## F-statistic: 10.5 on 6 and 23 DF, p-value: 1.24e-05
opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0));plot(fm1);par(opar)
Tukey-Anscomb
plot (top left) shows residuals vs. fitted values, ideally the points do not show any “pattern”Normal Q-Q
plot (top right) compares empirical quantiles with expected quantiles under the normal distribution. Assumption of Gaussian residuals is met when all points are on the dotted line shown in the plotScale Location
plot (bottom left) is an indicator for dependencies between variability of observations and parameter locationLeverage
plot (bottom right)