[R] Warning messages in function fitdistr (library:MASS)

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Oct 27 21:26:39 CEST 2004


On Wed, 27 Oct 2004, De la Vega Góngora Jorge wrote:

> Why the warning messages (2:4)?

The warnings are about your uninformed use of the function.  You have read
the reference (as the R posting guide asks) haven't you?

You are trying to fit a distribution with parameter > 0 by an
*unconstrained* optimizer with a deliberately poor starting value,
ignoring warning 1.

> > x <- rexp(1000,0.2)
> > fitdistr(x,"exponential",list(rate=1))
>       rate    
>   0.219824219 
>  (0.006951308)
> Warning messages: 
> 1: one-diml optimization by Nelder-Mead is unreliable: use optimize in: optim(start, mylogfn, x = x, hessian = TRUE, ...) 
> 2: NaNs produced in: dexp(x, 1/rate, log) 
> 3: NaNs produced in: dexp(x, 1/rate, log) 
> 4: NaNs produced in: dexp(x, 1/rate, log) 

fitdistr(x,"exponential",list(rate=1), lower=0.001, method="L-BFGS-B")

would be a much better way, following the examples on the help page.

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