Fits one latent transition class per person across repeated items. Class proportions are shared across items, while guessing probabilities are item-specific. Parameters are estimated jointly by expectation-maximization.

person_item_lca_fit(
  pre_test,
  pst_test,
  na_as = c("dk", "missing"),
  missing_action = c("omit", "error"),
  item_fit = NULL,
  max_iter = 1000L,
  tol = 1e-08
)

Arguments

pre_test

data frame of pre-test responses

pst_test

data frame of post-test responses

na_as

classification of NA responses

missing_action

structural missingness handling

item_fit

optional item-wise fit used to initialize the EM algorithm

max_iter

maximum EM iterations

tol

convergence tolerance

Value

An object of class guess_person_fit containing shared class proportions, item-specific guessing probabilities, person-level posterior probabilities, log-likelihood, and convergence information.

Details

This is distinct from item_lca_fit, which fits independent class proportions for each item.

Examples

sim <- simulate_lca(n = 500, n_items = 4, seed = 123)
fit <- person_item_lca_fit(sim$pre, sim$post)
fit$class_priors
#>        gg        gk        kk 
#> 0.3613498 0.2857225 0.3529276 
head(fit$posterior)
#>           P_gg        P_gk      P_kk
#> 1 1.000000e+00 0.000000000 0.0000000
#> 2 4.702054e-03 0.995297946 0.0000000
#> 3 1.424383e-05 0.003015035 0.9969707
#> 4 4.702054e-03 0.995297946 0.0000000
#> 5 4.702054e-03 0.995297946 0.0000000
#> 6 1.000000e+00 0.000000000 0.0000000