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

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
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)
Background image of page 1

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

View Full DocumentRight Arrow Icon
> 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
Background image of page 2
> 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
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/08/2012 for the course STAT 420 taught by Professor Stepanov during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 18

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

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online