Description Usage Arguments Details Value Note Author(s) References See Also Examples
Latent class analysis (LCA) attempts to find G hidden classes in binary data X. blca utilises one of: an EM algorithm, a variational Bayes approximation, Gibbs sampling or boot-strapping techniques to find maximum a posteriori (MAP), standard error and density estimates of the parameters.
1 |
X |
The data matrix. This may take one of several forms, see |
G |
The number of classes to run lca for. |
method |
The method with which to perform lca on the data. Four methods are currently available, "em", "gibbs", "boot" or "vb". Defaults to "em", with a warning. |
... |
Additional arguments to be passed on, depending on the method. See additional help files for details. |
The function calls to one of blca.em
, blca.boot
, blca.gibbs
, blca.vb
, depending on the method specified.
A list of class "blca" is returned. All methods return the following items:
classprob |
The class probabilities. |
itemprob |
The item probabilities, conditional on class membership. |
Z |
Estimate of class membership for each unique datapoint. |
prior |
A list containing the prior values specified for the model. |
See additional help files for details.
Earlier versions of this function erroneously referred to posterior standard deviations as standard errors. This also extended to some of the variable names of the returned function, which are now returned with the corrected suffix blca.em.sd
(for standard deviation). For backwards compatability reasons, the earlier suffix .se
has been retained as a returned argument.
Arthur White
Arthur White, Thomas Brendan Murphy (2014). BayesLCA: An R Package for Bayesian Latent Class Analysis." Journal of Statistical Software, 61(13), 1-28. URL: http://www.jstatsoft.org/v61/i13/.
blca.em
, blca.boot
, blca.gibbs
, blca.vb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | type1 <- c(0.8, 0.8, 0.2, 0.2)
type2 <- c(0.2, 0.2, 0.8, 0.8)
x<- rlca(1000, rbind(type1,type2), c(0.6,0.4))
set.seed(1)
fit <- blca(x, 2) ## EM algorithm used, warning returned
print(fit) ## No posterior standard deviations returned
summary(fit)
set.seed(1)
fit2 <- blca(x, 2, method="em", sd=TRUE) ##No warning - same fit
print(fit2) ##Posterior standard deviations returned
set.seed(1)
##Variational Bayes approximation, with priors specified.
fit3 <- blca(x, 2, method="vb", delta=c(5,5), alpha=2, beta=1)
print(fit3) ##Posterior standard deviations returned also.
par(mfrow=c(3,2))
plot(fit3, which=3:4)
par(mfrow=c(1,1))
|
Loading required package: e1071
Loading required package: coda
Restart number 1, logpost = -2451.19...
New maximum found... Restart number 2, logpost = -2451.19...
Restart number 3, logpost = -2451.19...
Restart number 4, logpost = -2451.19...
Restart number 5, logpost = -2451.19...
MAP Estimates:
Item Probabilities:
Col 1 Col 2 Col 3 Col 4
Group 1 0.774 0.798 0.197 0.201
Group 2 0.189 0.159 0.806 0.828
Membership Probabilities:
Group 1 Group 2
0.596 0.404
Warning message:
Posterior standard deviations not returned.
__________________
Bayes-LCA
Diagnostic Summary
__________________
Hyper-Parameters:
Item Probabilities:
alpha:
Col 1 Col 2 Col 3 Col 4
Group 1 1 1 1 1
Group 2 1 1 1 1
beta:
Col 1 Col 2 Col 3 Col 4
Group 1 1 1 1 1
Group 2 1 1 1 1
Class Probabilities:
delta:
Group 1 Group 2
1 1
__________________
Method: EM algorithm
Number of iterations: 19
Log-Posterior Increase at Convergence: 0.0007934346
Log-Posterior: -2451.186
AIC: -4920.373
BIC: -4964.543
Restart number 1, logpost = -2451.19...
New maximum found... Restart number 2, logpost = -2451.19...
Restart number 3, logpost = -2451.19...
Restart number 4, logpost = -2451.19...
Restart number 5, logpost = -2451.19...
MAP Estimates:
Item Probabilities:
Col 1 Col 2 Col 3 Col 4
Group 1 0.774 0.798 0.197 0.201
Group 2 0.189 0.159 0.806 0.828
Membership Probabilities:
Group 1 Group 2
0.596 0.404
Posterior Standard Deviation Estimates:
Item Probabilities:
Col 1 Col 2 Col 3 Col 4
Group 1 0.021 0.021 0.021 0.021
Group 2 0.027 0.026 0.026 0.026
Membership Probabilities:
Group 1 Group 2
0.024 0.024
Restart number 1, logpost = -6946.26...
MAP Estimates:
Item Probabilities:
Col 1 Col 2 Col 3 Col 4
Group 1 0.775 0.798 0.198 0.202
Group 2 0.193 0.163 0.805 0.827
Membership Probabilities:
Group 1 Group 2
0.594 0.406
Posterior Standard Deviation Estimates:
Item Probabilities:
Col 1 Col 2 Col 3 Col 4
Group 1 0.017 0.016 0.016 0.016
Group 2 0.020 0.018 0.020 0.019
Membership Probabilities:
Group 1 Group 2
0.015 0.015
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.