使用fitdistrplus拟合Gumbel分布

5

我正在尝试复现这个回答中的代码,但是我在操作时遇到了一些问题。我正在使用VGAMfitdistrplus包中的gumbel分布。

问题出现在执行以下代码时:

fit   = fitdist(data1, 'gumbel', start = list(location = 0, scale = 1))
Error in mledist(data, distname, start, fix.arg, ...) : 
  'start' must specify names which are arguments to 'distr'.

似乎*gumbel没有*location和*scale参数。 VGAM正确提供dgumbelpgumbelrgumbelqgumbel函数,但是该软件包还提供了一个名为gumbel的函数,其语法不同。这可能会导致问题吗? 编辑:确实会引起问题:改用软件包FAdist即可正常运行。
3个回答

5

作为参考资料,从评论中链接的软件包文档可知:

library(fitdistrplus)
data(groundbeef)
serving <- groundbeef$serving
dgumbel <- function(x, a, b) 1/b*exp((a-x)/b)*exp(-exp((a-x)/b))
pgumbel <- function(q, a, b) exp(-exp((a-q)/b))
qgumbel <- function(p, a, b) a-b*log(-log(p))
fitgumbel <- fitdist(serving, "gumbel", 
    start=list(a=10, b=10))

或者使用来自 VGAM 的函数:

rm(dgumbel) ## get rid of previous definition
## hack behaviour of VGAM::pgumbel() a little bit
pgumbel <- function(x,...) {
  if (length(x)==0) numeric(0) else VGAM::pgumbel(x,...)
}
library(VGAM)
fitgumbel <- fitdist(serving, "gumbel", 
       start=list(location=10, scale=10))

您知道rgumbel的定义吗?当使用bootdist时,我得到了“必须定义rgumbel函数”的错误提示。 - Oliver Amundsen
你尝试过 library("sos"); findFn("rgumbel") 吗?可能需要使用 VGAMevd 等包,并重新定义参数来进行包装。 - Ben Bolker
现在看起来像是随机 Gumbel 函数... 有什么线索可以告诉我们这个函数长什么样吗? - Oliver Amundsen
好像你应该把这个问题重新表述为一个新问题……? - Ben Bolker

-2

start=list(mu=R,s=R) R=您的参数


1
请为您的公式(或代码)添加一些解释。 - Alexei - check Codidact

-2

这是因为fitdistr包不支持gumbel分布。


1
你有任何的源代码、解释或参考资料吗? - AF7
如果您使用“gumbel”,它会显示:不支持的分布。然后在软件包文档中:“beta”、“cauchy”、“chi-squared”、“exponential”、“f”、“gamma”、“geometric”、“log-normal”、“lognormal”、“logistic”、“negative binomial”、“normal”、“Poisson”、“t”和“weibull”这些分布是被识别的,大小写不敏感。Libraries ismev和EnvStats可以估计gumbel参数。 - Forever
实际上,“gumbel”分布也在包文档中使用:https://cran.r-project.org/web/packages/fitdistrplus/fitdistrplus.pdf,第29页,使用自定义定义的gumbel。为什么`VGAM`中的gumbel不起作用?顺便说一下,在上述文档中,您提到的字符串不存在。您从哪里得到的?请提供链接。 - AF7
但是你必须自己定义古贝尔分布来获得拟合结果。 - Forever

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接