# 420Hw08ans - STAT 420 Spring 2010 Homework#8(due Friday...

This preview shows pages 1–5. Sign up to view the full content.

STAT 420 Spring 2010 Homework #8 (due Friday, April 2, by 4:00 p.m.) 1. The dataset prostate comes from a study on 97 men with prostate cancer who were due to receive a radical prostatectomy. ( Andrews D. F. and Herzberg A. M. (1985): Data. New York: Springer-Verlag ) . > library(faraway) > data(prostate) > prostate[1:5,] # to see what the data set looks like 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) OR The data set is also available at http://www.stat.uiuc.edu/~stepanov/prostate.csv lcavol log(cancer volume) lweight log(prostate weight) age age 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) a) Fit a model with lpsa as the response and lcavol as predictor. Record the residual standard error and the R 2 . Now add lweight , svi , lbph , age , lcp , pgg45 and gleason to the model one at a time (in the order that is specified). For each model, record the residual standard error and the R 2 . Plot the trends in these two statistics. > library(faraway) > data(prostate)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
> 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) > > > s = rep(0,8) > R2 = rep(0,8) > > > fit1 = lm(lpsa~lcavol) > > names(fit1) [1] "coefficients" "residuals" "effects" "rank" [5] "fitted.values" "assign" "qr" "df.residual" [9] "xlevels" "call" "terms" "model" > > names(summary(fit1)) [1] "call" "terms" "residuals" "coefficients" [5] "aliased" "sigma" "df" "r.squared" [9] "adj.r.squared" "fstatistic" "cov.unscaled" Here "sigma" is the residual standard error s e , and "r.squared" is R 2 , so the two could be extracted from the summary of each model. > s[1] = summary(fit1)\$sigma > R2[1] = summary(fit1)\$r.squared > > fit2 = lm(lpsa~lcavol+lweight) > s[2] = summary(fit2)\$sigma > R2[2] = summary(fit2)\$r.squared > > fit3 = lm(lpsa~lcavol+lweight+svi) > s[3] = summary(fit3)\$sigma > R2[3] = summary(fit3)\$r.squared
> fit4 = lm(lpsa~lcavol+lweight+svi+lbph) > s[4] = summary(fit4)\$sigma > R2[4] = summary(fit4)\$r.squared > > fit5 = lm(lpsa~lcavol+lweight+svi+lbph+age) > > s[5] = summary(fit5)\$sigma > R2[5] = summary(fit5)\$r.squared > > fit6 = lm(lpsa~lcavol+lweight+svi+lbph+age+lcp) > s[6] = summary(fit6)\$sigma > R2[6] = summary(fit6)\$r.squared > > fit7 = lm(lpsa~lcavol+lweight+svi+lbph+age+lcp+pgg45) > s[7] = summary(fit7)\$sigma > R2[7] = summary(fit7)\$r.squared > > fit8 = lm(lpsa~lcavol+lweight+svi+lbph+age+lcp+pgg45+gleason) > s[8] = summary(fit8)\$sigma > R2[8] = summary(fit8)\$r.squared > > > plot(s) > title("Residual standard error")

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
> plot(R2) > title("R squared") Since R 2 represents the proportion of observed variation of the response variable that can be explained by the regression model, the values of R 2 should be monotonically increasing as we include more predictors.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern