R version 3.1.0 (2014-04-10)
lmer package version 1.1-6
lmerTest package version 2.0-6我目前正在与lmer和lmerTest合作进行我的分析。每次向随机结构添加效果时,运行汇总()时都会出现以下错误:
#Fitting a mixed model:
TRT5ToVerb.lmer3 = lmer(TRT5ToVerb ~ Group + Condition + (1+Condition|Participant) + (1|Trial), data=AllData, REML=FALSE, na.action=na.omit)
summary(TRT5ToVerb.lmer3)
Error in `colnames<-`(`*tmp*`, value = c("Estimate", "Std. Error", "df", : length of 'dimnames' [2] not equal to array extent如果我这样离开这个结构:
TRT5ToVerb.lmer2 = lmer(TRT5ToVerb ~ Group + Condition + (1|Participant) + (1|Trial), data=AllData, REML=FALSE, na.action=na.omit)没有误差运行总结(TRT5ToVerb.lmer2)、返回AIC、BIC、logLik偏差、随机效应估计、固定效应估计及其对应p-值等。
因此,显然在我运行lmerTest时发生了一些事情,尽管存在对象TRT5ToVerb.lmer3。这两种结构之间唯一的区别是随机结构:(1+Condition|Participant)和(1\x参与者)
我的数据的一些特点:
我读过this threat,但找不到清晰的解决方案。难道我必须把我的数据转换成长格式吗?如果是这样的话,那我该如何处理这个问题呢?我希望不是这样。
谢谢!
免责声明:我既不是R方面的专家,也不是统计学方面的专家,所以请耐心点。
发布于 2014-07-14 15:06:29
(应该是注释,但是太长/代码格式等)
这个假示例似乎适用于lmerTest 2.0-6和lme4的开发版本(1.1-8;但我不认为这个示例与1.1-6有任何相关的区别.)
AllData <- expand.grid(Condition=factor(1:3),Group=factor(1:2),
Participant=1:28,Trial=1:8)
form <- TRT5ToVerb ~ Group + Condition + (1+Condition|Participant) + (1|Trial)
library(lme4)
set.seed(101)
AllData$TRT5ToVerb <- simulate(form[-2],
newdata=AllData,
family=gaussian,
newparam=list(theta=rep(1,7),sigma=1,beta=rep(0,4)))[[1]]
library(lmerTest)
lmer3 <- lmer(form,data=AllData,REML=FALSE)
summary(lmer3)生产:
Linear mixed model fit by maximum likelihood ['merModLmerTest']
Formula: TRT5ToVerb ~ Group + Condition + (1 + Condition | Participant) +
(1 | Trial)
Data: AllData
AIC BIC logLik deviance df.resid
4073.6 4136.0 -2024.8 4049.6 1332
Scaled residuals:
Min 1Q Median 3Q Max
-2.97773 -0.65923 0.02319 0.66454 2.98854
Random effects:
Groups Name Variance Std.Dev. Corr
Participant (Intercept) 0.8546 0.9245
Condition2 1.3596 1.1660 0.58
Condition3 3.3558 1.8319 0.44 0.82
Trial (Intercept) 0.9978 0.9989
Residual 0.9662 0.9829
Number of obs: 1344, groups: Participant, 28; Trial, 8
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 0.49867 0.39764 12.40000 1.254 0.233
Group2 0.03002 0.05362 1252.90000 0.560 0.576
Condition2 -0.03777 0.22994 28.00000 -0.164 0.871
Condition3 -0.27796 0.35237 28.00000 -0.789 0.437
Correlation of Fixed Effects:
(Intr) Group2 Cndtn2
Group2 -0.067
Condition2 0.220 0.000
Condition3 0.172 0.000 0.794https://stackoverflow.com/questions/24738391
复制相似问题