fast_lca: Latent Class Analysis

View source: R/svs.r

fast_lcaR Documentation

Latent Class Analysis

Description

A fast procedure for computing latent class analysis.

Usage

fast_lca(dat, k, tol = 1e-08, posterior = FALSE, transform = 1, sep = "_")

Arguments

dat

Input data: can be a table or a data frame.

k

Numeric specification of the number of latent classes to compute.

tol

Numeric specification of the convergence criterion.

posterior

Logical indicating whether the posterior probabilities of the individual observations should also be returned.

transform

Numeric specification of the power transformation to be applied on the posterior distribution; see fast_psa.

sep

Character specifying the separator string for joining the levels (if posterior = TRUE).

Details

The prior probabilities of the latent classes are initialized with a Dirichlet distribution (by means of rdirichlet from the package gtools) with alpha = the total frequency counts of every level.

Value

A list with components:

prob0

The probabilities of the latent classes.

prob1-prob...

The probabilities for each set of levels. The columns of each prob... sum to 1.

posterior

If posterior = TRUE: An indicator matrix with the posterior probabilities of each observation.

References

Agresti, A. (2013) Categorical data analysis. Hoboken: John Wiley and Sons, 535–542.

Examples

SndT_Fra <- read.table(system.file("extdata", "SndT_Fra.txt", package = "svs"),
   header = TRUE, sep = "\t", quote = "\"", encoding = "UTF-8",
   stringsAsFactors = FALSE)
lca_SndT_Fra <- fast_lca(SndT_Fra, k = 7)
lca_SndT_Fra

svs documentation built on June 24, 2024, 5:07 p.m.