title: Optim() function error
body: <p>This is my code.</p>
  
  <pre><code>beta1 = function(a,b,t) { beta(a+(1/t),b) }
  beta2 = function(a,b,t) { beta(a+(2/t),b) }
  
  eb11 = function(a,b,t) { beta2(a,b,t)/beta(a,b) }
  eb12 = function(a,b,t) { (beta1(a,b,t)-beta2(a,b,t))/beta(a,b) }
  eb22 = function(a,b,t) { 1 + (beta2(a,b,t)-2*beta1(a,b,t))/beta(a,b) }
  
  eb11r11 = function(a,b,t) { beta2(a,b,t)*beta(a,b)/beta1(a,b,t)^2 }
  eb12r12 = function(a,b,t) { (beta1(a,b,t)-beta2(a,b,t))*beta(a,b)/beta1(a,b,t)/(beta(a,b)-beta1(a,b,t)) }
  eb22r22 = function(a,b,t) { (beta(a,b)^2 + (beta2(a,b,t)-2*beta1(a,b,t))*beta(a,b))/(beta(a,b)-beta1(a,b,t))^2 }
  
  gbetloglik = function(a,b,t) {
    loglik = n1*log(eb11r11(a,b,t)) + n2*log(eb12r12(a,b,t)) + n3*log(eb22r22(a,b,t))
    return(-loglik)
  }
  
  abt = optim(c(0.5,0.5,1),gbetloglik,lower=c(0.001,0.001,0.001),method="L-BFGS-B")$par
  </code></pre>
  
  <p>What I'd like to do is to find a,b, and t that maximize 'gbetloglik' function. 
  But I got this error.</p>
  
  <pre><code>Error in 2/t : 't' is missing
  </code></pre>
  
  <p>It seems that the third argument of function 'beta2' is missing. When I enter three numbers directly in gbetloglik function, it works well. The problem occurs only in optim() function.
  Does anyone have any idea?</p>