lmerTest and lmer: Error message

2019-04-17 09:31发布

问题:

I have run lmerTest and lmer in R in the version 2013:

> library(lmerTest)
> data1.frame <- read.delim("colorness.txt", fileEncoding="UTF-16")
> str(data1.frame)
> lmer3 <- lmerTest::lmer(duration ~ (1|item) + (1+color|speaker) + group*color*sex, data=data1.frame, REML=FALSE, na.action=na.omit)

The lmer3 works fine for me. And when I checked the data in str(data1.frame), there is nothing wrong.

But when I put this command

> summary(lmer3)

It gives me this message:

Error in `colnames<-`(`*tmp*`, value = c("Estimate", "Std. Error", "df",  : 
  length of 'dimnames' [2] not equal to array extent

However, I am quite sure there is nothing wrong in my data as I can run lmer in R version 2009. Do you have any idea how to solve this issue? The thing is that if I stick with R version 2009, then I cannot get p-values from lmerTest, and I don't know how to get it from likelihood ratio test. Do you have any idea about this?

回答1:

sorry to post this as an answer, but I still do not have enough "reputation" to comment. I think it is a bug and/or depends on the data, because I have the same problem. I have a large dataset, and the model runs row-wise through it using a loop. Everything works perfectly for the first 26,478 tests (out of 34,713) but stops in the next cycle, with the same error. So:

1) it is not the version of the package, since it works perfectly for 3/4's of my dataset 2) it is not the sintax, since everything works fine in the first tens of thousands of models and an ANOVA I run previously against a null model.

My code is roughly:

for (i in 1:nrow(dataset)){
    dataframe<-as.data.frame(dataset[i,]);
    lm.R<-lmer(response ~ treatment + (1|ran)+(1|rep), dataframe, REML= FALSE);
    x<-summary(lm.R);
    p.val[i,]<-x$coefficients[,"Pr(>|t|)"];
}

and I get the same error when i = 26479

Model is not identifiable...
Error in `colnames<-`(`*tmp*`, value = c("Estimate", "Std. Error", "df",  : 
  length of 'dimnames' [2] not equal to array extent

My data is fine in that row (I doublechecked) and I cannot see any irregularity. Even the ANOVA against the null model (which I highly recommend you to do, since it gives you the p-value, loglike, AIB, etc. of your model) works perfectly.

lm.null<-lmer(response ~ 1 + (1|ran)+(1|rep), dataframe, REML= FALSE);
lm.R<-lmer(response ~ treatment + (1|ran)+(1|rep), dataframe, REML= FALSE);
anova(lm.null,lm.R);


标签: r lmer