Sunny2011
2011-Dec-29 06:47 UTC
[R] problem of "constrOptim.nl", no hessian and convergence values
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=5000000,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.
