Function for reordering the estimated parameters for glca
model.
# S3 method for class 'glca'
reorder(x, class.order = NULL, cluster.order = NULL, decreasing = TRUE, ...)
an object of "glca
", usually, a result of a call to glca
.
a integer vector of length equal to number of latent classes of the glca model, assigning the desired order of the latent classes
a integer vector of length equal to number of latent clusters of the glca model, assigning the desired order of the latent clusters
logical, when the class.order
or cluster.order
are not given, whether to rearrange the latent classes (clusters) by decreasing order of the magnitude of the probability of responding the first-category to the first manifest item (prevalence for the first latent class).
further arguments passed to or from other methods.
Since the latent classes or clusters can be switched according to the initial value of EM algorithm, the order of estimated parameters can be arbitrary.
lca = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
data = gss08, nclass = 3, na.rm = TRUE)
#> Manifest items :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#>
#> Deleted observation(s) :
#> 56 observation(s) for missing at least 1 variable
#>
#> SET : 1 .....loglik : -591.1304
#> SET : 2 .....loglik : -591.1231
#> SET : 3 .....loglik : -591.1237
#> SET : 4 .....loglik : -591.1231
#> SET : 5 .....loglik : -593.1777
#> SET : 6 .....loglik : -591.1232
#> SET : 7 .....loglik : -591.1231
#> SET : 8 .....loglik : -593.1778
#> SET : 9 .....loglik : -591.2244
#> SET : 10 .....loglik : -591.1231
#>
#> Start with SET 4 (-591.1231)
#>
#> Latent class analysis Fitting...
#>
#> 51 iteration
#>
#> Converged at 51 iteration (loglik :-591.1231)
plot(lca)
# Given ordering number
lca321 = reorder(lca, 3:1)
plot(lca321)
# Descending order
dec_lca = reorder(lca, decreasing = TRUE)
plot(dec_lca)
# Ascending order
inc_lca = reorder(lca, decreasing = FALSE)
plot(inc_lca)