An enumeration keeps every candidate it fitted. This returns one of them, so that a caller who wants to plot, summarise or test a particular candidate names it by its class counts instead of indexing the grid by position.
Arguments
- x
An
multilpa_enumerationresult fromenumerate_classes().- n_profiles
Number of individual profiles identifying the candidate.
- n_group_classes
Number of group classes identifying the candidate.
- model
The covariance model identifying the candidate, needed when
enumerate_classes()was given severalmodels and the class counts alone name several candidates. Naming counts that match more than one candidate raiseslatents_unknown_candidatelisting the models it could have meant.
Value
The fitted model for that cell of the grid: an object of class
multilpa, exactly as multilpa() returned it, with every verb of this
package available on it.
Conditions
latents_unknown_candidate when the requested class counts are not in
the grid, and latents_failed_candidate when they are in the grid but
that fit raised an error, so no model exists to return. Neither situation
returns NULL, because a NULL would flow silently into whatever the
caller did next.
Examples
set.seed(1)
d <- data.frame(g = rep(1:10, each = 10), y = rnorm(100))
candidates <- enumerate_classes(d, "y", "g", n_profiles = 1:2,
n_group_classes = 1, n_starts = 2, seed = 1)
candidate_fit(candidates, n_profiles = 2, n_group_classes = 1, model = "VVI")
#> Two-level latent profile analysis: 2 profiles, 1 group class
#> 100 individuals in 10 groups; varying diagonal residual covariance (VVI)
#> Log likelihood: -130.591962 | AIC: 271.184 | BIC (groups): 272.697
#> Converged: TRUE | iterations: 36 | best start: 1/2
#>
#> profile y count proportion
#> 1 -0.1928460 44.5831 0.445831
#> 2 0.3516482 55.4169 0.554169
#>
#> Variances and standard errors: get_results(x, "profiles").
#> Every other table: get_results(x, what = ), or get_results(x, "all").
