Hello,

In the following code, I need to calculate parameters
par_1,par_2,par_3,seperately for all the rows in casted data-frame .

how may I avoid the for loop because it is taking too much time , as in I
want to calculate optimized parameters(initial values 0.2,0.25,0.3 ,,, so
that I get parameters as a data-frame with nrows(parameters)=nrows(casted)
...


Thanks,


for (i in 1:nrow(casted))

{

  iter_df <- casted[i,]

  parameters <-
optim(c(0.2,0.25,0.3),opt_UD,data=iter_df,method="L-BFGS-B",lower=c(0,0,0),upper=c(1,1,1))

  iter_df$par_1 <- parameters$par[1]

  iter_df$par_2 <- parameters$par[2]

  iter_df$par_3 <- parameters$par[3]

  new_df <- rbind(new_df,iter_df)

  #print (i)

}

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to