为什么 log() 语句会导致 lmList 失败?
在解决这个问题时:lme4和nlme包之间的干扰OP和我确定将响应向量包装在对 lme4::lmList
的调用内的 log()
中会导致 lmList
失败。
例如,
my.lmList.model <- lmList( log(response) ~ log(predictor) | group, mydata)
给出响应
Error in eval(expr, envir, enclos) : object 'response' not found
,但如果您首先记录响应和预测器,它就可以正常工作,即,
mydata$log.response <- log(mydata$response)
mydata$log.predictor <- log(mydata$predictor)
my.new.lmList.model <- lmList( log.response. ~ log.predictor | group, mydata)
有人可以解释为什么在第一个示例中将响应包装在 log() 中不起作用吗?在我看来(至少直觉上)应该如此。
In working through this question: Interference between lme4 and nlme packages the OP and I determined that wrapping the response vector in log()
inside a call to lme4::lmList
causes lmList
to fail.
e.g.,
my.lmList.model <- lmList( log(response) ~ log(predictor) | group, mydata)
gives the response
Error in eval(expr, envir, enclos) : object 'response' not found
but if you first log the response and predictor it works fine, i.e.,
mydata$log.response <- log(mydata$response)
mydata$log.predictor <- log(mydata$predictor)
my.new.lmList.model <- lmList( log.response. ~ log.predictor | group, mydata)
Can someone explain why wrapping the response in log() in the first example doesn't work? It seems to me (at least intuitively) that it should.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定你想要什么答案。 “为什么”是因为 lmList 就是这样设计的。您已经知道解决方法。您想知道如何重写 lmList 以使其在这种情况下不会失败吗?这不是一个简单的函数。最好在仔细阅读文档并查看函数以查看这是否是故意行为后编写包作者。
I'm not sure what answer you want. The "why" is because that's how lmList is designed to function. You already know the workaround. Do you want to know how to rewrite lmList to have it not fail in such conditions? It's not a simple function. It might be best to write the package authors after carefully reading the documentation and looking through the function to see if this is intentional behaviour.