[R] Fitdistr and mle

Ben Bolker bbolker at gmail.com
Wed Dec 25 17:46:16 CET 2013


Tia Borrelli <tiaborrelli <at> yahoo.it> writes:

>  Thanks for answering, in ret i've the returns of FTSE MIB (the
> benchmark stock market index in Italy) and i'm estimating the
> parametres of the distribution of the returns of the index using
> different methods. 

  OK, but this still isn't a *reproducible* example (see e.g.
http://tinyurl.com/reproducible-000 )
 
> I need the mle and i found this two function and i could not
> understand why the result were different: it's possibile that i
> obtain different result because in the mle() i don't need to know
> the original distribution and in the fitdistr() i don't need to know
> the function i had to maximize?

  In your example fitdistr() and mle() are doing the same thing under
the hood, i.e.  using the built-in optim() function to minimize a
negative log-likelihood function based on the built-in dnorm().
fitdistr() picks the distribution for you based on your specification
of which distribution to use; mle() requires you to specify the
negative log-likelihood function (the mle2() function in the bbmle
package is an extension of stats4::mle that offers a middle ground,
e.g. you can say y ~ dnorm(mu,sigma) to specify the fit of a Normal
distribution).  The differences between the results you get will be
based on small numerical differences, e.g. the starting values of the
parameters, or differences in the control parameters for optimization.
In general you should get very similar, but not necessarily identical,
answers from these two functions; big differences would probably
indicate some kind of wonky data or numerical problem.  Again, we
would need a reproducible example to see precisely what is going on.



More information about the R-help mailing list