CreateModel: Create and initialize the Lcm model object

View source: R/ArrayUtils.R

CreateModelR Documentation

Create and initialize the Lcm model object

Description

CreateModel creates and initializes an Lcm Lcm object for non-parametric multiple imputation of discrete multivariate categorical data with or without structural zeros.

Usage

CreateModel(X, MCZ, K, Nmax, aalpha, balpha,seed)

Arguments

X

a data frame with the dataset with missing values. All variables must be unordered factors.

MCZ

a dataframe with the definition of the structural zeros. Placeholder components are represented with NAs. Variables in MCZ must be factors with the same levels as X. Rows do not need to define disjoint regions of the contingency table. See Manrique-Vallier and Reiter (2014) for details of the definition of structural zeros. MCZ should be set to NULL when there are no structure zeros.

K

the maximum number of mixture components.

Nmax

An upper truncation limit for the augmented sample size. This parameter will be ignored(set to 0) when there is no structural zeros.

aalpha

the hyper parameter 'a' for alpha in stick-breaking prior distribution.

balpha

the hyper parameter 'b' for alpha in stick-breaking prior distribution.

seed

the random seed for sampling. When setting to NULL(default), the random seed will be set randomly.

Details

This function should be the first function one should call to use the 'NPBayesImputeCat' library. The returned model is a Lcm object. See ?Lcm for more details on the fields available and their arguments.

Value

CreateModel returns an Lcm object. The returned model object will be referenced in all subsequent calls.

References

Manrique-Vallier, D. and Reiter, J.P. (2013), "Bayesian Estimation of Discrete Multivariate Latent Structure Models with Structural Zeros", JCGS.

Si, Y. and Reiter, J.P. (2013), "Nonparametric Bayesian multiple imputation for incomplete categorical variables in large-scale assessment surveys", Journal of Educational and Behavioral Statistics, 38, 499 - 521

Manrique-Vallier, D. and Reiter, J.P. (2014), "Bayesian Multiple Imputation for Large-Scale Categorical Data with Structural Zeros", Survey Methodology.

Examples

require(NPBayesImputeCat)
#Please use NYexample data set for a more realistic example
data('NYMockexample')

#create the model
model <- CreateModel(X,MCZ,10,10000,0.25,0.25,8888)

#run 1 burnins, 2 mcmc iterations and thin every 2 iterations
model$Run(1,2,2,FALSE)

#retrieve parameters from the final iteration
result <- model$snapshot

#convert ImputedX matrix to dataframe, using proper factors/names etc.
ImputedX <- GetDataFrame(result$ImputedX,X)
#View(ImputedX)

NPBayesImputeCat documentation built on Oct. 3, 2022, 5:05 p.m.