Has anyone had problems with the Weibull distribution using the ExtDist Package ?
From the documentation :
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 = 99.2079 and scale = 2.5957. The log-likelihood for this data and Rinne's parameter estimates is -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)
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?
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))
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)
}
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. 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
Bugs affected code of eGamma and eWeibull, but this has now been fixed (v0.7-1, Jan 17, 2023). Thanks to Robert Dodier for pointing at them.
Current output of 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
Current output of 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.