This class implements the MCMC sampler for non-parametric imputation of discrete multivariate data described in Manrique-Vallier and Reiter (2014). It provides methods for updating and monitoring the sampler.
Rcpp_lcm objects should be created with CreateModel. Please see the examples in the demo folder for more detailed explanation on model fitting and parameter tracing.
All reference classes extend and inherit methods from
the total number of iterations that have been run so far.
to check tracer status or to enable/disable the tracer.
the disjointed structural zero matrix.
retrieve a list with the current state of all the parameters in the sampler, including the imputed sample. A call the the "snapshot" method returns a list with the following components:
the concentration parameter of the stick breaking prior.
the effective number number of latent classes (mixture components)
the size of the augmented sample.
a vector with the mixture weights
a matrix with the current latent class assignment of each member of the sample
the current raw imputed dataset. Use GetDataFrame to convert the raw data to a data frame of factors as defined in the input data set.
The conditional multinomial probabilties. A Lmax * K * J array, where Lmax is the maximum number of levels of all discrete factors in the dataset, J is the number of factors in the dataset, and K is the number of latent classes. Since variables might have different numbers of levels, unused entries in the first dimension are filled with NAs to complete Lmax.
list of model parameters that can be traced by the tracer.
list of model parameters that are traced.
set parameters to be traced.
a list of parameters to be traced.
the maximum number of traced iterations.
Run(burnin, iter, thinning):
run MCMC iterations.
number of burn in iterations.
number of MCMC iterations.
resume from an interrupted call to run method.
retrieve a selected list of model parameters from last MCMC iteration.
a list of parameters to be traced.
retrieve all traced iterations. Returns a list with all the parameters set using the method SetTrace(). See description of snapshotreference method for a description of the parameters.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
require(NPBayesImpute) #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) #run 1 burnins, 2 mcmc iterations and thin every 2 iterations model$Run(1,2,2) #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)
Loading required package: Rcpp Initializing... Run model with structural zeros. iter = 0 kstar = 10 alpha = 0.03 Nmis = 380 iter = 0 kstar = 10 alpha = 2.88893 Nmis = 406 iter = 1 kstar = 10 alpha = 1.66954 Nmis = 424
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.