title: how to organize the final table to simulate maximum likelihood in r with different sample sizes?
body: <p>I do a simulation using R program but I cannot to organize/make the final table in R.</p>
  <pre><code>rep=100
  n=20
  
  # define starting values 
  mu&lt;-100
  sig&lt;-3
  theta=c(mu,sig) # store starting values
  
  #Tables
  #********
  
  LHE=array(0, c(2, rep));
  rownames(LHE)= c(&quot;MLE_mu&quot;, &quot;MLE_sigma&quot;)
  
  bias= array(0, c(2, rep));
  rownames(bias)= c(&quot;bias_mu&quot;, &quot;bias_sigma&quot;)
  
  #Simulation {FOR LOOP}
  #***********************
  set.seed(1)
  
  for(i in 1:rep){
    myx &lt;- rnorm(100, 100, 3)  
  
    loglikenorm&lt;-function(x, myx) # always use x to hold parameter values
    {
      mu&lt;-x[1]
      sig&lt;-x[2]
      n&lt;-length(myx)
      loglike&lt;- -n*log(sig*sqrt(2*pi))- sum((1/(2*sig^2))*(myx-mu)^2) # note
      # use of sum
      loglike&lt;- -loglike
    }
    
    result&lt;-nlm(loglikenorm, theta , myx=myx, hessian=TRUE, print.level=1) #ML estimation using nlm
    mle&lt;-result$estimate #extract and store mles
    LHE[,i]=  c(mle[1], mle[2])
    bias[,i]= c(mle[1]-theta[1], mle[2]-theta[2])
  } # end for i
  
  L &lt;-round(apply(LHE, 1, mean), 3) # MLE  of all the applied iterations  
  
  bs &lt;-round(apply(bias,1, mean),3) # bias of all the applied iterations 
  row&lt;- c(L, bs); row
  </code></pre>
  <p>This will run the MLE 100 times. I want to compute the MLE for different sample sizes (n=20,50,100) and different set of parameters <code>c(c(mu= 100, sigma=3), c(mu=80 , sigma=4))</code></p>
  <p>I want two things the first one is how to run the code to compute the MLE for different sample sizes and different sets of parameters. The second one how can I organize the output (like the attached image) using R program.</p>
  <p><a href="https://i.stack.imgur.com/SD7Zt.jpg" rel="nofollow noreferrer">The final table from R</a></p>
  <p>Any help will be appreciated.</p>