Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mice.impute.grouped

Imputation of a Variable with Grouped Values


Description

Imputes a variable with continuous values whose original values are only available as grouped values.

Usage

mice.impute.grouped(y, ry, x, low=NULL, upp=NULL,  ...)

Arguments

y

Incomplete data vector of length n

ry

Vector of missing data pattern (FALSE – missing, TRUE – observed)

x

Matrix (n x p) of complete covariates.

low

Vector with lower bound of grouping interval

upp

Vector with upper bound of grouping interval

...

Further arguments to be passed

Value

A vector of length nmis=sum(!ry) with imputed values.

See Also

This function uses the grouped::grouped function in the grouped package.

Examples

## Not run: 
#############################################################################
# EXAMPLE 1: Imputation of grouped data
#############################################################################

data(data.ma06)
data <- data.ma06

# define the variable "FC_imp" which should contain the variables to be imputed
data$FC_imp <- NA
V <- ncol(data)
# variables not to be used for imputation
vars_elim <-  c("id", "FC","FC_low","FC_upp")

# define imputation methods
impM <- rep("norm", V)
names(impM) <- colnames(data)
impM[  vars_elim ] <- ""
impM[ "FC_imp" ] <- "grouped"

# define predictor matrix
predM <- 1 - diag( 0, V)
rownames(predM) <- colnames(predM) <- colnames(data)
predM[vars_elim, ] <- 0
predM[,vars_elim] <- 0

# define lower and upper boundaries of the grouping intervals
low <- list("FC_imp"=data$FC_low )
upp <- list("FC_imp"=data$FC_upp )

# perform imputation
imp <- mice::mice( data, method=impM, predictorMatrix=predM,
        m=1, maxit=3, allow.na=TRUE,  low=low, upp=upp)
head( mice::complete(imp))

## End(Not run)

miceadds

Some Additional Multiple Imputation Functions, Especially for 'mice'

v3.11-6
GPL (>= 2)
Authors
Alexander Robitzsch [aut,cre] (<https://orcid.org/0000-0002-8226-3132>), Simon Grund [aut] (<https://orcid.org/0000-0002-1290-8986>), Thorsten Henke [ctb]
Initial release
2021-01-21 11:48:47

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.