我刚刚发现了 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/