[R] Parameter estimation of gamma distribution
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Feb 15 17:54:13 CET 2012
On 15/02/2012 14:18, Yogs wrote:
> Hi,
>
> I am trying to estiamte parameters for gamma distribution using mle for
> below data using fitdist& fitdistr functions which are from "fitdistrplus"
> & "MASS"packages . I am getting errors for both functions. Can someone
> please let me know how to overcome this issue??
>
> data
> y1<-
> c(256656, 76376, 6467673, 46446, 3400, 3100, 5760, 4562, 8000, 512, 4545,
> 4562, 4645, 4521, 4624, 5110, 4678, 4782, 4587, 491100,48426, 457940, 45000,
> 4820, 48225, 5415, 482466, 185535, 174346, 46875, 4876467)
>
> Results
>> fitdist(y1,"gamma")
> Error in fitdist(y1, "gamma") :
> the function mle failed to estimate the parameters,
> with the error code 100
> In addition: There were 17 warnings (use warnings() to see them)
>
>> fitdistr(y1,"gamma")
> Error in optim(x = c(256656, 76376, 6467673, 46446, 3400, 3100, 5760, :
> non-finite finite-difference value [1]
> In addition: Warning messages:
> 1: In dgamma(x, shape, scale, log) : NaNs produced
> 2: In dgamma(x, shape, scale, log) : NaNs produced
Rescale your values, as the help page suggests.
Note:
Numerical optimization cannot work miracles: please note the
comments in ‘optim’ on scaling data. If the fitted parameters are
far away from one, consider re-fitting specifying the control
parameter ‘parscale’.
Using 1e-6*y1 works.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list