I a开发者_运维百科m trying to estimate the shape and scale of a data set.
I used two different ways and for both I got an error message:First, I tried by moments using the survey
package:
survreg(Surv(all.ws)~1, dist="weibull")
I got the error message:
invalid survival times for this distribution
Second, I tried using fitdistr()
function:
fitdistr(all.ws, densfun=dweibull, start=list(scale=1, shape=2))
I got an error message:
Error in optim(x=c(2.2, 2.1,1.9....:
initial value in 'vmmin' is not finite
What is wrong with what I am doing?
A google search "fitdistr Weibull Error" shows this exact question was discussed a year ago on the R-help mailing list: http://r.789695.n4.nabble.com/Problems-with-fitdistr-td1334772.html
Some points from that link:
zeros in your data will cause problems
use pelwei() function from package lmom
I had a similar problem when using fitdistr() with a Beta distribution. In that case both ones and zeros in the data produced this error.
Additionally I found that when the limit argument is used in the fitdistr() call, a different error is produced: eg (where x is a vector of samples containing a 1.0 or 0):
fitdistr(x, "beta", list(shape1 = 1, shape2 = 0.2),lower=0.001)
`Error in stats::optim: L-BFGS-B needs finite values of 'fn'`
精彩评论