This previous question "How to repeatedly perform glm over multiple dependent variables after mice?" - did not work for me. I don't understand how it incorporates the pooling of the mids.
######################
I need to repeat logistic regression for 7 dependent variables, using the same 5 predictor variables for each regression.
I need to do multiple imputation using mice before I perform the regressions.
I then need an output of exponentiated odds ratios and confidence intervals for each of the dependent variables.
Here is a smaller example:
P1 <- c(7,8,5,NA)
P2 <- c(10,12,11,12)
P3 <- c(1,1,0,1)
P4 <- c(1,1,1,0)
R1 <- c(0,1,0,1)
R2 <- c(0,0,1,0)
R3 <- c(1,1,0,0)
R4 <- c(0,1,1,1)
R5 <- c(1,0,1,0)
df1 <- data.frame(P1,P2,P3,P4,R1,R2,R3,R4,R5)
cols <- c("P3","P4","R1","R2","R3","R4","R5")
df1[cols] <- lapply(df1[cols], factor)
Multiple Imputation:
library(mice)
imp <- mice(df1, maxit=0)
predM <- imp$predictorMatrix
meth <- imp$method
imp2 <- mice(df1, maxit=5,
predictorMatrix = predM,
method = meth, print = F)
Logistic Regression after pooling imputed data:
m1.mi <- with(imp2, glm(R1 ~ P1 + P2 + P3 + P4, family=binomial(link=logit)))
summary(pool(m1.mi),exponentiate=TRUE, conf.int = TRUE)
Is there a way to create a loop, that will produce an odds ratio and CIs for each dependent variable?
Any help appreciated, I apologise for my very limited knowledge in this area.