问题描述
使用 ExtDist软件包?
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)
但是,当我运行它时,我得到以下输出:
However when I run this I get the following output:
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
这显然是错误的,但是我不确定是否做错了或者包装中是否有错误?
This is clearly wrong but I am not sure if I have made a mistake or if there is a bug in the package?
推荐答案
在我看来,这是程序包中的错误.我做了自己的独立MLE,得到了与Rinne相同的答案:
It seems to me it's a bug in the package. I did my own independent MLE and got the same answer as 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
函数的源代码:
Then I dug in and looked at the source of the dWeibull
function:
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(...)
...?查看其余的weibull代码,似乎会重复出现此错误-也许这只是草率的剪切粘贴?我一定会联系维护者(maintainer("ExtDist")
).
It seems that out
should be set to the result of dweibull(...)
rather than dgamma(...)
... ?? Looking at the rest of the weibull code, this error seems to be repeated -- maybe this is just a sloppy cut-and-paste? I would definitely contact the maintainer (maintainer("ExtDist")
).
PS.如果我使用替代方法拟合Gamma分布,则得到的答案与ExtDist
软件包完全相同:
PS. If I fit a Gamma distribution using my alternative method I get exactly the same answers as the ExtDist
package:
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
这篇关于R中的Weibull分布(ExtDist)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!