TukeyHSD的具体条件

时间:2016-05-04 08:59:39

标签: r statistics anova posthoc

我试图让一个TukeyHSD在R中运行,我的代码如下:

#----------------------------------------------------------------------------------------#
# RING data:
#----------------------------------------------------------------------------------------#
library(doBy)
# Set working directory
setwd("")

#### Read data & Converting factors ####
dat <- read.table("afstand.txt", header =TRUE)  
str(dat)
dat$Vial <- as.factor(dat$Vial)
dat$Line <- as.factor(dat$Line)
dat$Fly <- as.factor(dat$Fly)  
dat$Temp <- as.factor(dat$Temp)
str(dat)

datSUM <- summaryBy(X0.5_sec+X1_sec+X1.5_sec+X2_sec+X2.5_sec+X3_sec~Vial_nr+Concentration+Sex+Line+Vial+Temp,data=dat, FUN=sum)
fl<-levels(datSUM$Line)
aov1 <- aov(X0.5_sec.sum ~ Concentration*Sex*Line*Temp, data=datSUM)
summary(aov1) #Overview of model 
TukeyHSD(aov1, 'Line',ordered = TRUE, conf.level = 0.95)

我想要做的是查看Line和Temp之间的交互,例如,如果我运行TukeyHSD(aov1),那么我得到所有的交互,导致此错误:[ reached getOption("max.print") -- omitted 3716 rows ]有没有办法我可以指定我只想在Line和Temp之间进行测试而不是所有组合,或者如果我只运行TukeyHSD(avo1),只显示重要结果的方法? 我尝试过使用TukeyHSD(aov1, 'Line,Temp',ordered = TRUE, conf.level = 0.95)TukeyHSD(aov1, 'Line':'Temp',ordered = TRUE, conf.level = 0.95)TukeyHSD(aov1, 'Line'&'Temp',ordered = TRUE, conf.level = 0.95),但没有运气。

structure(list(Concentration = structure(c(2L, 7L, 7L, 1L, 7L, 
1L, 2L, 1L, 7L, 1L, 4L, 2L, 2L, 1L, 2L, 4L, 7L, 2L, 2L, 1L), .Label = c("a", 
"b", "c", "d", "e", "x", "y"), class = "factor"), Sex = structure(c(1L, 
2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 
1L, 2L, 1L), .Label = c("f", "m"), class = "factor"), Line = structure(c(3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 2L, 3L, 
3L, 3L, 3L), .Label = c("20", "23", "40", "73"), class = "factor"), 
    Temp = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 1L), .Label = c("23", 
    "29"), class = "factor"), X0.5_sec.sum = c(107.19, 46.17, 
    58.05, 75.87, 87.75, 71.55, 46.17, 47.25, 22.41, 31.05, 27.36, 
    79.11, 87.58, 21.33, 34.29, 60.4, 85.05, 72.47, 114.21, 67.77
    )), .Names = c("Concentration", "Sex", "Line", "Temp", "X0.5_sec.sum"
), row.names = c(NA, 20L), class = "data.frame")

1 个答案:

答案 0 :(得分:1)

要仅显示变量LineTemp之间的互动,您可以按如下方式指定参数which

which = 'Line:Temp'

然后将您的完整函数调用转换为TukeyHSD

TukeyHSD(aov1, 'Line:Temp', ordered = TRUE, conf.level = 0.95)