Computes log scores and perplexity for each named item and in aggregate. The supplied counts may be the fit data or independent evaluation data; this function does not infer that provenance. Scores are only out-of-sample when the counts were not used to estimate `fit`.

score_item_lca(fit, transition_counts)

Arguments

fit

A `guess_fit` object returned by [fit_item_lca()] or [fit_item_lca_counts()].

transition_counts

Named matrix of nonnegative whole-number transition counts with exactly the same item names as `fit`.

Value

A `guess_item_score` object containing `item_scores`, a data frame of item-level log likelihood, observation count, mean log likelihood, and perplexity; plus aggregate `total_log_likelihood`, `n_observations`, `mean_log_likelihood`, and `perplexity`.

References

Cor, M. K., and Sood, G. (2016). Guessing and Forgetting: A Latent Class Model for Measuring Learning. *Political Analysis*, 24(2), 226–242.

Examples

sim <- simulate_lca(n = 500, n_items = 2, seed = 123)
transition_counts <- count_item_transitions(sim$pre, sim$post)
fit <- fit_item_lca_counts(transition_counts)
score_item_lca(fit, transition_counts)
#> $item_scores
#>       log_likelihood n_observations mean_log_likelihood perplexity
#> item1      -611.2387            500           -1.222477   3.395589
#> item2      -609.5039            500           -1.219008   3.383828
#> 
#> $total_log_likelihood
#> [1] -1220.743
#> 
#> $n_observations
#> [1] 1000
#> 
#> $mean_log_likelihood
#> [1] -1.220743
#> 
#> $perplexity
#> [1] 3.389704
#> 
#> $call
#> score_item_lca(fit = fit, transition_counts = transition_counts)
#> 
#> attr(,"class")
#> [1] "guess_item_score"