title: How to create a loop for a linear model in R
body: <p>I am here to ask your help.
  I have to run a series of OLS regression on multiple depended variable using the same set for the independent ones. </p>
  
  <p>I.e. I have a dataframe of size (1510x5), in particular each one represent the return of a portfolio, and I would like to regress it agains the same set of dependent variable (1510x4), which in my case are the factors from the Carhart model. Since, beside the value for the coefficients, I am interested in both their P-value and on the R2 of the regression, is there a way to build a loop that allows me to store the information?</p>
  
  <p>What I have tried so far is:</p>
  
  <pre><code>for (i in 1:ncol(EW_Portfolio)) {
    lmfit &lt;- lm(EW_Portfolio[, i] ~ FFM)
    summary(lmfit_i)
  }
  </code></pre>
  
  <p>in the hope that, every time the loop repeated itself, I could see the result of each individual regression.</p>