
Plot every information criterion of a grid, or of a model comparison, against the number of classes
Source:R/wildcards.R
plot_criteria.Rdplot_criteria() plots every information criterion of an enumeration grid
against the number of classes, or the criteria of the models compared by
compare_models().
Arguments
- x
One of:
an enumeration grid of any kind, from
enumerate_lpa(),enumerate_lca(),enumerate_classes()orenumerate_regressions();a comparison from
compare_models().
- main, subtitle
Title and subtitle of the plot.
NULL(default) keeps the view's own text.
Value
A ggplot object.
Errors:
latents_nothing_to_plotwhen the package returnedxbut this function has no plot of it: a fitted model, a diagnostics result, pooled imputations, a bootstrap result or a sensitivity analysis. For an object of the wrong kind, the message names the plot functions that apply to it;latents_not_a_fitwhenxis not a fit, grid or other result of the package, for example a data frame;latents_missing_packagewhen ggplot2 is not installed.
Details
An enumeration grid. There is one panel per criterion, each with its own y-axis; lower values are preferred. The x-axis is the number of classes (the number of group classes for a grid of group-class families, or when the grid has one number of profiles and several numbers of group classes). There is one line per number of group classes, and per covariance structure when the grid has several. In each panel the lowest value among the converged candidates is circled, and a candidate that did not converge is marked with a cross at the bottom of the panel. The circle marks a minimum; it does not choose a model.
The criteria depend on the kind of grid:
a profile or class grid: AIC, KIC, BIC, SABIC, CAIC, AWE, ICL and CLC. BIC, SABIC, CAIC, AWE and ICL exist in two versions, with the number of groups or the number of individuals as the sample size; the two are drawn as separate panels where they differ and as one panel where they are the same;
a transition grid or a grid of group-class families: AIC, BIC and BIC with the individuals as the sample size;
a regression grid: AIC, BIC, BIC with the rows as the sample size, SABIC and ICL.
On these grids a criterion that takes the same values as one already drawn is not repeated.
plot_enumeration() draws the criteria you name, and takes the options
of this view (labels, mark_minimum, combine).
A comparison. The x-axis lists the compared models and the y-axis is the value of the criterion; lower is better. AIC, BIC and SABIC are drawn as one line each, with their own colour and marker.
See also
plot_enumeration() to choose the criteria; get_candidates()
and get_best() for the values as tables; plot_deltas().
Examples
grid <- enumerate_lpa(faithful, c("eruptions", "waiting"),
n_profiles = 1:3, model = "EEI",
n_starts = 2, seed = 1)
plot_criteria(grid)
# A comparison of two fitted models
one <- lpa(faithful, c("eruptions", "waiting"), n_profiles = 1,
n_starts = 2, seed = 1)
two <- lpa(faithful, c("eruptions", "waiting"), n_profiles = 2,
n_starts = 2, seed = 1)
plot_criteria(compare_models(one, two))