Multiple Linear Regression in R

Peter von Rohr

9 Dec 2014

Example Data

Graphical inspection of attitude dataset

plot of chunk unnamed-chunk-1

Goals

Let us assume that

A First Linear Model

fm1 <- lm(rating ~ ., data = attitude)

Results From First Model

summary(fm1)
## 
## Call:
## lm(formula = rating ~ ., data = attitude)

Part two summarizes the residuals. This summary contains

## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.9418  -4.3555   0.3158   5.5425   11.599

Part three presents

## 
## 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

Last part lists

## 
## 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

Diagnostics Plots

opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0));plot(fm1);par(opar)

plot of chunk unnamed-chunk-8