[R] help in maximum likelihood

Ravi Varadhan ravi.varadhan at jhu.edu
Wed Mar 2 16:05:10 CET 2016

There is nothing wrong with the optimization.  It is a warning message.  However, this is a good example to show that one should not simply dismiss a warning before understanding what it means.  The MLE parameters are also large, indicating that there is something funky about the model or the data or both.  In your case, there is one major problem with the data:  for the highest dose (value of x), you have all subjects responding, i.e. y = n.  Even for the next lower dose, there is almost complete response.  Where do these data come from? Are they real or fake (simulated) data?

Also, take a look at the eigenvalues of the hessian at the solution.  You will see that there is some ill-conditioning, as the eigenvalues are widely separated.

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)

# note: there is no need to have the choose(n, y) term in the likelihood
fn <- function(p)
    sum( - (y*(p[1]+p[2]*x) - n*log(1+exp(p[1]+p[2]*x))) )

out <- nlm(fn, p = c(-50,20), hessian = TRUE)



Hope this is helpful,

Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg)
Associate Professor,  Department of Oncology
Division of Biostatistics & Bionformatics
Sidney Kimmel Comprehensive Cancer Center
Johns Hopkins University
550 N. Broadway, Suite 1111-E
Baltimore, MD 21205

	[[alternative HTML version deleted]]

More information about the R-help mailing list