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)
out
eigen(out$hessian)
Hope this is helpful,
Ravi
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
410-502-2619
[[alternative HTML version deleted]]
Thank you very much prof. Ravi, That was very helpful. Is there a way to get the t and p value for the coefficients? Thanks Alaa> On Mar 2, 2016, at 10:05 AM, Ravi Varadhan <ravi.varadhan at jhu.edu> wrote: > > 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) > > out > > eigen(out$hessian) > > > Hope this is helpful, > Ravi > > > > 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 > 410-502-2619 >[[alternative HTML version deleted]]
Standard error = sqrt(diag(solve(opt$hessian)))
Ravi
From: Alaa Sindi [mailto:alaasindi at icloud.com]
Sent: Wednesday, March 02, 2016 3:22 PM
To: Ravi Varadhan <ravi.varadhan at jhu.edu>
Cc: r-help at r-project.org
Subject: Re: help in maximum likelihood
Thank you very much prof. Ravi,
That was very helpful. Is there a way to get the t and p value for the
coefficients?
Thanks
Alaa
On Mar 2, 2016, at 10:05 AM, Ravi Varadhan <ravi.varadhan at
jhu.edu<mailto:ravi.varadhan at jhu.edu>> wrote:
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)
out
eigen(out$hessian)
Hope this is helpful,
Ravi
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
410-502-2619
[[alternative HTML version deleted]]