title: Need to run a regression 1000 times
body: <p>I have a regression function called reg. I now need to run it 1000 times , capture the Rsquare value and t-stat in a histogram.</p>
  
  <p>I tried running replicate as follows ( have taken n=5, to see results):</p>
  
  <pre><code>replicate(5,{
    seriese=matrix( rnorm(100*1,mean=0,sd=1), 100, 1) 
    e &lt;- matrix(ncol = 1, nrow = 100) 
    for(i in 1:100){
      e[i] &lt;- sum(seriese[1:i,1]) 
    } 
    dataY &lt;- cbind(seriese, e) 
    seriesa=matrix( rnorm(100*1,mean=0,sd=1), 100, 1) 
    x &lt;- matrix(ncol = 1, nrow = 100) 
    for(i in 1:100){ 
      x[i] &lt;- sum(seriesa[1:i,1]) 
    }
    dataX &lt;- cbind(seriesa, x) 
    #convert to ts
    dataYTS=ts(dataY[,2]) 
    dataXTS=ts(dataX[,2]) 
    #run regression 
    #check summary regression 
    reg=lm(dataYTS~dataXTS) 
  },simplify=FALSE) 
  </code></pre>
  
  <p>This reports the type of data, not the values.</p>
  
  <pre><code>replicate(5,{reg=lm(dataYTS~dataXTS)})
                [,1]        [,2]        [,3]        [,4]        [,5]       
  coefficients  Numeric,2   Numeric,2   Numeric,2   Numeric,2   Numeric,2  
  residuals     Numeric,100 Numeric,100 Numeric,100 Numeric,100 Numeric,100
  effects       Numeric,100 Numeric,100 Numeric,100 Numeric,100 Numeric,100
  rank          2           2           2           2           2          
  fitted.values Numeric,100 Numeric,100 Numeric,100 Numeric,100 Numeric,100
  assign        Integer,2   Integer,2   Integer,2   Integer,2   Integer,2  
  qr            List,5      List,5      List,5      List,5      List,5     
  df.residual   98          98          98          98          98         
  xlevels       List,0      List,0      List,0      List,0      List,0     
  call          Expression  Expression  Expression  Expression  Expression 
  terms         Expression  Expression  Expression  Expression  Expression 
  model         List,2      List,2      List,2      List,2      List,2     
  </code></pre>