【发布时间】: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