title: How to fetch data from several linear regressions at the same time in R?
body: <p>First of all thanks in advance for your support, I am merely a beginner working with R and many questions I had could be answered on this forum already. However, I am stuck at one point where I could not find an answer on the forum already.</p>
  
  <p>I have a data panel with monthly returns of 770 stocks over five years as well as monthly return data of the MSCI World Index. In order to estimate the idiosyncratic firm risk perceived by the market, I want to use a simple market model and take the residual volatility as the proxy for the firm risk.</p>
  
  <p>Thus, I do 770 regressions of the indivdual stock against the MSCI with the following code:</p>
  
  <pre><code>returns &lt;- read.csv("/Returns.csv", header=TRUE, sep=";", dec=",")
  MSCI &lt;- returns[,772]
  for (j in 2:771)){
     assign(paste("a", j, sep = ""),lm(returns[,j]~MSCI))
     }
  </code></pre>
  
  <p>which gives me 770 regression outputs named a2, a3, ..., a771.</p>
  
  <p>I know that i get the residual volatility for a single regression by</p>
  
  <pre><code>sd(residuals(a2))
  </code></pre>
  
  <p>however, I am struggling to code a loop or something which results in the output of all 770 residual volatilities at the same time, which at best could also be used for export to excel or similar.</p>
  
  <p>Your help would really be greatly appreciated!</p>