## paired t-test y1<-c(6,4,6,7,5,6,8,7,8,3,9,4,8,11,12,6,10,3,5,4,6,7,5,6,3,10,5,4,4,7) y2<-c(4,7,12,10,2,11,9,5,11,8,7,6,8,9,9,8,10,9,8,5,8,7,6,9,3,5,11,7,3,10) ##table 5.1, Imipramine(y1) vs. placebo(y2) to treat depression ## response: depression score. the higher the score, the more severe the dep. > mean(y1) [1] 6.3 > sqrt(var(y1)) [1] 2.394678 > mean(y2) [1] 7.566667 > sqrt(var(y2)) [1] 2.595531 > mean(y1-y2) [1] -1.266667 > sqrt(var(y1-y2)) [1] 2.923547 > t.test(y1,y2,paired = T) Paired t-test data: y1 and y2 t = -2.3731, df = 29, p-value = 0.02449 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -2.3583370 -0.1749963 sample estimates: mean of the differences -1.266667 ## RBD, class example conf<-c(1,2,7,6,12, 5,8,9,13,14, 8,14,16,18,17) block<-rep(1:5,3) method<-rep(1:3, c(5,5,5)) fit<-lm(conf~factor(method)+factor(block)) > anova(fit) Analysis of Variance Table Response: conf Terms added sequentially (first to last) Df Sum of Sq Mean Sq F Value Pr(F) factor(method) 2 202.8000 101.4000 33.98883 0.000122918 factor(block) 4 171.3333 42.8333 14.35754 0.001008124 Residuals 8 23.8667 2.9833