问题描述
我以数据向量PC6的形式设置了简单的计数数据。我试图识别分布,以便为仿真创建伪生成器。我数据的频率表是
> table(PC6)
PC6
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 23 26 28 29 30 31 32 34 36
96 45 38 60 40 47 37 26 32 16 12 13 12 11 6 4 4 5 1 1 2 2 1 1 1 2 1 1 1 1 1
41 48 59 64
1 1 1 1
我定义了几个模型,以便识别AIC来比较模型并找到最佳匹配。由于可能的零比例很大,因此我加入了“零膨胀”模型和障碍模型。我的模型是:
> pc6zip <- zeroinfl(PC5 ~ 1|1,dist = "poisson")
> pc6zinb <- zeroinfl(PC6 ~ 1|1,dist = "negbin")
> pc6nb <- fitdistr(PC6,"negative binomial")
> pc6pois <- fitdistr(PC6,"poisson")
> pc6hurdle <- hurdle(PC6 ~ 1|1,dist = "poisson",zero.dist = "poisson")
> AIC(pc6hurdle,pc6nb,pc6pois,pc6zinb,pc6zip)
df AIC
pc6hurdle 2 4092.290
pc6nb 2 2957.367
pc6pois 1 4794.918
pc6zinb 3 2951.646
pc6zip 2 3286.346
我看到负二项式和零膨胀负二项式非常接近。如果我正确地完成了这一部分,我的问题是我如何生成将遵循此ZINB模型的新日期集,因为我只有这个参数theta
> summary(pc6zinb)
Call:
zeroinfl(formula = PC6 ~ 1 | 1,dist = "negbin")
Pearson residuals:
Min 1Q Median 3Q Max
-0.9387 -0.7732 -0.2767 0.3853 9.6531
Count model coefficients (negbin with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.82669 0.05153 35.446 <2e-16 ***
Log(theta) 0.23829 0.12304 1.937 0.0528 .
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.3489 0.3354 -7.004 2.48e-12 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Theta = 1.2691
Number of iterations in BFGS optimization: 13
Log-likelihood: -1473 on 3 Df
如果我看一下这个负二项式模型,我会得到这个输出
Call:
glm.nb(formula = PC6 ~ 1,init.theta = 0.9328223932,link = log)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.9109 -1.1309 -0.2927 0.3290 3.6570
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.73550 0.04881 35.56 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(dispersion parameter for Negative Binomial(0.9328) family taken to be 1)
Null deviance: 603.94 on 523 degrees of freedom
Residual deviance: 603.94 on 523 degrees of freedom
AIC: 2957.4
Number of Fisher Scoring iterations: 1
Theta: 0.9328
Std. Err.: 0.0714
2 x log-likelihood: -2953.3670
由于AIC确实很接近,您是否认为负二项式是更好的模型,以及如何使用此theta参数生成遵循ZINB模型的新数据集
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)