Question
Load the prostate data set from the faraway package. The data are from a study of 97 men with prostate cancer who were due to
Load the prostate data set from the faraway package. The data are from a study of 97 men with
prostate cancer who were due to receive a radical prostatectomy. More details can be found by running
?faraway::prostate in the R Console. The variables in the data set include:
lcavol: log(cancer volume)
lweight: log(prostate weight)
age: subject age (years)
lbph: log(benign prostatic hyperplasia amount)
svi: seminal vesicle invasion
lcp: log(capsular penetration)
gleason: Gleason score
pgg45: percentage Gleason scores 4 or 5
lpsa: log(prostate specific antigen)
Unfortunately, units are not provided.
data(prostate, package = "faraway")
We will consider the relationship between the response lpsa and several of the other variables in the data set.
________________________________________________________________________________________________________________________________________________________
First, run the following code in the R Console. The update function takes an existing fitted model and
updates it. The notation . ~ . + var means keep the existing response and regressors but add var to the
model.
# fit model with an intercept
lmod1 <- lm(lpsa ~ 1, data = prostate)
summary(lmod1)$r.squared
# fit model with an intercept and lcavol
lmod2 <- update(lmod1, . ~ . + lcavol, data = prostate)
summary(lmod2)$r.squared
# fit model with an intercept, lcavol, and lweight
lmod3 <- update(lmod2, . ~ . + lweight, data = prostate)
summary(lmod3)$r.squared
# fit model with an intercept, lcavol, lweight, and age
lmod4 <- update(lmod3, . ~ . + age, data = prostate)
summary(lmod4)$r.squared
lmod5 <- update(lmod4, . ~ . + lbph, data = prostate)
summary(lmod5)$r.squared
lmod6 <- update(lmod5, . ~ . + svi, data = prostate)
summary(lmod6)$r.squared
lmod7 <- update(lmod6, . ~ . + lcp, data = prostate)
summary(lmod7)$r.squared
lmod8 <- update(lmod7, . ~ . + gleason, data = prostate)
summary(lmod8)$r.squared
lmod9 <- update(lmod7, . ~ . + rnorm(97), data = prostate)
summary(lmod9)$r.squared
(a)
Complete a table with the results from the code above with the following format. Replace x with the R2
value from the fitted model.