lmerTest ::: anova使用数据集的延迟加载? [英] lmerTest:::anova uses lazy loading of data sets?

查看:141
本文介绍了lmerTest ::: anova使用数据集的延迟加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试获得K-R自由度的经验分布时遇到了这个问题...

Ran into this problem while trying to get the empirical distribution of the K-R degrees of freedom...

这似乎是相当危险的行为?它构成一个错误吗?

This seems like fairly dangerous behaviour? Does it constitute a bug?

可复制的示例:

## import lmerTest package
library(lmerTest)

## an object of class merModLmerTest
m <- lmer(Informed.liking ~ Gender+Information+Product +(1|Consumer), data=ham)

# simulate data from fitted model
simData=ham
simData$Informed.liking=unlist(simulate(m))
# fit model to simulated data
m1 <- lmer(Informed.liking ~ Gender+Information+Product +(1|Consumer), data=simData)
stats:::anova(m1)
lmerTest:::anova(m1)

# simulate again, WITHOUT refitting
simData$Informed.liking=unlist(simulate(m))
stats:::anova(m1) # same as before
lmerTest:::anova(m1) # not same as before!

推荐答案

我的回答并不构成可靠的答案,而是一个扩展的注释:
这看起来很糟糕-实际上,我今天发现,由于lmerTest的相关行为,我在濒临提交的项目中进行的几乎所有分析都必须重做. 我遇到的问题是当我使用适合lmer模型的简短函数,然后返回coef(summary(model))时-简单的东西,两行代码.但是,此函数的输入名为data,我在工作区中也有一个名为data的数据框.看起来,尽管在与lmer拟合期间正确使用了函数作用域中的局部变量,但在summary期间却使用了工作区data变量(通常与传递给函数的数据帧不同)导致无效的t值和自由度导致不正确的p值(但是,估计值和标准误差是可以的).
因此,回答您的问题:

my response does not constitute a solid answer, rather an extended comment:
this looks pretty bad - in fact I have discovered today that almost all the analyses that I conducted in a project that was on the verge of submission have to be redone because of a related behavior of lmerTest.
The problem I have run into was when I used a short function that fits a model with lmer and then returns coef(summary(model)) - simple stuff, two lines of code. However the input to this function was named data and I also had a dataframe called data in the workspace. It seems that although during fitting with lmer the local variable from the function scope was correctly used, during summary the workspace data variable was used (which often was not the same as the dataframe passed to the function) leading to invalid t values and degrees of freedom leading to incorrect p values (the estimates and their standard error was ok however).
So, answering your question:

这似乎是相当危险的行为?它构成一个错误吗?

This seems like fairly dangerous behaviour? Does it constitute a bug?

这确实看起来很危险,我肯定会将此称为错误.

It seems dangerous indeed and I would definitelly call this a bug.

这篇关于lmerTest ::: anova使用数据集的延迟加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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