【问题标题】:Fitting a zero inflated poisson distribution in R在 R 中拟合零膨胀泊松分布
【发布时间】:2011-11-01 16:45:14
【问题描述】:

我有一个计数数据向量,该向量非常分散且零膨胀。

矢量看起来像这样:

i.vec=c(0,63,1,4,1,44,2,2,1,0,1,0,0,0,0,1,0,0,3,0,0,2,0,0,0,0,0,2,0,0,0,0,
0,0,0,0,0,0,0,0,6,1,11,1,1,0,0,0,2)
m=mean(i.vec)
# 3.040816
sig=sd(i.vec)
# 10.86078

我想为此拟合一个分布,我强烈怀疑这将是一个零膨胀泊松 (ZIP)。但我需要执行显着性检验来证明 ZIP 分布适合数据。

如果我有一个正态分布,我可以使用包 vcd 中的函数 goodfit() 进行卡方拟合优度测试,但我不知道我可以对零膨胀数据执行任何测试。

【问题讨论】:

  • 也许属于 stats.stackexchange.com?

标签: r distribution


【解决方案1】:

这是一种方法

# LOAD LIBRARIES
library(fitdistrplus)    # fits distributions using maximum likelihood
library(gamlss)          # defines pdf, cdf of ZIP


# FIT DISTRIBUTION (mu = mean of poisson, sigma = P(X = 0)
fit_zip = fitdist(i.vec, 'ZIP', start = list(mu = 2, sigma = 0.5))

# VISUALIZE TEST AND COMPUTE GOODNESS OF FIT    
plot(fit_zip)
gofstat(fit_zip, print.test = T)

基于此,ZIP 看起来并不合适。

【讨论】:

  • +1 ;但它看起来确实可以接受负二项式拟合:fit_zip2
  • 看起来不错。我还会尝试零膨胀负二项式分布,它在VGAM 包中以zinegbin 的形式提供。
  • 非常感谢!您是如何选择 mu 和 sigma 的?
  • 另外,你的意思是写“print.test=T”吗?
  • 它们只是我任意填充的优化算法的起始值。相反,您可以使用等于样本中零比例的mu = mean(i.vec[i.vec > 0])p 作为起点。是的,我的意思是写print.test = T
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多