[R] Optim function in the loop
Rstarer
bozhao86 at hotmail.com
Mon May 4 21:02:03 CEST 2009
Thanks for the reply.
optim(initpar,Linn,NULL,method="BFGS",hessian=TRUE,control=list(trace=1,REPORT=1,maxit=300))
The optim is to minimize the negative likelihood function which is performed
in function "Linn",
Every time the code stops right after optim, for example, the output looks
like:
"
iter 16 value 42.818394
iter 16 value 42.818394
final value 42.818394
converged
>
"
It seems from the code that the loop should continue to run, at least
calculate "u" values... but it does not...
Thank you.
Hi all,
I wrote the following lines of codes try to do some iterations to find the
global optimal values, but the function does not execute properly. Every
time codes stop after one iteration right after executing the optim()
function. Does anyone could have me to take a look? Thanks.
if (count>0){
k=k+0.05;
mu0=c(83+k,0,0)
Sigma0= diag(0.4,3)
initpar=c(.1+10*k,10*k,10*k,10*k) # initial parameters for Phi[1,1], the 2
Q’s and R
est=optim(initpar,Linn,NULL,method="BFGS",hessian=TRUE,control=list(trace=1,REPORT=1,maxit=300))
stderr=sqrt(diag(solve(est$hessian)))
estimate=est$par
u=cbind(estimate,stderr)
if (u[1]>0 & u[2]>0 & u[3]>0 & u[4]>0){
print("mu0=");print(mu0);
print("initpar=");print(initpar)
#break
} else {count=-1;
}
}
--
View this message in context: http://www.nabble.com/Optim-function-in-the-loop-tp23352044p23374525.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list