R optim() L-BFGS-B needs finite values of 'fn' - Weibull
<p>I try to estimate the three parameters a, b0 and b1 with the <code>optim()</code> function. But I always get the error: 
Error in optim(par = c(1, 1, 1), fn = logweibull, method = "L-BFGS-B",  : 
L-BFGS-B needs finite values of 'fn'</p>

<pre><code>t&lt;-c(6,6,6,6,7,9,10,10,11,13,16,17,19,20,22,23,25,32,32,34,35,1,1,2,2,3,4,4,5,5,8,8,8,8,11,11,12,12,15,17,22,23)
d&lt;-c(0,1,1,1,1,0,0,1,0,1,1,0,0,0,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
X&lt;-c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)

logweibull &lt;- function (a,b0,b1) {a &lt;- v[1];b0 &lt;- v[2]; b1 &lt;- v[3];
sum (d*log(t^a*exp(b0+X*b1)-t^a*exp(b0+X*b1))) + sum (d + log((a*t^(a-1))/t^a)) }

v&lt;-c(1,1,1)

optim( par=c(1,1,1) ,fn = logweibull, method = "L-BFGS-B",lower = c(0.1, 0.1,0.1), upper = c(100, 100,100),control = list(fnscale = -1) )
</code></pre>

<p>Can you help me? Do you know what I did wrong?</p>