Learn R Programming

BayesLCA (version 1.9)

as.mcmc.blca.gibbs: Converts blca.gibbs Objects to type mcmc

Description

Converts blca objects to mcmc objects. This is only to be used with the Gibbs sampling method.

Usage


# S3 method for blca.gibbs
as.mcmc(x, …)
 blca2mcmc(x)

Arguments

x

An object of class blca.gibbs. An error is returned if this is not the case.

Additional arguments to be passed to the mcmc function.

Value

An \(N \times G*(M+1)\) matrix of class mcmc, where N is the number of data points, M the number of columns and G the number of classes. The first G columns (labelled ClassProb 1 , …, ClassProb G) are class membership probability samples, the next G*M columns (labelled ItemProb 1 1 , ItemProb 1 2, …, ItemProb G 1, …, ItemProb G M) are item response probability samples.

Details

Whenever a Gibbs sampler is employed, it is always a good idea to ensure that parameter samples are being obtained correctly - that burn-in has been achieved, and that appropriate mixing is taking place, for example. as.mcmc.blca.gibbs converts an object of class blca to that of mcmc to avail of the diagnostic checks available in other R packages, particularly those in the coda package.

See Also

blca.gibbs, geweke.diag, raftery.diag

Examples

Run this code
# NOT RUN {
data(Alzheimer)

# }
# NOT RUN {
 fit.gibbs <- blca.gibbs(Alzheimer, 2) 
# }
# NOT RUN {
 raftery.diag(as.mcmc(fit.gibbs)) 
# }
# NOT RUN {
# }
# NOT RUN {
 fit.gibbs <- blca.gibbs(Alzheimer, 2, iter=50000, accept=0.1, burn.in=100) 
# }
# NOT RUN {
 plot(as.mcmc(fit.gibbs)) 
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab