[R] optimization in for loop

siriustar qinlangjinan at live.cn
Wed Jun 29 20:31:36 CEST 2011


Hi, dear R help
I am trying to use optim inside a for loop:

##For example. a: intial guess.  b: result.  f: function to be minimized 
for (i in 1:10) {
  b[i] <- optim(a[i], f)}

However, some intial values cause error in optim function (e.g. " system is
computationally singular..."). Then the for loop stops and won't try the
following initial guesses. 

What can I do if I want the for loop procedure to finish all the initial
guesses? I know this may be a stupid question.. but I am not familar with R
optim. So thankyou very much for any help..

Sirius

--
View this message in context: http://r.789695.n4.nabble.com/optimization-in-for-loop-tp3633638p3633638.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list