candidate_fit: Take one fitted model out of an enumeration grid

View source: R/enumeration.R

candidate_fitR Documentation

Take one fitted model out of an enumeration grid

Description

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.

Usage

candidate_fit(x, n_profiles, n_group_classes = 1L, model = NULL)

Arguments

x

An multilpa_enumeration result from enumerate_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 several models and the class counts alone name several candidates. Naming counts that match more than one candidate raises latents_unknown_candidate listing 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")

latents documentation built on Oct. 16, 2026, 5:09 p.m.