title: Regression in a loop but get "Error in coef(summary(fit))[2, 4] : subscript out of bounds"
body: <p>When running the following code on a high dimensional dataset I get the error message</p>
  
  <blockquote>
    <p>Error in coef(summary(fit))[2, 4] : subscript out of bounds</p>
  </blockquote>
  
  <p>The vector <code>beta</code> which the p-values of the logistic regression models are saved to has length 19481. If I loop through the different independent variables of the regression model up to 100 times I do not get this error.</p>
  
  <p>Could anyone give me hint why my code does not run smoothly?     </p>
  
  <pre><code>beta = rep(0, 19481)
  for (i in 25:19505) {
    fit = glm(mdr.mdr ~ an.mdr[,i], family=binomial)
    beta[i-24] = coef(summary(fit))[2,4]
    }
  </code></pre>