0
$\begingroup$

I generated set of random proportions using rnorm() function with mean=0.5 and standard deviation = 0.12. I get the below vector of proportions.

[0.59 0.66 0.65 0.67 0.40 0.26 0.46 0.46 0.53 0.66 0.51 0.58 0.45 0.47 0.64 0.62 0.60 0.34 0.40 0.38]

Then I re-estimated the mean and variance using R optim() function. Here, x is the above generated proportions.

foo <- function(par, x) -sum(dnorm(x, par[1], par[2], log=TRUE))

start<- c(0.1,0.1)

x <-c(0.59,0.66,0.65,0.67,0.40,0.26,0.46,0.46,0.53,0.66,0.51,0.58,0.45,0.47,0.64,0.62,0.60,0.34,0.40,0.38)

optim(start, foo, lower=c(0.01,0.01), upper=c(1,1), method="L-BFGS-B", x=x)

The output:

$par
[1] 0.5165004 0.1185091

$value
[1] -14.27772

$counts
function gradient 
      55       55 

$convergence
[1] 0

$message
[1] "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH"

My question is why do I get a negative $value (-14.27772) for as the maximum value of negative log-likelihood? because log-likelihood suppose to be a negative value so, maximum value of negative log-likelihood has to be a positive isn't it?. Appreciate your comments.

$\endgroup$
2
  • 3
    $\begingroup$ The log likelihood does not have to be negative for continuous variables. A Normal variate with a small standard deviation, such as you have, can easily have a positive log likelihood. Consider the value 0.59 in your example; the log of its likelihood is 0.92. Furthermore, you want to maximize the log likelihood, not maximize the negative of the log likelihood. Maximizing the negative of the log likelihood is equivalent to minimizing the likelihood, and why would we want to do that? As it happens, optim minimizes as its default, so everything worked out for you. $\endgroup$
    – jbowman
    Dec 14, 2017 at 5:21
  • $\begingroup$ @jbowman: do you want to post your excellent comment as an answer? $\endgroup$ Dec 14, 2017 at 6:41

1 Answer 1

3
$\begingroup$

A couple of points:

The log likelihood does not have to be negative for continuous variables. A Normal variate with a small standard deviation, such as you have, can easily have a positive log likelihood. Consider the value 0.59 in your example; the log of its likelihood is 0.92. (For discrete variables, it's a different story; unless the probability of one event equals one, all the probabilities will be less than 1, leading to negative logs.)

Furthermore, you want to maximize the log likelihood, not maximize the negative of the log likelihood. Maximizing the negative of the log likelihood is equivalent to minimizing the likelihood, and why would we want to do that? As it happens, optim minimizes as its default, so everything worked out for you - as looking at your parameter estimates and comparing them to the actual parameter values will show.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.