[R] weibull fitdistr problem: optimization failed

ethan.shepherd someguy235 at gmail.com
Fri Oct 28 16:02:06 CEST 2011


I'm getting errors when running what seems to be a simple Weibull
distribution function:

This works:
x <-
c(23,19,37,38,40,36,172,48,113,90,54,104,90,54,157,51,77,78,144,34,29,45,16,15,37,218,170,44,121)
rate <- c(.01,.02,.04,.05,.1,.2,.3,.4,.5,.8,.9)
year <- c(100,50,25,20,10,5,3.3,2.5,2,1.2,1.1)
library(MASS)
x <- sort(x)
tryCatch(
  f<-fitdistr(x, 'weibull'),
  error = function(e) cat(as.character(e))
)
shape = f$estimate["shape"]
scale = f$estimate["scale"]
cat(shape,scale,"\n")

for (i in 1:length(rate)){
  cat(scale*(-log(rate[i]))^(1/shape))
  cat(",")
}

I get my shape and scale printed out, and my calculated values, no problem.

If I change the data to this:

x <-
c(4,22,26,27,44,46,83,83,122,125,129,151,153,157,171,173,186,199,201,202,205,219,239,242,252,315,326,449,771)

I get the error "Error in fitdistr(x, "weibull"): optimization failed"

I can run a Weibull distribution in SAS with this same data, and it gives me
what looks like a reasonable answer. 

What am I missing here?

Thanks,

--Ethan

--
View this message in context: http://r.789695.n4.nabble.com/weibull-fitdistr-problem-optimization-failed-tp3947997p3947997.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list