
Get the average posterior probability of every class among the units assigned to each class
Source:R/wildcards.R
get_avepp.Rdget_avepp() returns the average posterior probability (AvePP) matrix in
long form: for the units assigned to each class, their mean posterior
probability of every class.
Arguments
- x
One of:
a fitted model of any family: from
lpa(),lca(),multilpa(),multilca(),lta()ormixture_regression(). The table is the onediagnostics()computes with its defaults;an enumeration grid of any kind, from
enumerate_lpa(),enumerate_lca(),enumerate_classes()orenumerate_regressions(). The tables of the fitted candidates are stacked, with a first columncandidatethat names the candidate of each row. A candidate whose estimation failed has no rows;the result of
diagnostics(). The table is the one the result holds.
Value
A data frame with one row per level, assigned class and class (and per candidate for a grid) and the columns:
level:"individuals"or"groups";assigned_class: the class the units are assigned to (their most likely class);class: the class whose probability is averaged;n_assigned: the number of units assigned toassigned_class;average_posterior: the mean posterior probability ofclassamong those units.
The rows in which assigned_class equals class are the diagonal of
the matrix: values near 1 mean that the class is well separated.
Errors: latents_not_a_fit when x is none of these, for example a
comparison, pooled imputations or a data frame.
See also
plot_avepp() draws the matrix; get_classification(),
get_entropy().
Examples
fit <- lpa(faithful, c("eruptions", "waiting"), n_profiles = 2,
n_starts = 2, seed = 1)
get_avepp(fit)
#> level assigned_class class n_assigned average_posterior
#> 1 individuals 1 1 175 9.999434e-01
#> 2 individuals 1 2 175 5.663136e-05
#> 3 individuals 2 1 97 3.851364e-04
#> 4 individuals 2 2 97 9.996149e-01