R中的威布尔分布(ExtDist)

3

有人使用ExtDist Package时遇到了Weibull分布的问题吗?

来自文档

对于具有未知形状参数的分布进行参数估计 来源于:Rinne(2009)数据集p.338和示例pp.418-419 参数估计结果为形状=99.2079和比例尺度=2.5957。 对于这个数据和Rinne参数估计,对数似然为-1163.278。

data <- c(35,38,42,56,58,61,63,76,81,83,86,90,99,104,113,114,117,119,141,183)
est.par <- eWeibull(X=data, method="numerical.MLE"); est.par
plot(est.par)

然而,当我运行它时,输出如下:
Parameters for the Weibull distribution.
(found using the  numerical.MLE method.)

 Parameter  Type   Estimate       S.E.
     shape shape 5.82976007 1.79326460
     scale scale 0.06628166 0.02129258

这显然是错误的,但我不确定是我犯了错误还是软件包中存在漏洞?


你读了示例的下一部分吗?“# eWeibull计算的估计值与Rinne(2009)给出的估计值不同。然而,由于lWeibull给出的更大的对数似然度为-99.09037,eWeibull的参数估计似乎是一种改进。” - Ben Bolker
嗨Ben,是的,我试过了,但是我从代码中得到的答案5.82976007绝对不接近,输出应该在99左右。 - James
1
似乎引用的值被交换了,除了Ben B指出的其他问题。Weibull分布的均值是gamma(1 + 1/shape) times scale,这应该与数据的平均值相差不大。对于shape = 99和scale = 2.6,平均值非常不可信,但如果交换,则非常可信。此外,我尝试使用手动编写的函数处理数据,并得到shape = 2.6,scale = 99。我想Rinne的论文中参数是否被正确说明是一个未解之谜,或者在引用中是正确的但在那里是错误的。记录一下,我尝试了0.6-4(最新版本)。 - Robert Dodier
值得一提的是,ExtDist中的错误已经在0.7-1版本中被修正,正如下面@notch所描述的那样。 - Robert Dodier
2个回答

2

在我看来,这似乎是包中的一个错误。我进行了自己独立的最大似然估计,并得到了与Rinne相同的答案:

library(bbmle)
m1 <- mle2(y~dweibull(shape=exp(lshape),scale=exp(lscale)),
     data=data.frame(y=data),
     start=list(lshape=0,lscale=0))

然后我深入研究了dWeibull函数的源代码:

function (x, shape = 2, scale = 2, params = list(shape = 2, scale = 2)) 
{
    if (!missing(params)) {
        shape <- params$shape
        scale <- params$scale
    }
    out = stats::dgamma(x, shape, scale)
    return(out)
}

似乎应该将out设置为dweibull(...)的结果,而不是dgamma(...)的结果...?? 从剩下的韦伯代码来看,这个错误似乎被重复了--也许这只是一个马虎的剪切和粘贴?我一定会联系维护者(maintainer("ExtDist"))。
附注:如果我使用我的替代方法拟合伽马分布,我得到的答案与ExtDist包完全相同。
m1g <- mle2(y~dgamma(shape=exp(lshape),rate=exp(lrate)),
     data=data.frame(y=data),
     start=list(lshape=0,lrate=0))
exp(coef(m1g))
##     lshape      lrate 
## 5.82976007 0.06628166 

1

错误影响了eGamma和eWeibull的代码,但现在已经修复(v0.7-1,2023年1月17日)。感谢Robert Dodier指出了这些问题。

eWeibull当前的输出:

# Parameter Estimation for a distribution with unknown shape parameters
# Example from: Rinne (2009) Dataset p.338 and example pp.418-419
# Parameter estimates are given as shape = 2.5957 and scale = 99.2079.
data <- c(35,38,42,56,58,61,63,76,81,83,86,90,99,104,113,114,117,119,141,183)
est.par <- eWeibull(X=data, method="numerical.MLE"); est.par

Parameters for the Weibull distribution. 
(found using the  numerical.MLE method.)

Parameter  Type Estimate      S.E.
    shape shape  2.59566 0.4366932
    scale scale 99.20792 9.0404336

# consistent with EnvStats estimates
EnvStats::eweibull(data)$parameters
    shape     scale 
 2.595663 99.207982 

eGamma当前的输出:

# Parameter estimation for a distribution with unknown shape parameters
# Example from:  Bury(1999) pp.225-226, parameter estimates as given by Bury are
# shape = 6.40 and scale=2.54.
data <- c(16, 11.6, 19.9, 18.6, 18, 13.1, 29.1, 10.3, 12.2, 15.6, 12.7, 13.1,
          19.2, 19.5, 23, 6.7, 7.1, 14.3, 20.6, 25.6, 8.2, 34.4, 16.1, 10.2, 12.3)
est.par <- eGamma(data, method="numerical.MLE"); est.par

Parameters for the Gamma distribution. 
(found using the  numerical.MLE method.)

Parameter  Type Estimate      S.E.
    shape shape 6.404003 1.7661637
    scale scale 2.544659 0.7300405

# consistent with EnvStats estimates
EnvStats::egamma(data)$parameters
    shape    scale 
 6.404041 2.544643 

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