title: append values by dataframe row in a loop
body: <p>I'm running models with various initial values, and I'm trying to append values (3 estimators) by rows to a dataframe in a loop. I assign values to estimators within the loop, but I can't recall them to produce a dataframe.</p>
  
  <p>My code: <code>f</code> is the model for the estimation. Three parameters: alpha, rho, and lambda in the model. I want to output these 3 values.</p>
  
  <pre><code>library("maxLik")
  
  f &lt;- function(param) {
      alpha &lt;- param[1]
      rho &lt;- param[2]
      lambda &lt;- param[3]
      u &lt;- 0.5 * (dataset$v_50_1)^alpha - 0.5 * lambda * (dataset$v_50_2)^alpha
      p &lt;- 1/(1 + exp(-rho * u))
      logl &lt;- sum(dataset$gamble * log(p) + (1 - dataset$gamble) * log(1 - p))
  }
  
  
  df &lt;- data.frame(alpha = numeric(), rho = numeric(), lambda = numeric())
  
  for (j in 1:20) {
      tryCatch({
          ml &lt;- maxLik(f, start = c(alpha = runif(1, 0, 2), rho = runif(1, 0, 4), lambda = runif(1, 
              0, 10)), method = "NM")
  
          alpha[j] &lt;- ml$estimate[1]
          rho[j] &lt;- ml$estimate[2]
          lambda[j] &lt;- ml$estimate[3]
  
      }, error = function(e) {NA})
  }
  output &lt;- data.frame(alpha, rho, lambda)
  </code></pre>
  
  <p>error occurs:</p>
  
  <pre><code> Error in data.frame(alpha, rho, lambda) : object 'alpha' not found
  </code></pre>
  
  <p>Expected output</p>
  
  <pre><code> alpha    rho    lambda
    0.4      1       2      # estimators append by row. 
    0.6      1.1     3      # each row has estimators that are estimated 
    0.7      1.5     4      # by one set of initial values, there are 20 
                            # rows, as the estimation loops for 20 times.
  </code></pre>