# true data
n <- 100
x <- rbinom(n,1,.45)
z <- ordered(rep(seq(1, 5),n)[sample(1:n, n)])
y <- rnorm(n)
group <- rep(1:10, 10)
# create artificial missingness
dat.xy <- data.frame(x, y, z)
dat.xy <- mi:::.create.missing(dat.xy, pct.mis=10)
# imputation
IMP <- mi(dat.xy, n.iter=6, add.noise=FALSE)
# fit models
M1 <- lm.mi(y ~ x + z, IMP)
display(M1)
coef(M1)
se.coef(M1)
M2 <- glm.mi(x ~ y , IMP, family = binomial(link="logit"))
display(M2)
coef(M2)
se.coef(M2)
M3 <- bayesglm.mi(x ~ y , IMP, family = binomial(link="logit"))
display(M3)
coef(M3)
se.coef(M3)
M4 <- polr.mi(ordered(z) ~ y, IMP)
display(M4)
coef(M4)
se.coef(M4)
M5 <- bayespolr.mi(ordered(z) ~ y, IMP)
display(M5)
coef(M5)
se.coef(M5)
M6 <- lmer.mi(y ~ x + (1|group), IMP)
display(M6)
coef(M6)
se.coef(M6)
M7 <- glmer.mi(x ~ y + (1|group), IMP, family = binomial(link="logit"))
display(M7)
coef(M7)
se.coef(M7)
Run the code above in your browser using DataLab