Hi, 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) c<-dim(data)[2] results<-vector(length=c) for (i in 1:c){ f<-function(x){ x^2+x*sum(data[,i]) } results[i]<-optimize(f,int=c(0.0001,10))[1] #minimum } #results Can someone please indicate me if there´s a different function/ way to do so? (with no need of initial parameter values) Thanks! Sandra ______________________________________________ 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.