title: In Optim function, print out parameter input in R
body: <p>I have a function called est_Bt()</p>
  
  <pre><code>est_Bt = function(pars)
  {
      exp_Bt &lt;- rep(NA,length(prawn_df$Catch))
      exp_Bt[1] &lt;- pars[4]
      for(i in 2:length(prawn_df$Catch))
      {
          exp_Bt[i] &lt;- max(exp_Bt[i-1] + exp_Bt[i-1]* (pars[1]/pars[3]) * (1-((exp_Bt[i-1]/pars[2])^pars[3])) - prawn_df$Catch[i-1],100)
      }### Not we put the max to either bt+1 or 100 so the stock doesn't go extinct.
      cpue_obs &lt;- prawn_df$Catch/prawn_df$Effort
      pred_q &lt;- log(cpue_obs/exp_Bt)
      series &lt;- 0:(nrow(prawn_df)-1)
      q_int &lt;- as.vector(lsfit(series,pred_q)$coefficients)[1]
      q_stat &lt;- as.vector(lsfit(series,pred_q)$coefficients)[2]
      qinc_int &lt;- exp(q_int)
      qinc_stat &lt;- exp(q_stat)
      q &lt;- rep(NA, length(series))
      q[1] &lt;- qinc_int
      for(i in 2:length(q)){
          q[i] &lt;- q[i-1]* qinc_stat
      }
      pred_cpue &lt;- pred_bt* q
      sum((log(cpue_obs) - log(pred_cpue))^2)
  }
  </code></pre>
  
  <p>The Function is not important itself what I would like help is when evaluating pars using the function optim() I was wondering if there is a command for printing out trialing parameters. The function gives the sum of squares for applying a fisheries surplus model to Catch effort data. </p>
  
  <pre><code>est_Bt(c(0.2,30000, 0.0000000001, 50000))
  [1] 159.2381
  est_Bt(c(0.32,27000, 0.0000000001, 45000))
  [1] 67.45901
  </code></pre>
  
  <p>when I use optim however I get</p>
  
  <pre><code>optim(c(0.32,27000, 0.0000000001, 45000), est_Bt)
  Error in lsfit(series, pred_q) : NA/NaN/Inf in 'y'
  In addition: Warning message:
  In lsfit(series, pred_q) : 26 missing values deleted
  </code></pre>
  
  <p>My thoughts on this are that it is testing a parameter value that is nonsense and the function is failing. And I'm sure that I should know my equation to penalise for ridiculous parameter values. But I thought that if optim could print out the parameter values each trial then it would help me explore the parameter interactions in my model? </p>
  
  <p>Chairs Cyrill</p>