[R] Optimization failed in fitting mixture 3-parameter Weibull distri bution using fitdistr()

Yang, Richard dyang at nrcan.gc.ca
Mon Jul 28 17:12:53 CEST 2003


Dear All;

	I tried to use fitdistr() in the MASS library to fit a mixture
distribution of the 3-parameter Weibull, but the optimization failed.
Looking at the source code, it seems to indicate the error occurs at 
                if (res$convergence > 0) 
        stop("optimization failed").

            The procedures I tested are as following:

>w3den <- function(x, a,b,c) {c/b*((x -a)/b)^(c-1)*exp(-((x-a)/b)^c)}    #
define 3-parameter Weibull density
>w3den <- function(x, a,b,c) {c/b*((x -a)/b)^(c-1)*exp(-((x-a)/b)^c)}
>set.seed(123)
> x3 <- rweibull(100, shape = 4, scale = 100)                             #
Distribution 1
> fitdistr(x3, w3den, start= list(a = 8.8, b = 90.77, c = 3.678))      #
Fitting 3-parameter

       a            b            c     
   8.9487415   90.6667712    3.6722124 
 (15.1462445) (16.0657103) ( 0.7582376)
Warning messages: 
1: NaNs produced in: log(x) 
2: NaNs produced in: log(x)
>      x4 <- rweibull(50, shape = 3, scale = 90)                           #
Distribution 2
> fitdistr(x4, w3den, start=list(a = 5.0, b = 90, c = 3))
       a            b            c     
  -67.572244   159.020786     5.835588 
 (105.975870) (107.842846) (  4.288019)
Warning messages: 
1: NaNs produced in: log(x) 
2: NaNs produced in: log(x) 

> mweib <- function(x, p, a,b,c,a1, b1, c1) {p*(c/b*((x -
a)/b)^(c-1)*exp(-((x-a)/b)^c))+
+             +(1-p)*(c1/b1*((x -a1)/b1)^(c1-1)*exp(-((x-a1)/b1)^c1))}
# define mixture distribution
> x5 <- c(x3, x4)
> fitdistr(x5, mweib, start=list(p = 0.7, a = 8.9, b=90.77, c = 3.68, a1 =
-67.57, b1 = 159.02, c1 = 5.83))
Error in fitdistr(x5, mweib, start = list(p = 0.7, a = 8.9, b = 90.77,  : 
        optimization failed
In addition: There were 14 warnings (use warnings() to see them).

	I tested the same procedures with a mixture 2-parameter Weibull
distribution without problems. With a limited experience with the
fitdistr(), it seems to me, similar to all nonlinear or optimization
procedures,  the starting values are critical for convergence. Any
suggestions for solving the optimization problem?

	TIA

Richard Yang


Northern Forestry Centre   /	Centre de foresterie du Nord
Canadian Forest Service	   /	Service canadien des forêts
Natural Resources Canada   /	Ressources naturelles Canada
5320-122 Street     	   /	5320, rue 122

Edmonton (Alberta) Canada
T6H 3S5




More information about the R-help mailing list