Re: [R] Parameters setting in functions optimization

2011-11-30 Thread Diane Bailleul
Dear Florent, I know that I'm asking to optim to minimize my values, and that the results with a lower fvalue are best supported than those with a higher fvalue. My comment was just from a data point of view. I'd like the lower ms (second parameter) as possible, as well as the fvalue. So a ms o

Re: [R] Parameters setting in functions optimization

2011-11-30 Thread John C Nash
optimx does allow you to use bounds. The default is using only methods from optim(), but even though I had a large hand in those methods, and they work quite well, there are other tools available within optimx that should be more appropriate for your problem. For example, the current version of

Re: [R] Parameters setting in functions optimization

2011-11-30 Thread Florent D.
With optimx(c(30,50),ms=c(0.4,0.5), fn=LogLiketot) where LogLiketot<- function(dist,ms) { res <- NULL for(i in 1:nrow(pop5)) { for(l in 1:nrow(freqvar)) { res <- c(res, pop5[i,l]*log(LikeGi(l,i,dist,ms))) } } return(-sum(res)) } I think it will do something l

Re: [R] Parameters setting in functions optimization

2011-11-30 Thread Diane Bailleul
Le 11/30/2011 2:09 AM, Florent D. a écrit : Thanks for your answer ! I also think your last write-up for LogLiketot (using a single argument "par") is the correct approach if you want to feed it to optim(). I'm not dedicated to optim() fonction. I just want to optimise my two parameters and the

Re: [R] Parameters setting in functions optimization

2011-11-29 Thread Florent D.
Oh, and your message: In log(LikeGi(l, i, par[1], par[2])) : NaNs produced means your LikeGi is returning something negative. Can't take the log of it... On Tue, Nov 29, 2011 at 8:09 PM, Florent D. wrote: > I also think your last write-up for LogLiketot (using a single > argument "par") is the

Re: [R] Parameters setting in functions optimization

2011-11-29 Thread Florent D.
I also think your last write-up for LogLiketot (using a single argument "par") is the correct approach if you want to feed it to optim(). So now you have a problem with log(LikeGi(l, i, par[1], par[2])) for some values of par[1] and par[2]. Where is LikeGi coming from? a package or is it your ow