Skip to content

help in maximum likelihood

2 messages · Alaa Sindi, John C Nash

#
Hi all,

what is wrong with this code? I am trying to estimate the model parameters by maximizing the likelihood function and I am getting this warning 


Warning message:
In nlm(fn, p = c(-50, 20), hessian = TRUE) :
  NA/Inf replaced by maximum positive value




x <- c(1.6907, 1.7242, 1.7552, 1.7842, 1.8113, 1.8369, 1.8610, 1.8839)
y <- c( 6, 13, 18, 28, 52, 53, 61, 60)
n <- c(59, 60, 62, 56, 63, 59, 62, 60)
fn <- function(p)
    sum( - (y*(p[1]+p[2]*x) - n*log(1+exp(p[1]+p[2]*x))
            + log(choose(n, y)) ))
out <- nlm(fn, p = c(-50,20), hessian = TRUE)


Thanks
#
It's useful to add "print.level=2" inside your call to find that there's
essentially nothing wrong.

Rvmmin doesn't give the msg and numDeriv gives a similar (BUT NOT
EXACTLY THE SAME!) hessian estimate.

It's almost always worthwhile turning on the diagnostic printing when
doing optimization, even if you throw away the output pretty well right
away, because it can often suggest whether the results are reasonable or
rubbish.

JN
On 16-03-01 03:09 PM, Alaa Sindi wrote: