2017-05-07 70 views
2

我試圖用fitdist()函數(包含在fitdistrplus包中)將數值向量擬合到幾個分佈:weibull 2-p,weibull 3-P,gamma,對數正態分佈,指數,gumbel,正態,loglogistic,邏輯和廣義lambda。適合具有「fitdist」函數的廣義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 

回答

0

您使用fitdist和廣義拉姆達分佈(GLD)發現這個問題似乎是由於在命令中實現的優化算法。
如果我們估計GLD使用的gldfit.fkml命令的參數,我們得到的最優值沒有任何錯誤:

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 
+0

我已經試過您的解決方案不同的數據,似乎它應該工作,但不與我的數據,會出現同樣的錯誤。也許「mle」方法不能具體地處理我的數據? 非常感謝。 –

+0

您是否嘗試過使用'fit.fkml'和'ML'方法? –

+0

是的,它工作正常,不知道爲什麼它不適合fitdist。 –