title: How can I calculate standard errors using bootstrap in R?
body: <p>I have a matrix "num" containing explanatory variables with the following sample data:</p>
  
  <pre><code>Intercept   Num1   Num2  Num3
  1           1.20   0     5.46
  1           2.39   1     2.95
  1           1.93   1     13.44
  1           1.30   0     3.05
  1           2.37   1     3.55
  </code></pre>
  
  <p>I also have a matrix "succ" containing the dependent variable with the following sample data:</p>
  
  <pre><code>succ
  2.69
  -0.71
  1.96
  -6.95
  2.61
  </code></pre>
  
  <p>I am running a regression of succ on num. I am trying to create a bootstrap function to calculate the standard errors of the regression for each explanatory variable, to see how different the standard errors are compared to the linear regression. I do not want to use the "boot" package.</p>
  
  <p>I've tried creating the following function: </p>
  
  <pre><code>custom.boot &lt;- function(times, data) {
    boots &lt;- rep(NA, times)
    for (i in 1:times) {
      boots[i] &lt;- sd(sample(data, length(data), 
                     replace=TRUE)/sqrt(length(data)))  
    }
    boots
  }
  </code></pre>
  
  <p>However, I am stuck here as I know that I will not get the values I need if I just run</p>
  
  <pre><code>custom.boot(1000, num)
  </code></pre>
  
  <p>I would like to just receive an output like:</p>
  
  <pre><code>var        std. errors
  Intercept  ###
  Num1       ###
  Num2       ###
  Num3       ###
  </code></pre>
  
  <p>Per bootstrap methodology, these should slightly differ based on the number of replications that I run. What do I need to change in my code to get this output?</p>