library(faraway)
## Warning: package 'faraway' was built under R version 3.3.3
data(prostate)
prostate[1:5,]
## lcavol lweight age lbph svi lcp gleason pgg45 lpsa
## 1 -0.5798185 2.7695 50 -1.386294 0 -1.38629 6 0 -0.43078
## 2 -0.9942523 3.3196 58 -1.386294 0 -1.38629 6 0 -0.16252
## 3 -0.5108256 2.6912 74 -1.386294 0 -1.38629 7 20 -0.16252
## 4 -1.2039728 3.2828 58 -1.386294 0 -1.38629 6 0 -0.16252
## 5 0.7514161 3.4324 62 -1.386294 0 -1.38629 6 0 0.37156
attach(prostate)
prostate.lm <- lm(lpsa ~ lcavol+age+lweight+gleason) #how does it treat factor veriables?
summary(prostate.lm)
##
## Call:
## lm(formula = lpsa ~ lcavol + age + lweight + gleason)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.48679 -0.46467 -0.00243 0.38421 1.95227
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.85636 1.04299 -0.821 0.413732
## lcavol 0.64443 0.07367 8.748 9.82e-14 ***
## age -0.01320 0.01125 -1.173 0.243783
## lweight 0.58736 0.16506 3.559 0.000592 ***
## gleason 0.17211 0.12103 1.422 0.158393
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.7476 on 92 degrees of freedom
## Multiple R-squared: 0.5981, Adjusted R-squared: 0.5806
## F-statistic: 34.22 on 4 and 92 DF, p-value: < 2.2e-16
plot(prostate.lm)