Sample covariates using multivariate imputation using chained equations (mice)
sample_covariates_mice.RdIn contrast to sampling methods bootstrap and NHANES, categorical covariates
need to be specified using the cat_covs argument, otherwise they will be
treated as continuous.
Usage
sample_covariates_mice(
data,
cat_covs = NULL,
conditional = NULL,
n_subjects = nrow(data),
cont_method = "pmm",
replicates = 1,
seed = NULL,
...
)Arguments
- data
data.frame (n x p) containing the original, observed, time-invariant covariates (ID should not be included) that will be used to inform the imputation.
- cat_covs
character vector containing the names of the categorical covariates in orgCovs.
- conditional
list with conditional limits for sampled population. For continuous covariates, specify a numeric vector of length 2 giving the
c(min, max)range, e.g.list("WT" = c(40, 60), "BMI" = c(15, 25)). For categorical covariates (those listed incat_covs), specify a character vector of the allowed category values, e.g.list("SEX" = c("F")).- n_subjects
number of simulated subjects, default is the number of subjects in the data.
- cont_method
method used to predict continuous covariates within mice, default is
pmm.- replicates
number of multiple imputations replicates to sample. Default is 1.
- seed
integer random seed passed to
set.seed()for reproducibility. DefaultNULLdoes not set a seed.- ...
additional arguments passed to
mice::mice()function