1 / 16

ANOVA Homework Solutions

ANOVA Homework Solutions. EPP 245/298 Statistical Analysis of Laboratory Data. Exercise 6.1. > library(ISwR) Loading required package: survival Loading required package: splines > data(zelazo) > zelazo $active [1] 9.00 9.50 9.75 10.00 13.00 9.50 $passive

Download Presentation

ANOVA Homework Solutions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ANOVA Homework Solutions EPP 245/298 Statistical Analysis of Laboratory Data

  2. Exercise 6.1 > library(ISwR) Loading required package: survival Loading required package: splines > data(zelazo) > zelazo $active [1] 9.00 9.50 9.75 10.00 13.00 9.50 $passive [1] 11.00 10.00 10.00 11.75 10.50 15.00 $none [1] 11.50 12.00 9.00 11.50 13.25 13.00 $ctr.8w [1] 13.25 11.50 12.00 13.50 11.50 EPP 245 Statistical Analysis of Laboratory Data

  3. > age.walk <- c(zelazo$active,zelazo$passive,zelazo$none,zelazo$ctr.8w) > group <- rep(c("active","passive","none","ctr.8w"),c(6,6,6,5)) > group <- as.factor(group) > group [1] active active active active active active passive passive passive [10] passive passive passive none none none none none none [19] ctr.8w ctr.8w ctr.8w ctr.8w ctr.8w Levels: active ctr.8w none passive > anova(lm(age.walk ~ group)) Analysis of Variance Table Response: age.walk Df Sum Sq Mean Sq F value Pr(>F) group 3 14.778 4.926 2.1422 0.1285 Residuals 19 43.690 2.299> plot(age.walk ~ group) EPP 245 Statistical Analysis of Laboratory Data

  4. EPP 245 Statistical Analysis of Laboratory Data

  5. > mgroup <- rep(c("active","passive","none"),c(6,6,11)) > mgroup <- as.factor(mgroup) > anova(lm(age.walk ~ mgroup)) Analysis of Variance Table Response: age.walk Df Sum Sq Mean Sq F value Pr(>F) mgroup 2 13.655 6.827 3.0471 0.06996 . Residuals 20 44.812 2.241 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > t.test(zelazo$active,c(zelazo$none,zelazo$ctr.8w)) Welch Two Sample t-test data: zelazo$active and c(zelazo$none, zelazo$ctr.8w) t = -2.6574, df = 9.327, p-value = 0.02539 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -3.4626053 -0.2873947 sample estimates: mean of x mean of y 10.125 12.000 EPP 245 Statistical Analysis of Laboratory Data

  6. Exercise 6.2 • Lung data set has columns • volume = measured lung volume • method = method of measurement • subject = subject • Compare the methods. Are they different? Which ones differ? EPP 245 Statistical Analysis of Laboratory Data

  7. > attach(lung) > lm(volume ~ method + subject) Call: lm(formula = volume ~ method + subject) Coefficients: (Intercept) methodB methodC subject2 subject3 subject4 3.17222 0.28333 0.60000 -0.83333 0.10000 -0.06667 subject5 subject6 -0.03333 -0.60000 > lung.lm <- lm(volume ~ method + subject) > anova(lung.lm) Analysis of Variance Table Response: volume Df Sum Sq Mean Sq F value Pr(>F) method 2 1.08111 0.54056 6.4953 0.01557 * subject 5 2.18278 0.43656 5.2457 0.01271 * Residuals 10 0.83222 0.08322 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 EPP 245 Statistical Analysis of Laboratory Data

  8. > tapply(volume,method,mean) A B C 2.933333 3.216667 3.533333 > tapply(volume,subject,mean) 1 2 3 4 5 6 3.466667 2.633333 3.566667 3.400000 3.433333 2.866667 > diff(sort(tapply(volume,method,mean))) B C 0.2833333 0.3166667 > plot(volume ~ method) > plot(lung.lm) Hit <Return> to see next plot: Hit <Return> to see next plot: Hit <Return> to see next plot: Hit <Return> to see next plot: > help(plot.lm) > plot(lung.lm$resid ~ method) EPP 245 Statistical Analysis of Laboratory Data

  9. EPP 245 Statistical Analysis of Laboratory Data

  10. EPP 245 Statistical Analysis of Laboratory Data

  11. EPP 245 Statistical Analysis of Laboratory Data

  12. EPP 245 Statistical Analysis of Laboratory Data

  13. EPP 245 Statistical Analysis of Laboratory Data

  14. EPP 245 Statistical Analysis of Laboratory Data

  15. EPP 245 Statistical Analysis of Laboratory Data

  16. > anova(lung.lm) Analysis of Variance Table Response: volume Df Sum Sq Mean Sq F value Pr(>F) method 2 1.08111 0.54056 6.4953 0.01557 * subject 5 2.18278 0.43656 5.2457 0.01271 * Residuals 10 0.83222 0.08322 > diff(sort(tapply(volume,method,mean))) B C 0.2833333 0.3166667 EPP 245 Statistical Analysis of Laboratory Data

More Related