# Unit 5 for R # 030521 prepared by C. Andy Tsao # Concept: Comparing two treatment # cf. Chapter 10 of Johnson and Bhattacharyya x<-c(44,44,56,46,47,38,58,53,49,35,46,30) y<-c(35,47,55,29,40,39,32,41,42,57,51,39) # Pre-prelim analysis??? Design and Sampling plan? # Don't just dump the data into the statware. # Reminder: Garbage in, garbage out # Prelim analysis stem(x);stem(y); summary(x);summary(y); boxplot(x,y) # Variuos t-tests t.test(x,y) t.test(x, y, alternative = c("two.sided"), mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95) t.test(x, y, alternative = c("two.sided"), mu = 0, paired = FALSE, var.equal = TRUE, conf.level = 0.95) t.test(x, y, alternative = c("two.sided"), mu = 0, paired = TRUE, var.equal = TRUE, conf.level = 0.90) # Example : on page 425 fwa<-c(44,44,56,46,47,38,58,53,49,35,46,30,41) dwa<-c(35,47,55,29,40,39,32,41,42,57,51,39) summary(fwa);summary(dwa); boxplot(fwa,dwa) t.test(fwa,dwa, var.equal = TRUE) # clear up rm(list=ls(all=TRUE)) # 10.31 on page 438 using R c1<-c(5,2,8,3);c2<-c(8,9,6); t.test(c1,c2) t.test(c1,c2,var.equal=TRUE) # 10.48 on page 452 (also Example 12 on page 445) # Switch working dir to where data C10T2.dat is located t<-matrix(scan("C10T2.dat"),ncol=2,byrow=T) t x<-t[,1];y<-t[,2]; x y d<-x-y t.test(d) t.test(x,y,pair=TRUE) t.test(x,y)