我试图使用fitdist()函数(包含在fitdistrplus包中)将数值向量拟合到几个分布:weibull 2-P,weibull 3-P,gamma,lognormal,exponential,gumbel,normal, loglogistic,logistic和generalized lambda。
其中一些包含在同一个包中,其中包括不同的包,我创建了gumbel发行版。我对它们中的任何一个都没有问题,只有GLD。我已经尝试过fitdist函数的所有方法(mle,mme ......),以及包" gld"和" GLDEX"创建分发函数。
fitdist(example$`TTF MIN`, "gl", start=list(12139.06, 0.000434674, 0.2, -1.5), method="mle", control=list(trace=1, REPORT=1))
Error in fitdist(example$`TTF MIN`, "gl", start = list(12139.06, 0.000434674, :
the function mle failed to estimate the parameters,
with the error code 100
和...
memp <- function(x, order) mean(x^order)
fgl <- fitdist(example$`TTF MIN`, "gl", method="mme",order=c(1, 2, 3, 4), memp="memp", start=c(10, 10), lower=1, upper=Inf)
Error in mmedist(data, distname, start = start, fix.arg = fix.arg, ...) :
wrong dimension for the moment order to match
数据基本统计数据:
min(example$`TTF MIN`)
[1] 1338.149
max(example$`TTF MIN`)
[1] 27485.42
median(example$`TTF MIN`)
[1] 12555.87
mean(example$`TTF MIN`)
[1] 13983.5
sd(example$`TTF MIN`)
[1] 4220.227
skewness(example$`TTF MIN`)
[1] 0.7572039
kurtosis(example$`TTF MIN`)
[1] -0.1358661
quantile(example$`TTF MIN`, probs = c(0.25, 0.5, 0.75, 1))
25% 50% 75% 100%
11006.06 12555.87 17037.58 27485.42
答案 0 :(得分:0)
使用fit.fkml
和广义lambda分布(GLD)找到的问题似乎是由于命令中实现的optmization算法。
如果我们使用gld
的{{1}}命令估算GLD的参数,我们会得到没有错误的最佳值:
library(fitdistrplus)
library(gld)
set.seed(3)
x <- rnorm(100, mean=2, sd=3)
fitGLD <- fit.fkml(x, method = "ML")
print(fitGLD)
########
Maximum Likelihood estimate, gld type: fkml
lambda1 lambda2 lambda3 lambda4
2.2351 0.4406 0.2643 0.4115
下面我们尝试使用fitdist
估算GLD参数,并使用距离fit.fkml
给出的最佳值不远的参数的初始值:
fitdist(x, "gl", start=list(2.2,0.4,0.3,0.5), method="mle",
control=list(trace=1, REPORT=1))
######
Nelder-Mead direct search function minimizer
<simpleError in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs = data, gr = gradient, ddistnam = ddistname, hessian = TRUE, method = meth, lower = lower, upper = upper, ...): la funzione non può essere calcalata per i parametri iniziali>
Error in fitdist(x, "gl", start = list(2.0, 0.4, 0.3, 0.5), method = "mle", :
the function mle failed to estimate the parameters,
with the error code 100
算法无法找到解决方案,但如果我们使用更接近最优值的初始值重试,fitdist
会产生解决方案:
optGLD <- fitGLD$optim.results$par
(opt <- round(optGLD ,1))
#######
[1] 2.2 0.4 0.3 0.4
fitdist(x, "gl", start=list(opt[1], opt[2], opt[3], opt[4]), method="mle",
control=list(trace=0, REPORT=1))
########
Fitting of the distribution ' gl ' by maximum likelihood
Parameters:
estimate Std. Error
1 2.2369295 0.31415154
2 0.4407676 0.05857841
3 0.2639203 0.07714630
4 0.4115397 0.09449990