Description Usage Arguments Value Examples
View source: R/mice.impute.bygroup.R
The function mice.impute.bygroup
performs groupwise imputation for arbitrary
imputation methods defined in mice.
1 | mice.impute.bygroup(y, ry, x, group, imputationFunction, ...)
|
y |
Incomplete data vector of length |
ry |
Vector of missing data pattern ( |
x |
Matrix ( |
group |
Name of grouping variable |
imputationFunction |
Imputation method for mice |
... |
More arguments to be passed to imputation function |
Vector of imputed values
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ## Not run:
#############################################################################
# EXAMPLE 1: Cluster-specific imputation for some variables
#############################################################################
data( data.ma01 )
dat <- data.ma01
# use sub-dataset
dat <- dat[ dat$idschool <= 1006 , ]
V <- ncol(dat)
# create initial predictor matrix and imputation methods
predictorMatrix <- matrix( 1 , nrow=V , ncol=V)
diag(predictorMatrix) <- 0
rownames(predictorMatrix) <- colnames(predictorMatrix) <- colnames(dat)
predictorMatrix[ , c("idstud", "studwgt","urban" ) ] <- 0
imputationMethod <- rep("norm" , V)
names(imputationMethod) <- colnames(dat)
#** groupwise imputation of variable books
imputationMethod["books"] <- "bygroup"
# specify name of the grouping variable ('idschool') and imputation method ('norm')
group <- list( "books" = "idschool" )
imputationFunction <- list("books" = "norm" )
#** conduct multiple imputation in mice
imp <- mice::mice( dat, imputationMethod=imputationMethod, predictorMatrix=predictorMatrix,
m=1 , maxit=1 , group = group , imputationFunction = imputationFunction )
## End(Not run)
|
Loading required package: mice
* miceadds 2.7-19 (2017-08-24 17:34:44)
iter imp variable
1 1 math read migrant books hisei paredu
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.