无法在互动中执行Tukey的HSD测试

时间:2019-06-17 21:23:33

标签: r tukey

我与人之间有很重要的互动,并希望对此进行Tukey的HSD测试,但是,我在网上找到的示例似乎并不适合我。

我的数据:

>dput(head(dataAvgSucCI))
structure(list(Collection = c(1L, 1L, 1L, 1L, 1L, 2L), Irrigation = 
structure(c(1L,2L, 3L, 4L, 5L, 1L), .Label = c("Rate1", "Rate2", "Rate3", "Rate4", 
"Rate5"), class = "factor"), meanSuc = c(0.585416666666667, 0.5032, 
0.61375, 0.602775, 0.688466666666667, 0.545133333333333), ab = 
structure(c(1L, 3L, 5L, 7L, 9L, 2L), .Label = c("1.Rate1", "2.Rate1", "1.Rate2", 
"2.Rate2", "1.Rate3", "2.Rate3", "1.Rate4", "2.Rate4", "1.Rate5", 
"2.Rate5"), class = "factor")), row.names = c(NA, -6L), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"), vars = "Collection", drop = TRUE, indices 
= list(0:4, 5L), group_sizes = c(5L, 1L), biggest_group_size = 5L, labels = 
structure(list(Collection = 1:2), row.names = c(NA, -2L), class = "data.frame", 
vars = "Collection", drop = TRUE)

我正在尝试做的事情:

require(multcomp) 
intSucCI <- with(dataAvgSucCI, interaction(Collection, Irrigation)) 
sucCIHSD.aov <- aov(meanSuc ~ Collection*Irrigation, data=dataAvgSucCI) 
summary(sucCIHSD.aov) 
sucCIHSD.glht <- glht(sucCIHSD.aov, linfct = mcp(intSucCI = "Tukey"))

错误代码,出现在先前代码的最后一行:

  

mcp2matrix(model,linfct = linfct)中的错误:         在“ linfct”中指定了变量“ intSucCI”,但在“模型”中找不到!

任何帮助将不胜感激。谢谢!

2 个答案:

答案 0 :(得分:0)

您知道图书馆TukeyC吗?

library(TukeyC)
data(FE)

dad = FE$dfm

mod = aov(y ~ blk + N*P*K, dad)

#Studing K within N0 and P0.
tk = TukeyC(mod, which = 'N:P:K', fl1 = 1, fl2 = 1)
summary(tk)
plot(tk)

See help(TukeyC) to more details!




答案 1 :(得分:0)

这是您要找的吗?

intSucCI <- with(dataAvgSucCI, interaction(Collection, Irrigation))
sucCIHSD.aov <- aov(meanSuc ~ intSucCI, data = dataAvgSucCI)
summary(sucCIHSD.aov)
sucCIHSD.glht <- glht(sucCIHSD.aov, linfct = mcp(intSucCI = "Tukey"))