# 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