When running the following code on a high dimensional dataset I get the error message
Error in coef(summary(fit))[2, 4] : subscript out of bounds
The vector beta
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.
Could anyone give me hint why my code does not run smoothly?
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]
}