0
votes

I'm trying to get the MLE.

loglike <- function(theta) {
  ll <- 14 * log(1 - theta) + 12216 * log(theta)
  ll
}

neg.loglike <- function(theta) -loglike(theta)

mle(neg.loglike, start = list(theta = 0.5))

I'm getting the error

Error in optim(start, f, method = method, hessian = TRUE, ...) : 
  non-finite finite-difference value [1]
In addition: There were 37 warnings (use warnings() to see them)

I usually use the above code, but I found another function:

mle2(neg.loglike, start = list(theta = 0.5))

And it worked. Why isn't the other one working?

1

1 Answers

0
votes

The function mle uses the minimization method BFGS by default, which requires computing the Jacobian (and sometimes Hessian) of the log likelihood function. If you don't specify analytical functions for the Jacobian and Hessian, numerical issues can arise. This is exactly the error you get.

The function mle2 uses the minimization method Nelder-Mead by default, which does not rely on computing derivatives of the log likelihood function.

If you add method="Nelder-Mead" to your mle call, I suspect you will get the same result as with your mle2 call.

Please see https://www.rdocumentation.org/packages/bbmle/versions/1.0.23.1/topics/mle2 and https://www.rdocumentation.org/packages/stats4/versions/3.6.2/topics/mle for details.