R进行多重t检验

           X A
1  0.2156628 1
2  0.2871022 1
3  0.2641319 1
4  0.1095140 2
5  0.1736879 2
6  0.1380919 2
7  0.1269411 3
8  0.1647899 3
9  0.1551072 3
10 0.1370872 4
11 0.1603417 4
12 0.1621285 4


#anova.tab.R

anova.tab<-function(fm){

   tab<-summary(fm)
   k<-length(tab[[1]])-2
   temp<-c(sum(tab[[1]][,1]), sum(tab[[1]][,2]), rep(NA,k))
   tab[[1]]["Total",]<-temp
   tab

}


mouse <- data.frame(X=c(0.215662772,0.287102173,0.264131874,0.109513986,0.173687902,0.138091882,0.126941056,0.164789873,0.155107218,0.137087212,0.160341682,0.162128451),A=factor(c(rep(1,3),rep(2,3),rep(3,3),rep(4,3))))


#anova

mouse.aov<-aov(X ~ A, data=mouse)
source("anova.tab.R"); anova.tab(mouse.aov)

#多重t检验

attach(mouse)

mu<-c(mean(X[A==1]), mean(X[A==2]), mean(X[A==3]), mean(X[A==4])); mu

pairwise.t.test(X, A, p.adjust.method = "none")


你可能感兴趣的:(R)