blca {BayesLCA} | R Documentation |

## Bayesian Latent Class Analysis with one of several methods

### Description

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.

### Usage

```
blca(X, G, method = c("em", "gibbs", "boot", "vb"), ...)
```

### Arguments

`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. |

### Details

The function calls to one of `blca.em`

, `blca.boot`

, `blca.gibbs`

, `blca.vb`

, depending on the method specified.

### Value

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.

### Note

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.

### Author(s)

Arthur White

### References

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/.

### See Also

`blca.em`

, `blca.boot`

, `blca.gibbs`

, `blca.vb`

### Examples

```
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))
```

*BayesLCA*version 1.9 Index]