lme4升级会产生错误消息`[[<-.data.frame`(`* tmp *`,i,value = integer(0))错误 [英] lme4 upgrade produces error message Error in `[[<-.data.frame`(`*tmp*`, i, value = integer(0))

查看:2401
本文介绍了lme4升级会产生错误消息`[[<-.data.frame`(`* tmp *`,i,value = integer(0))错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上周用lmer(lme4)构建了一个广义混合线性模型,效果很好:

I have constructed a generalized mixed linear model with lmer (lme4) last week which worked fine:

fit<-lmer(dat$presence~log(dat$SIZE_strict)*dat$Troph_level+log(dat$HAB500EXCL_strict+1)+(1|dat$dataset), family=poisson, REML=FALSE)

但是,更新lme4软件包后,该模型不再起作用,并显示错误消息:

After updating the lme4 package however, the model no longer worked, giving the error message:

Error in `[[<-.data.frame`(`*tmp*`, i, value = integer(0)) : 
  replacement has 0 rows, data has 174
In addition: Warning messages:
1: In lmer(dat$presence ~ log(dat$SIZE_strict) * dat$Troph_level +  :
  calling lmer with 'family' is deprecated; please use glmer() instead
2: In checkArgs("glmer", REML = FALSE) :
  extra argument(s) ‘REML’ disregarded

使用glmer代替lmer不能解决第一条错误消息.任何建议将不胜感激!

Using glmer instead of lmer did not solve the first error message. Any suggestions would be very much appreciated!

以下是一些数据(称为dat):

Here are some of the data (called dat):

Troph_level presence    dataset SIZE_strict HAB500EXCL_strict
carnivorous 2   1   46155   26005
carnivorous larvae  0   1   46155   26005
phytophagous    2   1   46155   26005
phytophagous    0   3   195295  360882
carnivorous 0   3   195295  360882
carnivorous larvae  0   3   195295  360882
phytophagous    4   2   18272   21169
carnivorous larvae  0   2   18272   21169
carnivorous 1   2   18272   21169
carnivorous 1   2   24964   26745
carnivorous larvae  0   2   24964   26745
phytophagous    4   2   24964   26745
phytophagous    5   2   6220    12543
carnivorous larvae  0   2   6220    12543
carnivorous 1   2   6220    12543
phytophagous    0   3   102633  12198
carnivorous larvae  0   3   102633  12198
carnivorous 0   3   102633  12198
phytophagous    0   3   2092    291439
carnivorous larvae  1   3   2092    291439
carnivorous 0   3   2092    291439
phytophagous    3   5   80410   0

非常感谢! Toos van Noordwijk

Many thanks in advance! Toos van Noordwijk

推荐答案

这是新版本的lme4中的一个buglet(将在即将发布的补丁程序版本中修复),要求在数据框中可以找到分组变量由data参数指定.通常,如果使用data参数并使用dat$var形式的变量避开,则事情会更流畅(并且代码更易于阅读),例如:

This is a buglet in the new version of lme4 (to be fixed in an upcoming patch release) that requires grouping variables to be findable within the data frame specified by the data argument. In general things will work more smoothly (and your code will be easier to read) if you use the data argument and eschew using variables of the form dat$var, for example:

fit <- glmer(presence~log(SIZE_strict)*Troph_level+log(HAB500EXCL_strict+1)+
  (1|dataset), family=poisson, data=dat)

这篇关于lme4升级会产生错误消息`[[&lt;-.data.frame`(`* tmp *`,i,value = integer(0))错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆