[R] problem of constrOptim.nl, no hessian and convergence

2011-12-29 Thread Ravi Varadhan
Hi,

Use the `auglag' function in alabama if you want to get the Hessian at 
convergence.  This typically tends to perform better than `constrOptim.nl'.  
Also,  `constrOptim.nl' does not compute the Hessian.   You should not specify 
method=L-BFGS-B. The default method BFGS is better in this setting.

Hope this helps,
Ravi
---
Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins 
University

Ph. (410) 502-2619
email: rvarad...@jhmi.edumailto:rvarad...@jhmi.edu


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problem of constrOptim.nl, no hessian and convergence values

2011-12-28 Thread Sunny2011
Dear Helper,

I used constrOptim.nl and got the value of par. The estimations looks good
even if the number of iterations is only  16. But the values of hessian and
convergence are both NULL. 

I tested the objective function and gradient function by optim and didn't
see any problem there. With these functions, optim gives the convergence
value of 0.

Since constraints are necessary for the identifiability of my mode, I have
to switch to constrOptim.nl.

Following is my code of the constraint.  Could you please help me to check
is there anything wrong? 

Thank a lot!

# define the equality constraint
heq-function(par){
u-par[1:m]
a-par[(m+1):(m+n)]
b-par[(m+n+1):(m+2*n)]
h-rep(NA,2)
h[1]-mean(u)-0
h[2]-var(u)-1
h
}

heq.jac-function(par){
u-par[1:m]
a-par[(m+1):(m+n)]
b-par[(m+n+1):(m+2*n)]
j - matrix(NA, 2, length(par))
j[1,]-c(rep(1,m),rep(0,2*n))
j[2, ] - c(2/(m-1)*(u-mean(u)),rep(0,2*n))
j
}

# use optim
library(alabama)
myoptim-constrOptim.nl(par=par0, fn=obj, heq=heq, heq.jac=heq.jac,
control.outer=list(maxit=500,method=L-BFGS-B))



--
View this message in context: 
http://r.789695.n4.nabble.com/problem-of-constrOptim-nl-no-hessian-and-convergence-values-tp4242031p4242031.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.