alkfos PCA SPH 247 Statistical Analysis of Laboratory
alkfos PCA SPH 247 Statistical Analysis of Laboratory Data
> library(ISw. R) > data(alkfos) > names(alkfos) [1] "grp" "c 0" "c 3" "c 6" "c 9" > summary(alkfos) grp c 0 Min. : 1. 000 Min. : 81. 0 1 st Qu. : 1. 000 1 st Qu. : 124. 0 Median : 1. 000 Median : 161. 0 Mean : 1. 465 Mean : 159. 9 3 rd Qu. : 2. 000 3 rd Qu. : 190. 5 Max. : 2. 000 Max. : 237. 0 c 9 Min. : 74. 0 1 st Qu. : 107. 5 Median : 140. 5 Mean : 140. 3 3 rd Qu. : 163. 5 Max. : 240. 0 NA's : 1. 0 May 7, 2010 c 12 Min. : 73. 0 1 st Qu. : 103. 0 Median : 134. 0 Mean : 143. 3 3 rd Qu. : 168. 0 Max. : 289. 0 NA's : 2. 0 "c 12" "c 18" "c 24“ c 3 Min. : 79. 0 1 st Qu. : 110. 0 Median : 134. 0 Mean : 143. 3 3 rd Qu. : 170. 5 Max. : 277. 0 c 6 Min. : 79. 0 1 st Qu. : 112. 5 Median : 146. 0 Mean : 149. 0 3 rd Qu. : 167. 5 Max. : 298. 0 c 18 Min. : 69. 0 1 st Qu. : 114. 0 Median : 140. 0 Mean : 149. 1 3 rd Qu. : 185. 5 Max. : 288. 0 NA's : 4. 0 c 24 Min. : 68. 0 1 st Qu. : 111. 8 Median : 146. 5 Mean : 150. 1 3 rd Qu. : 189. 8 Max. : 260. 0 NA's : 5. 0 SPH 247 Statistical Analysis of Laboratory Data 2
> > > > af 1 <- alkfos[complete. cases(alkfos), ] afmat <- af 1[, -1] grp <- af 1$grp pca. af <- prcomp(afmat, scale=T) pca. tam <- prcomp(afmat[grp==2, ], scale=T) pca. placebo <- prcomp(afmat[grp==1, ], scale=T) plot(pca. af$x[, 1: 2], col=grp) plot(pca. af) May 7, 2010 SPH 247 Statistical Analysis of Laboratory Data 3
May 7, 2010 SPH 247 Statistical Analysis of Laboratory Data 4
May 7, 2010 SPH 247 Statistical Analysis of Laboratory Data 5
> library(MASS) > lda. af <- lda(afmat, grp) > lda. af Prior probabilities of groups: 1 2 0. 6 0. 4 Group means: c 0 c 3 c 6 c 9 c 12 c 18 c 24 1 156. 7143 161. 8571 173. 9048 158. 4286 163. 8571 164. 3333 163. 2857 2 164. 2143 125. 1429 123. 7143 118. 7143 117. 2857 130. 7857 134. 8571 Coefficients of linear discriminants: LD 1 c 0 0. 0618073455 c 3 -0. 0329471378 c 6 0. 0004421163 c 9 -0. 0232320119 c 12 -0. 0248954902 c 18 0. 0113410946 c 24 0. 0003473940 May 7, 2010 SPH 247 Statistical Analysis of Laboratory Data 6
> af. pred <- predict(lda. af) > table(af. pred$class, grp) grp 1 20 0 2 1 14 > plot(grp, af. pred$x) May 7, 2010 SPH 247 Statistical Analysis of Laboratory Data 7
May 7, 2010 SPH 247 Statistical Analysis of Laboratory Data 8
- Slides: 8