r - 使用 fitdistplus 中的 fitdist 和二项式分布

标签 r distribution

我刚刚发现了 fitdistrplus 包,并且我用泊松分布等启动并运行了它。但是在尝试使用二项式时我遇到了困难:

set.seed(20)
#Binomial distributed, mean score of 2
scorebinom <- rbinom(n=40,size=8,prob=.25)


fitBinom=fitdist(data=scorebinom, dist="binom", start=list(size=8, prob=mean(scorebinom)/8))

我收到错误:

Error in fitdist(data = scorebinom, dist = "binom", start = list(size = 8,  : 
  the function mle failed to estimate the parameters, 
                with the error code 100
In addition: There were 50 or more warnings (use warnings() to see the first 50)

我从这个包中看到了很多关于负二项式分布的文档,但关于二项式分布的文档不多。此函数似乎确实支持此分布(尽管 MASS 中的 fitdistr 不支持)。

有什么想法吗?

最佳答案

您不是总是知道试验次数(即大小参数)吗?如果是这样,请尝试

fitBinom=fitdist(data=scorebinom, dist="binom", fix.arg=list(size=8), start=list(prob=0.3))

估计 p 及其误差。

关于r - 使用 fitdistplus 中的 fitdist 和二项式分布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27628529/

相关文章:

r - 按年和月对年月列进行排序

用其他数据框中的值替换数据框中的 NA

algorithm - 没有前瞻性的桶之间的加权分布

r - 如何将我构建的模型拟合到另一个数据集并获得残差?

R子集唯一观察保留最后一个条目

r - 'arg' 必须为 NULL 或字符向量

java - 如何在 Java 中转移分布中的数据

c++ - 如何从限制在一定区间内的正态分布中采样,C++实现?

ipad - 如何在多台 iPad 上安装 iPad 应用程序?

python - 如何查找pandas中特定范围内的值的数量?