[R] Optimize multiple variable sets

sandra lag sdlag at hotmail.com
Mon Dec 6 13:00:57 CET 2010

I usually use optimize function for ML Estimation. Now I´ve got a data frame with many sets, but I can´t save estimates each time I run the code for each data set (I´m using a for loop with my loglikelihood function and works ok but when I apply another for loop to:
optimize(my.loglikelihood.function[i], int=c(0.0001,10))
it doesn´t work;

alternatively, using optimize inside the for loop (like in the example below), it returns always the same value, which is not expected:

data<-matrix(c(1,1,1, 2,2,2, 3,3,3, 4,4,4), nrow=3, ncol=4)
for (i in 1:c){
results[i]<-optimize(f,int=c(0.0001,10))[1] #minimum

Can someone please indicate me if there´s a different function/ way to do so? (with no need of initial parameter values)
Thanks! Sandra 		 	   		  

More information about the R-help mailing list