How to fit a Weibull distribution to input data containing zeroes? I'm trying to reproduce an existing prediction algorithm, handed down by a retired researcher. The first step is to fit some observed data to a Weibull distribution, to obtain a shape and scale which will be used for predicting future values. I'm using R to do this. Here's an example of my code:
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)
f<-fitdistr(x, 'weibull')

This works fine unless there are any zeroes in the input array, which causes it to fail completely. The same thing happens in SAS. As I understand it, this is because one of the steps in calculating the Weibull distribution is taking the natural log, which is undefined for 0. Is there a reasonable way to work around this? 
The best I've found so far is to add 1 to all of my input values, fit the curve, and then subtract one from my predicted values ("shift" the curve up and then back down by 1). This fits the previously predicted data fairly well, but seems like it must be a wrong way of doing so. 
edit: The values in the input array are observed, real-world data (the number of occurrences of something) for a range of years. So in some years the number of occurrences was zero. Whether it's the best way or not (I agree that it may not be), the original algorithm author claims to have used the Weibull distribution, and I have to try to replicate their process. 
 A: You could also try fitting a three-parameter Weibull, where the third parameter is a location parameter, let us say $\theta$.  This amounts to estimating the constant that you ought to add to the data to get you the best fit to  the Weibull.  You might do this using a profile likelihood approach by putting a "wrapper" around fitdistr, where the wrapper takes a value of $\theta$ and the data, adds $\theta$ to the data, calls the fitdistr function, and returns the associated logliklihood:
foo <- function(theta, x)
{
  if (theta <= -min(x)) return(Inf);
  f <- fitdistr(x+theta, 'weibull')
  -2*f$loglik
}

Then minimize this function using one-dimensional optimization:
bar <- optimize(foo, lower=-min(x)+0.001, upper=-min(x)+10, x=x)

where I have just made up the "+10" based on nothing at all.
For the data with the three smallest values replaced with zeroes, we get:
> bar
$minimum
[1] 2.878442

$objective
[1] 306.2792

> fitdistr(x+bar$minimum, 'weibull')
     shape        scale   
   1.2836432   81.1678283 
 ( 0.1918654) (12.3101211)
> 

bar$minimum is the MLE of $\theta$, and the fitdistr outputs are the MLEs of the Weibull parameters, jointly with $\theta$ that is.  As you can see, they are pretty close to the method-of-moments estimators @r.e.s. demonstrated above.
A: It should fail, you should be grateful that it failed. 
Your observations showed that failures occurred at the very moment you started observing them. If this is a real process, coming from real (and not simulated data), you need to somehow account for the reason why you're getting zeros. I've seen survival studies where 0 times show up as a consequence of one of several things: 


*

*The data are actually truncated: objects were at risk and failed before the study started and you want to pretend you had observed them all along.

*The instruments are poorly calibrated: you don't have enough measurement precision for the study and so failures occurring near the start time were coded as exactly zero.

*The thing coded as a zero is not a zero. They're people or objects that were excluded from the analysis one way or another. The zero just shows up in the data as a consequence of merging, sorting, or otherwise recoding missing values.


So for case 1: you need to use proper censoring methods, even if that means retrospectively pulling records. Case 2 means you can use the EM algorithm because you have a precision issue. Bayesian methods work similarly here as well. Case 3 means you just need to exclude the values that were supposed to be missing.
A: I agree with cardinal's answer above.  However, it is also quite common to add a constant to avoid zeros.  Another value commonly used is 0.5, but any positive constant might have been used.  You might try a range of values to see if you can identify the exact value used by the previous researcher.  Then you could be confident that you are able to reproduce his results, before going on a search for a better distribution.  
A: [Assuming Weibull is appropriate] Johnson Kotz and Balakrishnan's book has a lot of ways to estimate Weibull parameters.  Some of these do not depend on the data not including zeroes (e.g. using the mean and standard deviation, or using certain percentiles).
Johnson, N. L., Kotz, S., and Balakrishnan, N. (1994). Continuous Univariate Distributions. New York: Wiley, roughly on page 632.
