This is a duplicate of https://stats.stackexchange.com/questions/293988/logistic-regression-how-to-try-every-combination-of-predictors.
I want to perform a logistic
There's a package that does this, MuMIn (multimodel inference), as part of a more principled multi-model approach (i.e. it doesn't just pick the best model(s) and ignore the fact that selection has been done):
Set up data and full model:
set.seed(101)
d <- data.frame(replicate(5,rnorm(100)))
d$y <- rbinom(100,size=1,prob=0.5)
full <- glm(y~.,data=d,na.action=na.fail)
"dredge" the result:
library(MuMIn)
allfits <- dredge(full)
results (also contains all fitted parameters):
head(allfits[,7:11])
## df logLik AICc delta weight
## 3 3 -69.66403 145.5781 0.000000 0.15916685
## 11 4 -69.22909 146.8792 1.301191 0.08304293
## 19 4 -69.30856 147.0382 1.460123 0.07669921
## 7 4 -69.31233 147.0457 1.467655 0.07641093
## 4 4 -69.40589 147.2328 1.654775 0.06958615
## 1 2 -72.07662 148.2769 2.698896 0.04128523