pairwise.t.test is returning NAs when one of the samples only has one entry, while TukeyHSD returns results (maybe not trustworthy or believable, but results). I stumbled on this because I did not realize one of my samples only had one entry while most of the others had several hundred, so I realize this is not a desirable situation. I'm really just curious about the difference between how pairwise.t.test and TukeyHSD handle this situation, and if this is the desired result. As an aside, should, in cases like this, pairwise.t.test return an error or warning indicating what might be the cause for the NA's being returned? Also, should TukeyHSD similarly return a warning about this situation? Thanks again for any insights and feedback. length_1<-1 mean_1<-0.0 sd_1<-0.0 distribution_1<-rnorm(length_1, mean=mean_1, sd=sd_1) length_2<-750 mean_2<-0.5 sd_2<-0.0 distribution_2<-rnorm(length_2, mean=mean_2, sd=sd_2) length_3<-850 mean_3<-0.1 sd_3<-0.65 distribution_3<-rnorm(length_3, mean=mean_3, sd=sd_3) length_4<-850 mean_4<-0.0 sd_4<-0.65 distribution_4<-rnorm(length_4, mean=mean_4, sd=sd_4) columns_A<-data.frame(type=c("A"), vals=distribution_1) columns_B<-data.frame(type=c("B"), vals=distribution_2) columns_C<-data.frame(type=c("C"), vals=distribution_3) columns_D<-data.frame(type=c("D"), vals=distribution_4) combined_columns<-rbind(columns_A, columns_B) combined_columns<-rbind(combined_columns, columns_C) combined_columns<-rbind(combined_columns, columns_D) boxplot(combined_columns$vals ~ combined_columns$type) a2 <- aov(combined_columns$vals ~ combined_columns$type) summary(a2) TukeyHSD(a2) pairwise.t.test(combined_columns$vals, combined_columns$type, p.adj = "none")
Walmes Zeviani
2010-Mar-25 03:03 UTC
[R] Expected pairwise.student.t and TukeyHSD behavior?
This is because pairwise.student.t and TukeyHSD use differents estimates for error term. TukeyHSD use the parameters covariance matrix and t use sample variance. In this case a treatment with only one value doesn't have sample variance but has a estimated standard error in a covariance matrix. The lines below will illustrate the point: # toy data da <- data.frame(A=factor(rep(c("a","b","c"), c(1,5,7)))) da$y <- rnorm(da$A) # sample variance tapply(da$y, da$A, var) pairwise.t.test(da$y, da$A, p.adj="none") # problem! # model and covariance matriz m0 <- aov(y~A, da) vcov(m0) TukeyHSD(m0) # no problem! Walmes. ----- ..ooo0 ................................................................................................... ..(....)... 0ooo... Walmes Zeviani ...\..(.....(.....)... Master in Statistics and Agricultural Experimentation ....\_)..... )../.... walmeszeviani at hotmail.com, Lavras - MG, Brasil ............ (_/............................................................................................ -- View this message in context: http://n4.nabble.com/Expected-pairwise-student-t-and-TukeyHSD-behavior-tp1690100p1690136.html Sent from the R help mailing list archive at Nabble.com.