I have one last theoretical question, I did not adjust my code prior so that it maximise the likehood function. I googled that to make optim maximise you multiply fn by -1.
In my code, would that be the same as saying "-sum" on the "sum" part of my code (see below)? llik = function(x) { al_j=x[1]; au_j=x[2]; sigma_j=x[3]; b_j=x[4] sum(na.rm=T, ifelse(a$R_j< 0, log(1 / ( sqrt(2*pi) * sigma_j) )- -- View this message in context: http://r.789695.n4.nabble.com/loop-in-optim-tp3643230p3650592.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.