5

I am 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?

Andre Silva
  • 4,782
  • 9
  • 52
  • 65
eliavs
  • 2,306
  • 4
  • 23
  • 33

2 Answers2

6

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

Prasad Chalasani
  • 19,912
  • 7
  • 51
  • 73
  • 1
    apparently because it takes a log, not sure though. – Prasad Chalasani Jan 11 '11 at 12:31
  • 1
    @Prasad Any chance you could update the answer showing _how_ to use pelwei function to solve this as I'm having the same difficulty myself. It's returning 3x parameters whereas I'm looking for just 2x (shape and scale for Weibull). Thanks! – dardisco Feb 25 '13 at 17:42
0

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'`
Tony M.
  • 155
  • 1
  • 2
  • 7