【问题标题】:Fit generalized lambda distribution with "fitdist" function使用“fitdist”函数拟合广义 lambda 分布
【发布时间】:2017-10-05 10:54:10
【问题描述】:

我正在尝试将带有 fitdist() 函数(包含在 fitdistrplus 包中)的数字向量拟合到几个分布:weibull 2-P、weibull 3-P、gamma、lognormal、exponential、gumbel、normal、loglogistic、逻辑和广义 lambda。

其中一些包含在与“fitdist()”相同的包中,其他包含在不同的包中,我创建了 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 

【问题讨论】:

    标签: r lambda fitdistrplus


    【解决方案1】:

    您在fitdist 和广义 lambda 分布 (GLD) 中发现的问题似乎是由于命令中实现的优化算法造成的。
    如果我们使用gldfit.fkml 命令估计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
    

    【讨论】:

    • 我已经用不同的数据尝试过你的解决方案,它似乎应该可以工作,但我的数据不能,出现同样的错误。也许“mle”方法不能具体处理我的数据?非常感谢。
    • 您是否尝试过将fit.fkmlML 方法一起使用?
    • 可以,而且可以正常工作,不知道为什么在fitdist上不行。
    猜你喜欢
    • 2019-09-13
    • 1970-01-01
    • 2019-12-28
    • 2021-09-23
    • 2021-01-19
    • 1970-01-01
    • 2012-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多