零膨胀负二项式分布函数 NaN 警告
Zero-inflated negative binomial distribution function NaN warning
我正在尝试将我的数据拟合到一个零膨胀的负二项式模型,但是当 SE 为在汇总函数中计算。我还尝试了 运行 负二项式障碍模型并且 运行 遇到了类似的问题。
str(eggTreat)
'data.frame': 455 obs. of 4 variables:
$ Exposure : Factor w/ 2 levels "C","E": 2 2 2 2 2 2 2 2 2 2 ...
$ hi_lo : Factor w/ 2 levels "hi","lo": 2 2 2 2 2 2 2 2 2 2 ...
$ Egg_count: int 0 0 0 0 0 0 0 0 0 0 ...
$ Food : Factor w/ 2 levels "1.5A5YS","5ASMQ": 2 2 2 2 2 2 2 2 2 2 ...
mod.zeroinfl <- zeroinfl(Egg_count ~ Food+Exposure+hi_lo | Food+Exposure+hi_lo, data=eggTreat,
+ dist="negbin")
> summary(mod.zeroinfl)
Call:
zeroinfl(formula = Egg_count ~ Food + Exposure + hi_lo | Food + Exposure + hi_lo, data = eggTreat, dist = "negbin")
Pearson residuals:
Min 1Q Median 3Q Max
-0.65632 -0.47163 -0.28588 0.02976 9.00804
Count model coefficients (negbin with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.04435 0.14393 -0.308 0.7580
Food -1.12486 0.22267 -5.052 4.38e-07 ***
Exposure -2.34990 0.38684 -6.075 1.24e-09 ***
hi_lo -0.44893 0.19524 -2.299 0.0215 *
Log(theta) -0.24387 0.22639 -1.077 0.2814
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.830e+01 NA NA NA
Food -5.768e+00 5.628e+04 0 1
Exposure 4.612e-01 NA NA NA
hi_lo -7.477e+00 9.963e+05 0 1
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Theta = 0.7836
Number of iterations in BFGS optimization: 21
Log-likelihood: -350.2 on 9 Df
Warning message:
In sqrt(diag(object$vcov)) : NaNs produced
function (object, ...)
{
object$residuals <- residuals(object, type = "pearson")
kc <- length(object$coefficients$count)
kz <- length(object$coefficients$zero)
se <- sqrt(diag(object$vcov))
这个问题通常是由于完全分离引起的;使用此搜索词,或搜索 Hauck-Donner 效果,将向您表明问题在于预测变量值存在某种线性组合,可完美分隔零值和非零值(由于您的零 inflation 中的预测变量都是分类变量,因此这转化为所有值为零或非零的类别组合)。
我会看一下 with(eggTreat, table(eggcount>0, Food, Exposure, hi_lo))
(按照使 table 最容易阅读的任何顺序排列参数)。
典型症状包括:
- 大参数值(例如
|beta|>10
);在这种情况下,您的截距为 -18.3,这给出了基线类别中 1e-8
的预测零 inflation 概率(其他两个值也很大,尽管不如截距那么极端)
- 非常大的标准误差(
Food
、hi_lo
),导致 z 值实际上为零,p 值实际上为 1
- 或者...您看到的
NA
值
这个问题有多种解决方案:
- 不同形式的正则化或贝叶斯先验
- 使用模型 comparison/likelihood 比率测试计算 p 值
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.830e+01 NA NA NA
Food -5.768e+00 5.628e+04 0 1
Exposure 4.612e-01 NA NA NA
hi_lo -7.477e+00 9.963e+05 0 1
我正在尝试将我的数据拟合到一个零膨胀的负二项式模型,但是当 SE 为在汇总函数中计算。我还尝试了 运行 负二项式障碍模型并且 运行 遇到了类似的问题。
str(eggTreat)
'data.frame': 455 obs. of 4 variables:
$ Exposure : Factor w/ 2 levels "C","E": 2 2 2 2 2 2 2 2 2 2 ...
$ hi_lo : Factor w/ 2 levels "hi","lo": 2 2 2 2 2 2 2 2 2 2 ...
$ Egg_count: int 0 0 0 0 0 0 0 0 0 0 ...
$ Food : Factor w/ 2 levels "1.5A5YS","5ASMQ": 2 2 2 2 2 2 2 2 2 2 ...
mod.zeroinfl <- zeroinfl(Egg_count ~ Food+Exposure+hi_lo | Food+Exposure+hi_lo, data=eggTreat,
+ dist="negbin")
> summary(mod.zeroinfl)
Call:
zeroinfl(formula = Egg_count ~ Food + Exposure + hi_lo | Food + Exposure + hi_lo, data = eggTreat, dist = "negbin")
Pearson residuals:
Min 1Q Median 3Q Max
-0.65632 -0.47163 -0.28588 0.02976 9.00804
Count model coefficients (negbin with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.04435 0.14393 -0.308 0.7580
Food -1.12486 0.22267 -5.052 4.38e-07 ***
Exposure -2.34990 0.38684 -6.075 1.24e-09 ***
hi_lo -0.44893 0.19524 -2.299 0.0215 *
Log(theta) -0.24387 0.22639 -1.077 0.2814
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.830e+01 NA NA NA
Food -5.768e+00 5.628e+04 0 1
Exposure 4.612e-01 NA NA NA
hi_lo -7.477e+00 9.963e+05 0 1
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Theta = 0.7836
Number of iterations in BFGS optimization: 21
Log-likelihood: -350.2 on 9 Df
Warning message:
In sqrt(diag(object$vcov)) : NaNs produced
function (object, ...)
{
object$residuals <- residuals(object, type = "pearson")
kc <- length(object$coefficients$count)
kz <- length(object$coefficients$zero)
se <- sqrt(diag(object$vcov))
这个问题通常是由于完全分离引起的;使用此搜索词,或搜索 Hauck-Donner 效果,将向您表明问题在于预测变量值存在某种线性组合,可完美分隔零值和非零值(由于您的零 inflation 中的预测变量都是分类变量,因此这转化为所有值为零或非零的类别组合)。
我会看一下 with(eggTreat, table(eggcount>0, Food, Exposure, hi_lo))
(按照使 table 最容易阅读的任何顺序排列参数)。
典型症状包括:
- 大参数值(例如
|beta|>10
);在这种情况下,您的截距为 -18.3,这给出了基线类别中1e-8
的预测零 inflation 概率(其他两个值也很大,尽管不如截距那么极端) - 非常大的标准误差(
Food
、hi_lo
),导致 z 值实际上为零,p 值实际上为 1 - 或者...您看到的
NA
值
这个问题有多种解决方案:
- 不同形式的正则化或贝叶斯先验
- 使用模型 comparison/likelihood 比率测试计算 p 值
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.830e+01 NA NA NA
Food -5.768e+00 5.628e+04 0 1
Exposure 4.612e-01 NA NA NA
hi_lo -7.477e+00 9.963e+05 0 1