[R] Expected pairwise.student.t and TukeyHSD behavior?

Jason Rupert jasonkrupert at yahoo.com
Thu Mar 25 03:10:28 CET 2010


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")



More information about the R-help mailing list