我正在尝试使用 pbkrtest 包中的函数 PBmodcomp 对两个 lmer 模型进行模型比较。但是我收到以下错误。
Error in `[<-.data.frame`(`*tmp*`, , rcol, value = c(0.318337014579985, :
replacement has 4080 rows, data has 4458
我的数据在这里可用:https ://www.dropbox.com/s/oweyw767qtpbqot/Data.txt
head(dat)
Subject time age cognition gender
60002.1 60002 1 0.4898039 -0.6915897 2
60002.2 60002 2 4.4898039 -0.8999999 2
60002.3 60002 3 8.4898039 -1.1619855 2
60008.1 60008 1 2.4898039 -0.2106083 2
60008.2 60008 2 6.4898039 0.3355440 2
60008.3 60008 3 10.4898039 -0.7309111 2
我正在运行的代码是
library(lme4)
library(pbkrtest)
m2 <- lmer(cognition ~ age + (age | Subject), data = dat, REML = FALSE, na.action = na.omit, control = lmerControl(optimizer = "Nelder_Mead"))
m3 <- lmer(cognition ~ age + gender + (age | Subject), data = dat, REML = FALSE, na.action = na.omit, control = lmerControl(optimizer = "Nelder_Mead"))
pb <- PBmodcomp(m3, m2)
我该如何解决这个问题?
谢谢