[R] weibull fitdistr problem: optimization failed

Ben Bolker bbolker at gmail.com
Fri Oct 28 18:24:14 CEST 2011


ethan.shepherd <someguy235 <at> gmail.com> writes:

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

  [snip]

> If I change the data to this:
> 

 [snip] 

> 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. 
>


 How about:

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)

hist(x)
fit2 <-fitdistr(x, 'weibull',lower=c(0.01,0.01))

hist(x,freq=FALSE,col="gray",ylim=c(0,0.004))
with(as.list(coef(fit2)),curve(dweibull(x,shape=shape,scale=scale),
     add=TRUE,col=2))



More information about the R-help mailing list