Re: [R] Maximization under constraits

From: Ben Bolker <>
Date: Fri, 25 Jul 2008 17:32:33 +0000 (UTC)

Daniela Garavaglia <danygaravaglia84 <at>> writes:

> I'm looking for a R function which can maximise this logliklihood function,
> under the constraits a>0 e b>0
> f<-function(param){
> a<-param[1]
> b <-param[2]
> log(prod)-(a*s2)-(b*s)-n*log(1-((0.5*b/sqrt(a))*(exp((b^2)/(4*a)))*((sqrt(pi
> ))*(1-pnorm(-b/(2*sqrt(a)), mean=0, sd=1)))))}

  If you're really just looking for "box constraints" (independent inequalities on different parameters) then optim(...,method="L-BFGS-B", lower=c(0,0)) should work fine [or maybe lower=c(0.002,0.002) if you want to make absolutely sure you don't hit the boundaries]

  If you use stats4::mle or bbmle::mle2 (which are both wrappers for optim(), so the advice above applies) you will be able to do a little bit more with the results -- e.g. draw profiles and get profile confidence intervals

  Ben Bolker mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 25 Jul 2008 - 17:38:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 25 Jul 2008 - 18:32:24 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive