将 sim() 与 lmer() 一起使用
我使用相同的预测变量运行了两个多级逻辑回归,但有两个不同的响应:
fruitMLM <- lmer(InsuffFruit ~ Income + HDI + Income:HDI + (1 + Income | Country),family=binomial(link="logit"))
fuelMLM <- lmer(Pollution ~ Income + HDI + Income:HDI + (1 + Income | Country),family=binomial(link="logit"))
Income
是离散的,其值为 c(-2,-1,0,1,2)
,HDI
在 0 和 1 之间连续,Country
是分类的,响应均为 1/0。
为了绘制置信带,我使用arm包中的sim()函数运行模拟:
sim(fruitMLM,100)
sim(fuelMLM,100)
第一个计算得很好。第二个返回以下错误:
Error in mvnorm(n.sims, bhat[j,], V.beta) :
'Sigma' is not positive definite
我实际上是用 8 个不同的响应来执行此操作。其中六个工作正常,其中两个返回了此错误。
有谁知道如何纠正这个问题?
I have run two multilevel logistic regressions using the same predictors, but on two different responses:
fruitMLM <- lmer(InsuffFruit ~ Income + HDI + Income:HDI + (1 + Income | Country),family=binomial(link="logit"))
fuelMLM <- lmer(Pollution ~ Income + HDI + Income:HDI + (1 + Income | Country),family=binomial(link="logit"))
Income
is discrete with values c(-2,-1,0,1,2)
, HDI
is continuous between 0 and 1, Country
is categorical, and the responses are both 1/0.
To plot confidence bands I run a simulation using the sim() function from the arm package:
sim(fruitMLM,100)
sim(fuelMLM,100)
The first one computes fine. The second one returns the following error:
Error in mvnorm(n.sims, bhat[j,], V.beta) :
'Sigma' is not positive definite
I actually am doing this with 8 different responses. Six of them worked fine and two of them returned this error.
Does anyone know how to rectify this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能看到错误消息是否正确,即“手动”检查失败模型的协方差矩阵是否实际上是正半定的?我不确定,但我想您可以执行一些检查 - 也许这里有一些东西: http://en.wikipedia.org/wiki/Positive-definite_matrix
Can you see if the error message is correct, i.e., check "by hand" whether the covariance matrix from the failing model is actually positive semi-definite? I'm not sure, but I imagine there are some checks you could perform - maybe there's something here: http://en.wikipedia.org/wiki/Positive-definite_matrix