# Re: [R] Likelihood returning inf values to optim(L-BFGS-B) other options?

From: Jin Huang <crystal_huangjin_at_yahoo.com.cn>
Date: Thu 05 Apr 2007 - 13:43:25 GMT

Hi,

I got this message sometimes too. Try to change the initial value and lower bound value and see if it works.

Jin

r@micom-solutions.de wrote:
Dear R-help list,

I am working on an optimization with R by evaluating a likelihood function that contains lots of Gamma calculations (BGNBD: Hardie Fader Lee 2005 Management Science). Since I am forced to implement lower bounds for the four parameters included in the model, I chose the optim() function mith L-BFGS-B as method. But the likelihood often returns inf-values which L-BFGS-B can't deal with.

Are there any other options to implement an optimization algorithm with R accounting for lower bounds and a four parameter-space?

Here is the error message I receive (german):

```--

> out=optim(c(.1,.1,.1,.1),fn,method="L-BFGS-B",lower=c(.0001,.0001,.0001,.0001,.0001))

Fehler in optim(c(0.1, 0.1, 0.1, 0.1), fn, method = "L-BFGS-B", lower
= c(1e-04, :
L-BFGS-B benötigt endliche Werte von 'fn'
Zusätzlich: Es gab 50 oder mehr Warnungen (Anzeige der ersten 50 mit
warnings())
--
And this is the likelihood function:
--
fn<-function(p) {
A1=(gamma(p[1]+x)*p[2]^p[1])/(gamma(p[1]))
A2=(gamma(p[3]+p[4])*gamma(p[4]+x))/(gamma(p[4])*gamma(p[3]+p[4]+x))
A3=(1/(p[2]+Tvec))^(p[1]+x)
A4=(p[3]/(p[4]+x-1))*((1/(p[2]+t_x))^(p[1]+x))
ll=sum(log(A1*A2*(A3+flag*A4)))
return(ll)
}

Best regards,

Michael

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
and provide commented, minimal, self-contained, reproducible code.

---------------------------------
Be a PS3 game guru.

[[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help