Description Usage Arguments Details Value Functions Author(s) Examples
Plug the imputations obtained with multilevelLCMI into the original dataset, in order to obtain a completed dataset.
A package for the multiple imputation of single-level and nested categorical data by means of Bayesian Multilevel Latent Class models.
1 |
convData |
Ouptut list produced by the 'convData' function |
implev1 |
The set of imputations for the level-1 variables provided by the 'multilevelLCMI' function. It corresponds to the first element of the list returned by 'multilevelLCMI'. |
implev2 |
The set of imputations for the level-2 variables (when present) provided by the 'multilevelLCMI' function. It corresponds to the second element of the list returned by 'multilevelLCMI'. |
ind |
The imputation index; an integer value that ranges from 1 to M, where M is the number of imputations
computed by |
This function takes a 'convData' list, the imputations provided by 'multilevelLCMI' and the imputation index (ind in 1,..., M where M is the number of imputations) and returns the completed dataset.
'BMLCimpute' allows researchers and users of categorical datasets with missing data to perform Multiple Imputation via Bayesian latent class models.
Data can be either single- or multi-level. Model estimation and imputations are implemented via a Gibbs sampler run with the Rcpp package interface.
The function multilevelLCMI
performs the imputations. Prior to the imputation step, data should be processed with the function convData
; the
resulting list is then passed as input to the multilevelLCMI
. Complete datasets are obtained via the compData
function.
The imputed dataset
multilevelLCMI
for the imputations and model estimation (internally calls Rcpp code);
convData
for data preparation (preprocessing);
compData
for dataset completion.
D. Vidotto <d.vidotto@uvt.nl>
BMLCimpute : Bayesian Multilevel Latent Class Models for the Multiple Imputation of Nested Categorical Data
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 30 31 32 | ## Not run:
library(BMLCimpute)
# Load data
data(simul_incomplete)
# Preprocess the Data
cd <- convData(simul_incomplete, GID = 1, UID = 2, var2 = 8:12)
# Model Selection
set.seed(1)
mmLC <- multilevelLCMI( convData = cd, L = 10, K = 10, it1 = 1000, it2 = 3000, it3 = 100,
it.print = 250, v = 10, I = 0, pri2 = 1 / 10, pri1 = 1 / 15, priresp = 0.01,
priresp2 = 0.01, random = TRUE, estimates = FALSE, count = TRUE, plot.loglik = FALSE,
prec = 3, scale = 1.0)
# Select posterior maxima of the number of classes for the imputations
# (Other alternatives are possible, such as posterior modes or posterior quantiles)
L = max(which(mmLC[[12]] != 0))
K = max(apply(mmLC[[13]], 1, function(x) max(which( x != 0))), na.rm = TRUE)
# Perform 5 imutations on the dataset
mmLC <- multilevelLCMI( convData = cd, L = L, K = K, it1 = 2000, it2 = 4000, it3 = 100,
it.print = 250, v = 10, I = 5, pri2 = 500, pri1 = 50, priresp = 0.01, priresp2 = 0.01,
random = TRUE, estimates = FALSE, count = TRUE, plot.loglik = TRUE, prec = 4, scale = 1.0)
# Obtain the dataset completed with the first set of imputations (ind = 1)
complete_data = compData( convData = cd, implev1 = mmLC[[1]], implev2 = mmLC[[2]], ind = 1 )
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.