在R中为Poisson家族运行随机效果模型的麻烦
我试图在R中的泊松家族中运行一个简单的随机效应模型。我不明白这个错误,或者为什么会给我带来错误。我在其他一些数据集中尝试了同样的方法,并且发现了类似的错误。有什么可能会产生错误?
library(ggplot2)
library(lme4)
y.test <- c(3.09601,3.546579, 12.115740, 2.226694, 1.180938, 4.420249, 2.001162, 3.788012, 21.170732, 7.494421 , 5.602522 , 3.300510, 11.404264 ,23.115029,
19.371686, 25.444904, 17.094280 ,1.368615 ,19.343291 , 9.724363 , 8.086256 ,13.021972 ,10.740431 , 2.768960 ,14.494745 ,19.040086 , 7.072040, 8.748415,
10.012655, 14.759963 , 6.669221, 9.179184, 14.069743 ,12.132714, 8.517986, 18.095548, 9.076304, 9.197501, 7.972339 , 3.111373, 10.802117, 16.874861,
2.977454 ,15.195754, 5.433059 , 8.569472, 24.479745 , 3.756167 ,7.028482 , 7.412065 , 6.298529 , 3.585942 , 4.706638 , 9.00223)
x.test <- c(1:54)
random.effect <- rep(c("A","B","C"), each=18)
df.test <- data.frame(x.test, y.test, random.effect)
df.test$random.effect <- as.factor(df.test$random.effect)
df.test$y.test <- as.numeric(df.test$y.test)
df.test$x.test <- as.numeric(df.test$x.test)
mod <- glmer(y.test ~ x.test + I(x.test^2) + (1|random.effect), data = df.test, family = poisson)
summary(mod)
警告消息:1:在vcov.mermod(object,use.hessian = use.hessian):从有限差异的Hessian计算的方差 - 可达矩阵不是正确定的或包含NA值:倒回Var-Cov估计的估计来自RX
I am trying to run a simple random-effects model in a Poisson family in R. I don't understand the error, or why it's throwing me an error. I tried the same with a few other datasets, and I get a similar error. What could possibly be generating the error?
library(ggplot2)
library(lme4)
y.test <- c(3.09601,3.546579, 12.115740, 2.226694, 1.180938, 4.420249, 2.001162, 3.788012, 21.170732, 7.494421 , 5.602522 , 3.300510, 11.404264 ,23.115029,
19.371686, 25.444904, 17.094280 ,1.368615 ,19.343291 , 9.724363 , 8.086256 ,13.021972 ,10.740431 , 2.768960 ,14.494745 ,19.040086 , 7.072040, 8.748415,
10.012655, 14.759963 , 6.669221, 9.179184, 14.069743 ,12.132714, 8.517986, 18.095548, 9.076304, 9.197501, 7.972339 , 3.111373, 10.802117, 16.874861,
2.977454 ,15.195754, 5.433059 , 8.569472, 24.479745 , 3.756167 ,7.028482 , 7.412065 , 6.298529 , 3.585942 , 4.706638 , 9.00223)
x.test <- c(1:54)
random.effect <- rep(c("A","B","C"), each=18)
df.test <- data.frame(x.test, y.test, random.effect)
df.test$random.effect <- as.factor(df.test$random.effect)
df.test$y.test <- as.numeric(df.test$y.test)
df.test$x.test <- as.numeric(df.test$x.test)
mod <- glmer(y.test ~ x.test + I(x.test^2) + (1|random.effect), data = df.test, family = poisson)
summary(mod)
Warning messages: 1: In vcov.merMod(object, use.hessian = use.hessian) : variance-covariance matrix computed from finite-difference Hessian is not positive definite or contains NA values: falling back to var-cov estimated from RX
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论