【问题标题】:using fitdist from fitdistplus with binomial distribution使用 fitdistplus 中的 fitdist 和二项分布
【发布时间】:2019-07-09 16:28:56
【问题描述】:

我刚刚发现了 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 不支持)。

有什么想法吗?

【问题讨论】:

  • 问题似乎是由在 fitdist 内部调用的 MLE 例程引起的 - 帮助文件的 Value 部分中有一个(有些无用的)输出代码列表?mledist。我在拟合参数时不时遇到这样的错误,通常很难找到确切的原因。您可以尝试使用custom.optim 函数fitdist 传递给optim。有时我使用 模拟退火optim 使用的默认算法更幸运。 ...
  • 例如,这会返回参数估计值,但不返回标准错误,并且仍然会产生警告:fitdist(data=x,dist="binom",start=list(size=8, prob=mean(x)/8),custom.optim=function(...){optim(..., method="SANN")})(为了方便,我将您的向量 scorebinom 重命名为 x)。

标签: r distribution


【解决方案1】:

您不是总是知道试验次数(即大小参数)吗?如果有,那就试试

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

估计 p 及其误差。

【讨论】:

  • 谢谢!那行得通。对我来说,当我为起始值提供 size 参数时它无法估计它似乎很奇怪,但我认为在固定参数列表中应该需要它是有道理的。我认为fitdist 文档在这里可以更明确。
猜你喜欢
  • 2019-04-30
  • 2019-03-14
  • 2019-01-31
  • 2019-09-04
  • 2017-10-05
  • 2019-12-09
  • 2021-11-25
  • 2019-09-13
  • 2018-03-22
相关资源
最近更新 更多