# NOT RUN {
### To compare two linear models:
imp <- mice(nhanes2, seed = 51009, print = FALSE)
mi1 <- with(data = imp, expr = lm(bmi ~ age + hyp + chl))
mi0 <- with(data = imp, expr = lm(bmi ~ age + hyp))
pc <- pool.compare(mi1, mi0)
pc$pvalue
### Comparison of two general linear models (logistic regression).
# }
# NOT RUN {
imp <- mice(boys, maxit = 2, print = FALSE)
fit1 <- with(imp, glm(gen > levels(gen)[1] ~ hgt + hc + reg, family = binomial))
fit0 <- with(imp, glm(gen > levels(gen)[1] ~ hgt + hc, family = binomial))
pool.compare(fit1, fit0, method = 'likelihood')$pvalue
# using factors
fit1 <- with(imp, glm(as.factor(gen > levels(gen)[1]) ~ hgt + hc + reg, family = binomial))
fit0 <- with(imp, glm(as.factor(gen > levels(gen)[1]) ~ hgt + hc, family = binomial))
pool.compare(fit1, fit0, method = 'likelihood')$pvalue
# }
Run the code above in your browser using DataLab