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.