Learn R Programming

LCPA (version 1.0.0)

get.npar.LCA: Calculate Number of Free Parameters in Latent Class Analysis

Description

Computes the total number of free parameters in an LCA model based on the number of categories per observed variable and the number of latent classes. This follows standard LCA parameterization with local independence assumption.

Usage

get.npar.LCA(poly.value, L)

Value

Integer representing the total number of free parameters in the model: $$\text{npar} = \sum_{i=1}^I \underbrace{(L \times K_i - 1)}_{\text{free parameters}} + \underbrace{(L-1)}_{\text{class proportions}}$$

Arguments

poly.value

A numeric vector of length \(I\) where each element \(K_i\) represents the number of response categories for observed variable \(i\).

L

Integer specifying the number of latent classes.

Details

Parameter count derivation:

Fixed components (always present):
  • Conditional response probabilities: \(\sum_{i=1}^I (L \times K_i - 1)\) parameters

  • Independent class proportions: \(L-1\) parameters (since \(\sum_{l=1}^L \pi_l = 1\))

Per-variable parameterization:

For each observed variable \(i\) with \(K_i\) categories:

  • Each latent class requires \(K_i\) conditional probabilities \(P(X_i=k|Z=l)\)

  • With constraints \(\sum_{k=1}^{K_i} P(X_i=k|Z=l) = 1\) for each class \(l\)

  • Global constraints reduce total parameters to \(L \times K_i - 1\) per variable

Examples

Run this code
# Example 1: 3 binary variables (K_i=2), 2 latent classes
poly.value <- c(2, 2, 2)  # Three binary variables
L <- 2
npar <- sum(poly.value * L - 1) + (L - 1)  # = (4-1)+(4-1)+(4-1) + 1 = 3+3+3+1 = 10
get.npar.LCA(poly.value, L)  # Returns 10

# Example 2: Mixed variable types (binary, ternary, quaternary)
poly.value <- c(2, 3, 4)  # Variables with 2, 3, and 4 categories
L <- 3
npar <- sum(poly.value * L - 1) + (L - 1)  # = (6-1)+(9-1)+(12-1) + 2 = 5+8+11+2 = 26
get.npar.LCA(poly.value, L)  # Returns 26

# Example 3: Single polytomous variable with 5 categories, 4 latent classes
poly.value <- 5
L <- 4
npar <- sum(poly.value * L - 1) + (L - 1)  # = (20-1) + 3 = 19+3 = 22
get.npar.LCA(poly.value, L)  # Returns 22

Run the code above in your browser using DataLab