【问题标题】:Fitting a Gumbel distribution with fitdistrplus用 fitdistrplus 拟合 Gumbel 分布
【发布时间】:2016-07-05 09:02:12
【问题描述】:

我正在尝试从this answer 复制代码,但是这样做有问题。我正在使用包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'.

好像locationscale 不是*gumbel 的参数。

dgumbelpgumbelrgumbelqgumbelVGAM 正确提供。 然而,该包还提供了一个名为gumbel 的函数,具有不同的语法。这会导致问题吗?

编辑:是的,它确实导致了问题:使用包 FAdist 反而工作得很好。

【问题讨论】:

    标签: r model-fitting fitdistrplus


    【解决方案1】:

    供参考,来自cmets中链接的package vignette

    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 函数”
    • 你试过library("sos"); findFn("rgumbel")吗? VGAM, evd 包,可能还有其他...可能需要包装/重新定义以更改参数化...
    • 编辑:这似乎是随机的口香糖......现在,任何线索该功能是什么样的?
    • 似乎您应该将其表述为一个新问题...?
    【解决方案2】:

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

    【讨论】:

    • 您有任何来源、解释或参考吗?
    • 如果你使用'gumbel',它会说:不支持的分发。然后在包文档中:'分布“beta”,“cauchy”,“chi-squared”,“exponential”,“f”,“gamma”,“geometric”,“log-normal”,“lognormal”,“logistic "、"负二项式"、"正常"、"泊松"、"t" 和 "weibull" 被识别,忽略大小写。库 ismev 和 EnvStats 可以估计 gumbel 参数
    • 实际上“gumbel”分布也在包文档中使用:cran.r-project.org/web/packages/fitdistrplus/fitdistrplus.pdf,第 29 页,带有自定义的 gumbel。为什么VGAM 的口香糖不起作用?顺便说一下,在上述文档中,您提到的字符串不存在。你在哪里得到它?请提供链接。
    • 但是你必须自己定义 gumbel 分布才能得到合适的结果。
    【解决方案3】:

    开始=列表(mu=R,s=R) R=你的参数

    【讨论】:

    • 请为您的公式(或一般代码)添加一些解释。
    猜你喜欢
    • 2021-04-20
    • 1970-01-01
    • 2023-04-07
    • 2019-09-13
    • 2019-12-28
    • 2017-06-25
    • 2011-10-14
    • 2015-08-01
    • 1970-01-01
    相关资源
    最近更新 更多