r-mcp2matrix(model,linfct=linfct)中的错误:类"integer"的变



我不明白为什么它不工作这里是我的代码:

library(lme4,multcomp)
tijd <- c(7.667, 9.5, 6.467, 10.033, 9.767, 29.133, 15.933, 8.1, 8.6, 
12.3, 5.867, 13.667, 12.933, 11.933, 27.2, 11.567, 10.9, 12.567, 
9.033, 12.6, 13.133, 17.067, 14.333, 15.2, 9.1, 9.167, 8.4, 11.4, 
18.467, 15.633, 10.4, 10.767, 12.7, 7.667, 9.867, 36.167, 20.4, 
33.8, 15.767, 20.1, 10.533, 17.7, 62.667, 21.133, 40.133, 9.2, 
19.467, 7.667, 8.867, 20.333, 14.367, 10.167, 28.4, 11.367, 10.867, 
22.1, 24.8, 13.3, 17.067, 10.967, 12.333, 28.867, 21.1)
week <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3)
Methode <- c(1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 
4, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 
1, 1, 2, 2, 3, 3, 4, 1, 1, 2, 2, 3, 3, 4, 1, 1, 
2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3)
freq <- c(c(5.9, 5.9, 5.9, 5.9, 5.9, 5.9, 5.9, 5.9, 8, 8, 8, 8, 8, 8, 8, 
8, 10, 10, 10, 10, 10, 10, 10, 10, 5.9, 5.9, 5.9, 5.9, 5.9, 5.9, 
5.9, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 5.9, 5.9, 
5.9, 5.9, 5.9, 5.9, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10))
ID <-c(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 
8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 8, 
1, 2, 3, 4, 5, 6, 8, 1, 2, 3, 4, 5, 6, 8, 1, 2, 
3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6)
week <- as.factor(week)
Methode <- as.factor(Methode)
ID <- as.factor(ID)

M1 <- lmer(log(tijd) ~ Methode + (1|freq) + (1|week) + (1|ID), data = data)
summary(M1)
anova(M1, type = "III", test = "F")
plot(M1)
plot(cooks.distance(M1))

summary(glht(M1, linfct = mcp(Methode = "Tukey")))

以下是我的数据集的第一行:https://i.stack.imgur.com/dyXLb.jpg我目前正在写我的学士论文,如果你能帮助我,那将是非常好的。

提前感谢:(

在您的lmer代码中,您依赖data,但您没有将data$Methode转换为factor,那么您的代码应该是:

data$week <- as.factor(data$week)
data$Methode <- as.factor(data$Methode)
data$ID <- as.factor(data$ID)
M1 <- lmer(log(tijd) ~ Methode + (1|freq) + (1|week) + (1|ID), data = data)

您在图像中显示的数据不包含与lmer代码相同的列名,因此您必须注意(例如:frequencie和freq(

相关内容

  • 没有找到相关文章

最新更新