De la Vega Góngora Jorge
2004-Oct-27 18:47 UTC
[R] Warning messages in function fitdistr (library:MASS)
Why the warning messages (2:4)?> 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) and with respect to this function, it is curious that only for the normal family the mle is obtained in closed form. Why not in other cases like the exponential? Using R 1.9.1 or 2.0.0 under Windows. Jorge
Prof Brian Ripley
2004-Oct-27 19:26 UTC
[R] Warning messages in function fitdistr (library:MASS)
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