Learn R Programming

mice (version 3.4.0)

mice.impute.2l.bin: Imputation by a two-level logistic model using glmer

Description

Imputes univariate systematically and sporadically missing data using a two-level logistic model using lme4::glmer()

Usage

mice.impute.2l.bin(y, ry, x, type, wy = NULL, intercept = TRUE, ...)

Arguments

y

Vector to be imputed

ry

Logical vector of length length(y) indicating the the subset y[ry] of elements in y to which the imputation model is fitted. The ry generally distinguishes the observed (TRUE) and missing values (FALSE) in y.

x

Numeric design matrix with length(y) rows with predictors for y. Matrix x may have no missing values.

type

Vector of length ncol(x) identifying random and class variables. Random variables are identified by a '2'. The class variable (only one is allowed) is coded as '-2'. Fixed effects are indicated by a '1'.

wy

Logical vector of length length(y). A TRUE value indicates locations in y for which imputations are created.

intercept

Logical determining whether the intercept is automatically added.

Arguments passed down to glmer

Value

Vector with imputed data, same type as y, and of length sum(wy)

Details

Data are missing systematically if they have not been measured, e.g., in the case where we combine data from different sources. Data are missing sporadically if they have been partially observed.

References

Jolani S., Debray T.P.A., Koffijberg H., van Buuren S., Moons K.G.M. (2015). Imputation of systematically missing predictors in an individual participant data meta-analysis: a generalized approach using MICE. Statistics in Medicine, 34:1841-1863.

See Also

Other univariate 2l functions: mice.impute.2l.lmer, mice.impute.2l.norm, mice.impute.2l.pan

Examples

Run this code
# NOT RUN {
library(tidyr)
library(dplyr)
data("toenail", package = "HSAUR3")
data <- tidyr::complete(toenail, patientID, visit) %>% 
 tidyr::fill(treatment) %>% 
 dplyr::select(-time) %>%
 dplyr::mutate(patientID = as.integer(patientID))

# }
# NOT RUN {
pred <- mice(data, print = FALSE, maxit = 0, seed = 1)$pred
pred["outcome", "patientID"] <- -2
imp <- mice(data, method = "2l.bin", pred = pred, maxit = 1, m = 1, seed = 1)
# }

Run the code above in your browser using DataLab