
Get the estimates of a fitted profile or class model as starting values for another fit
Source:R/accessors.R
starting_values.Rdstarting_values() returns the parameter estimates of a fitted profile or
class model in the form multilpa() accepts as start, so that a second fit
begins from the first one's solution. The measurement parameters can be taken
alone, for a refit that estimates the class probabilities anew. Starting
values are where the estimation begins, not constraints: to hold parameters
fixed, use the fixed argument of the fitting function.
Arguments
- x
The source of the values, one of:
a fit from
lpa(),lca(),multilpa()ormultilca()without membership covariates;a list with
profile_probabilities,group_probabilitiesand the measurement blocks the model uses:meanswithvariancesorcovariancesfor continuous indicators,response_probabilitiesfor categorical ones (a model with only categorical indicators needs nomeans). Other elements are ignored.
A fit with membership covariates and a model of another family carry no such blocks and raise
latents_bad_start, as does a transition fit fromlta(), which takes nostart.- covariance
How the within-profile covariances are returned:
"auto"(default):covarianceswhenxhas them (a fit with a full covariance structure), otherwisevariances;"drop": alwaysvariances, the diagonal form;"keep":covariances, raisinglatents_bad_startwhenxhas none.
- what
Which blocks to return:
"all"(default): the measurement blocks and the mixing blocks (profile_probabilitiesandgroup_probabilities);"measurement": the measurement blocks only. The mixing blocks are sized for the model that produced them, so leave them out for a refit with another number of group classes, together withfixedinmultilpa().
Value
An object of class multilpa_start: the list that multilpa()
accepts as start, which can be passed on as it is. Its elements:
means: a matrix, profiles by continuous indicators;variances: a matrix of the same shape; or, when covariances are returned,covariancesin its place: an array, indicators by indicators by profiles;profile_probabilities: a matrix, group classes by profiles, andgroup_probabilities: a vector with one value per group class. Both are left out underwhat = "measurement";response_probabilities: for a model with categorical indicators, a list with one matrix per indicator, profiles by categories.
The Gaussian blocks are unnamed and matched by position.
response_probabilities keeps the indicator and category names, and
multilpa() matches its blocks by them.
Printing the object summarises the blocks. as.data.frame() returns
the means and variances as a table, one row per profile and
indicator, and get_results() the tables "profiles", "responses",
"profile_probabilities" and "covariances".
Conditions raised:
latents_bad_start:xlacks a block that is needed, is a transition fit, or has no covariances undercovariance = "keep".multilpa()raises the same class for astartwhose categorical indicators or categories do not match the model;latents_unsupported_noise:xis a fit with a noise component;latents_bad_argument:xis not a list.
Details
This is a utility for controlled refitting. starting_values() checks
that the blocks it needs are present; the fitting function checks their
dimensions and values.
See also
get_results() for the values as tidy tables; fit_staged() for
two-stage estimation with fixed measurement parameters.
Examples
set.seed(7)
example_data <- data.frame(
school = rep(seq_len(12), each = 10),
score_a = rnorm(120), score_b = rnorm(120)
)
fit <- multilpa(example_data, c("score_a", "score_b"), "school",
n_profiles = 2, n_group_classes = 1, n_starts = 2, seed = 1)
starting_values(fit)
#> Starting values: 2 profile(s), 2 continuous indicator(s)
#> Residual covariance: diagonal
#> Categorical indicators: 0
#> Mixing blocks: 1 group class(es)
#> Pass this to multilpa(start = ) as it is.
as.data.frame(starting_values(fit))
#> profile indicator mean variance standard_deviation
#> 1 1 1 0.31636435 0.7483133 0.8650510
#> 2 1 2 -0.05291897 0.9149761 0.9565438
#> 3 2 1 -1.11359384 0.1018719 0.3191738
#> 4 2 2 0.79093314 0.2857893 0.5345926
refit <- multilpa(example_data, c("score_a", "score_b"), "school",
n_profiles = 2, n_group_classes = 1, n_starts = 1,
start = starting_values(fit))
logLik(refit)
#> 'log Lik.' -323.0197 (df=9)