
Print the estimates, descriptive statistics and diagnostic checks of a fitted model, and draw its plots
Source:R/report.R
report.Rdreport() prints a first look at a fitted profile, class or transition
model in one call: its estimates, the descriptive statistics of its
variables and its diagnostic checks, followed by its plots. It computes
nothing of its own; each part is the output of another function, named
under Report contents, which returns the same numbers as tables.
The output goes to the R console and the graphics device. The function returns the fitted model invisibly, so it can end a pipeline.
Usage
report(
x,
data = NULL,
plots = TRUE,
by = c("profile", "overall"),
rows = 10L,
...
)Arguments
- x
A profile, class or transition fit: from
lpa(),lca(),multilpa()ormultilca()(with or without membership covariates), or anlta()fit of classmultilpa_transitions(the basic transition model: continuous or categorical indicators and one first-order transition matrix for all occasions, without covariates, weights or a stayer class). Any other model (anlta()fit of classmultilpa_lta, a mixture regression, a growth mixture, an additive or cross-level fit) raiseslatents_not_a_fit; its ownsummary(),diagnostics()andplot()report it.- data
The data frame the model was fitted to.
NULL(default) uses the columns stored in the fit.- plots
Whether to draw the plots:
TRUE(default): after the printed output, draws every plot view the fit has the ingredients for, one after another (seeplot_views()), and then names the views that could not be drawn. Without the ggplot2 package a message says so and nothing is drawn;FALSE: prints only.
- by
How
diagnostics()assesses the bivariate residuals:"profile"(default): within each profile separately;"overall": pooled over the profiles.
- rows
How many rows of each table of
summary(x)to print: one whole number of 0 or more (default 10). A longer table ends with the number of rows left out and the call that returns it whole.- ...
Not used. Any further argument raises
latents_bad_argumentbefore anything is printed.
Value
The fitted model x, invisibly. The function is called for its
printed and plotted output. Conditions raised:
latents_not_a_fit:xis not a profile, class ormultilpa_transitionsfit;latents_bad_argument: an argumentreport()does not take, or aplotsorbywith a value it does not take.
Report contents
The parts are printed in this order:
summary(x): every table of the fit, each cut torowsrows;descriptives()of the fit: the number of observations, missing values, mean, standard deviation and range of each variable, and for grouped data its intraclass correlation;the checks of
diagnostics(): estimation, class sizes, classification, bivariate residuals, and the log likelihood with its BIC, each with its status;with
plots = TRUE, the plot views of the fit.
The tables behind each part are returned by get_results(),
descriptives() and diagnostics().
See also
summary(), diagnostics(), descriptives(), plot_views();
plot_all() for the plots alone.
Examples
fit <- multilpa(
course_engagement,
vars = c("browse", "lectures", "forum_read", "forum_post", "attendance"),
id = "student", n_profiles = 2, n_group_classes = 2, n_starts = 4,
seed = 1
)
report(fit, plots = FALSE)
#> Two-level latent profile analysis: 2 profiles, 2 group classes
#> Individuals: 1422; groups: 106; parameters: 23; converged: TRUE
#> Log likelihood: -8439.816424; AIC: 16925.633
#> BIC (groups): 16986.892; BIC (individuals): 17046.609
#> Best likelihood replicated in 4/4 starts (absolute tolerance 0.00711).
#>
#> -- profiles --------------------------------------------------------
#> profile indicator mean variance standard_deviation mean_standard_error
#> 1 browse 0.5396 0.5899 0.7680 0.02710
#> 1 lectures 0.4274 0.8447 0.9191 0.03249
#> 1 forum_read 0.6198 0.4815 0.6939 0.02473
#> 1 forum_post 0.5305 0.6888 0.8299 0.02953
#> 1 attendance 0.6490 0.3841 0.6198 0.02226
#> 2 browse -0.7656 0.5285 0.7270 0.03121
#> 2 lectures -0.6065 0.5384 0.7337 0.03093
#> 2 forum_read -0.8792 0.3631 0.6026 0.02622
#> 2 forum_post -0.7527 0.4212 0.6490 0.02768
#> 2 attendance -0.9207 0.3736 0.6113 0.02643
#> variance_standard_error
#> 0.02948
#> 0.04210
#> 0.02440
#> 0.03482
#> 0.01956
#> 0.03222
#> 0.03209
#> 0.02279
#> 0.02608
#> 0.02279
#>
#> -- responses -------------------------------------------------------
#> (no rows)
#>
#> -- covariances -----------------------------------------------------
#> profile indicator indicator_2 covariance
#> 1 browse browse 0.5899
#> 1 lectures browse 0.0000
#> 1 forum_read browse 0.0000
#> 1 forum_post browse 0.0000
#> 1 attendance browse 0.0000
#> 1 browse lectures 0.0000
#> 1 lectures lectures 0.8447
#> 1 forum_read lectures 0.0000
#> 1 forum_post lectures 0.0000
#> 1 attendance lectures 0.0000
#> ... 40 more rows. get_results(x, what = "covariances")
#>
#> -- gaussian_diagnostics --------------------------------------------
#> context profile gaussian_mass positive_rows weight_effective_n
#> profiles profile_1 834.1 1422 852
#> profiles profile_2 587.9 1422 606
#> min_variance_ratio min_standardized_eigenvalue boundary
#> 0.3930 0.3930 FALSE
#> 0.3715 0.3715 FALSE
#>
#> -- profile_probabilities -------------------------------------------
#> group_class profile probability group_class_probability
#> 1 1 0.1705 0.3253
#> 1 2 0.8295 0.3253
#> 2 1 0.7859 0.6747
#> 2 2 0.2141 0.6747
#>
#> -- counts ----------------------------------------------------------
#> level class effective_count effective_proportion
#> individuals 1 834.10 0.5866
#> individuals 2 587.90 0.4134
#> groups 1 34.48 0.3253
#> groups 2 71.52 0.6747
#>
#> -- posteriors ------------------------------------------------------
#> row group profile posterior modal
#> 1 1 1 9.996e-01 TRUE
#> 2 1 1 9.851e-01 TRUE
#> 3 1 1 2.421e-06 FALSE
#> 4 1 1 3.863e-06 FALSE
#> 5 1 1 5.749e-06 FALSE
#> 6 1 1 2.278e-05 FALSE
#> 7 1 1 2.301e-05 FALSE
#> 8 1 1 1.107e-05 FALSE
#> 9 1 1 2.173e-06 FALSE
#> 10 1 1 9.510e-06 FALSE
#> ... 2834 more rows. get_results(x, what = "posteriors")
#>
#> -- group_posteriors ------------------------------------------------
#> group group_size log_likelihood group_class posterior modal
#> 1 13 -61.52 1 1.000e+00 TRUE
#> 2 13 -71.94 1 1.000e+00 TRUE
#> 3 14 -76.69 1 6.005e-10 FALSE
#> 4 13 -67.56 1 1.327e-09 FALSE
#> 5 14 -78.80 1 1.000e+00 TRUE
#> 6 12 -80.90 1 1.984e-02 FALSE
#> 7 15 -89.36 1 1.123e-09 FALSE
#> 8 14 -85.22 1 9.989e-01 TRUE
#> 9 14 -83.80 1 4.309e-10 FALSE
#> 10 15 -82.06 1 1.000e+00 TRUE
#> ... 202 more rows. get_results(x, what = "group_posteriors")
#>
#> -- assignments -----------------------------------------------------
#> student browse lectures forum_read forum_post attendance profile group_class
#> 1 0.73 -0.08 0.30 0.67 0.72 1 1
#> 1 0.68 0.53 -0.02 -0.55 0.70 1 1
#> 1 -1.51 -0.51 -0.91 -0.80 -0.97 2 1
#> 1 0.64 -1.02 -1.62 -1.20 -1.26 2 1
#> 1 -0.94 -0.37 -0.71 -0.28 -1.52 2 1
#> 1 -0.36 -0.46 -0.77 -0.43 -1.34 2 1
#> 1 0.38 -1.85 -0.84 -1.09 -1.12 2 1
#> 1 -1.44 0.66 -0.67 -1.67 -1.00 2 1
#> 1 -0.76 -0.43 -1.04 -0.69 -1.37 2 1
#> 1 0.26 -0.95 -0.51 -1.89 -1.45 2 1
#> uncertainty posterior_profile_1 posterior_profile_2
#> 4.436e-04 9.996e-01 0.0004436
#> 1.485e-02 9.851e-01 0.0148535
#> 2.421e-06 2.421e-06 0.9999976
#> 3.863e-06 3.863e-06 0.9999961
#> 5.749e-06 5.749e-06 0.9999943
#> 2.278e-05 2.278e-05 0.9999772
#> 2.301e-05 2.301e-05 0.9999770
#> 1.107e-05 1.107e-05 0.9999889
#> 2.173e-06 2.173e-06 0.9999978
#> 9.510e-06 9.510e-06 0.9999905
#> ... 1412 more rows. get_results(x, what = "assignments")
#>
#> -- classification --------------------------------------------------
#> level class n_modal proportion_modal estimated_n estimated_proportion
#> individuals 1 836 0.5879 834.10 0.5866
#> individuals 2 586 0.4121 587.90 0.4134
#> groups 1 35 0.3302 34.48 0.3253
#> groups 2 71 0.6698 71.52 0.6747
#> average_posterior odds_correct_classification
#> 0.9849 46.08
#> 0.9818 76.35
#> 0.9690 64.80
#> 0.9920 59.89
#>
#> -- average_posteriors ----------------------------------------------
#> level assigned_class class n_assigned average_posterior
#> individuals 1 1 836 0.984935
#> individuals 1 2 836 0.015065
#> individuals 2 1 586 0.018243
#> individuals 2 2 586 0.981757
#> groups 1 1 35 0.968985
#> groups 1 2 35 0.031015
#> groups 2 1 71 0.007986
#> groups 2 2 71 0.992014
#>
#> -- classification_errors -------------------------------------------
#> level true_class assigned_class probability
#> individuals 1 1 0.98718
#> individuals 1 2 0.01282
#> individuals 2 1 0.02142
#> individuals 2 2 0.97858
#> groups 1 1 0.98356
#> groups 1 2 0.01644
#> groups 2 1 0.01518
#> groups 2 2 0.98482
#>
#> -- bch_weights -----------------------------------------------------
#> level unit assigned_class class weight
#> individuals 1 1 1 1.01327
#> individuals 1 1 2 -0.01327
#> individuals 2 1 1 1.01327
#> individuals 2 1 2 -0.01327
#> individuals 3 2 1 -0.02218
#> individuals 3 2 2 1.02218
#> individuals 4 2 1 -0.02218
#> individuals 4 2 2 1.02218
#> individuals 5 2 1 -0.02218
#> individuals 5 2 2 1.02218
#> ... 3046 more rows. get_results(x, what = "bch_weights")
#>
#> -- entropy ---------------------------------------------------------
#> level n_classes n_units entropy_sum relative_entropy
#> individuals 2 1422 60.940 0.9382
#> groups 2 106 4.435 0.9396
#>
#> -- replication -----------------------------------------------------
#> n_starts n_screened n_converged n_failed n_best_replicated share tolerance
#> 4 0 4 0 4 1 0.00711
#> best_start log_likelihood
#> 1 -8440
#>
#> -- residuals -------------------------------------------------------
#> profile indicator_1 indicator_2 kind observed expected residual
#> profile_1 lectures attendance gaussian 0.23393 0 0.23393
#> profile_2 forum_read attendance gaussian 0.22869 0 0.22869
#> profile_1 forum_read attendance gaussian 0.20880 0 0.20880
#> profile_1 forum_post attendance gaussian 0.20314 0 0.20314
#> profile_2 browse attendance gaussian 0.19248 0 0.19248
#> profile_1 browse attendance gaussian 0.17312 0 0.17312
#> profile_2 lectures attendance gaussian 0.12018 0 0.12018
#> profile_2 forum_post attendance gaussian 0.11883 0 0.11883
#> profile_2 browse forum_read gaussian 0.10925 0 0.10925
#> profile_2 forum_read forum_post gaussian 0.06676 0 0.06676
#> effective_n statistic df p_value p_adjusted
#> 834.1 6.871 NA 6.374e-12 1.275e-10
#> 587.9 5.630 NA 1.799e-08 8.994e-08
#> 834.1 6.109 NA 1.001e-09 1.001e-08
#> 834.1 5.939 NA 2.867e-09 1.912e-08
#> 587.9 4.714 NA 2.429e-06 8.098e-06
#> 834.1 5.042 NA 4.619e-07 1.847e-06
#> 587.9 2.921 NA 3.493e-03 9.708e-03
#> 587.9 2.888 NA 3.883e-03 9.708e-03
#> 587.9 2.653 NA 7.983e-03 1.774e-02
#> 587.9 1.617 NA 1.059e-01 2.118e-01
#> ... 10 more rows. get_results(x, what = "residuals")
#>
#> -- information_criteria --------------------------------------------
#> log_likelihood n_parameters aic kic bic_groups bic_individual sabic_groups
#> -8440 23 16926 16952 16987 17047 16914
#> sabic_individual caic_groups caic_individual awe_groups awe_individual
#> 16974 17010 17070 17292 17412
#> icl_groups icl_individual clc_groups clc_individual
#> 17116 17176 17009 17009
#>
#> -- model -----------------------------------------------------------
#> n_observations n_informative n_groups n_profiles n_group_classes centering
#> 1422 1422 106 2 2 none
#> scaling covariance_structure n_parameters n_parameters_with_measurement
#> none VVI 23 23
#> log_likelihood aic bic_groups bic_individual converged iterations boundary
#> -8440 16926 16987 17047 TRUE 9 FALSE
#> small_classes best_start n_best_replicated weights
#> FALSE 1 4 <NA>
#>
#> -- stages ----------------------------------------------------------
#> stage group_classes fixed log_likelihood parameters
#> joint 2 <NA> -8440 23
#> parameters_with_measurement converged
#> 23 TRUE
#>
#> -- starts ----------------------------------------------------------
#> start log_likelihood converged iterations error boundary
#> 1 -8440 TRUE 9 <NA> FALSE
#> 2 -8440 TRUE 12 <NA> FALSE
#> 3 -8440 TRUE 9 <NA> FALSE
#> 4 -8440 TRUE 9 <NA> FALSE
#>
#> -- data ------------------------------------------------------------
#> student browse lectures forum_read forum_post attendance
#> 1 0.73 -0.08 0.30 0.67 0.72
#> 1 0.68 0.53 -0.02 -0.55 0.70
#> 1 -1.51 -0.51 -0.91 -0.80 -0.97
#> 1 0.64 -1.02 -1.62 -1.20 -1.26
#> 1 -0.94 -0.37 -0.71 -0.28 -1.52
#> 1 -0.36 -0.46 -0.77 -0.43 -1.34
#> 1 0.38 -1.85 -0.84 -1.09 -1.12
#> 1 -1.44 0.66 -0.67 -1.67 -1.00
#> 1 -0.76 -0.43 -1.04 -0.69 -1.37
#> 1 0.26 -0.95 -0.51 -1.89 -1.45
#> ... 1412 more rows. get_results(x, what = "data")
#>
#> 21 tables above, truncated to fit. get_results(x, what = ) returns any
#> of them whole, and get_results(x, what = "all") returns every one.
#>
#> variable n n_missing mean sd min max n_distinct
#> 1 browse 1422 0 -2.812940e-05 0.9890804 -3.14 2.49 398
#> 2 lectures 1422 0 -4.219409e-05 0.9889178 -2.91 3.22 399
#> 3 forum_read 1422 0 7.032349e-05 0.9890236 -2.73 2.81 400
#> 4 forum_post 1422 0 -2.109705e-05 0.9890038 -2.61 3.10 397
#> 5 attendance 1422 0 7.735584e-05 0.9889426 -2.45 2.41 401
#> n_groups sd_within sd_between icc
#> 1 106 0.8896664 0.5017669 0.19229259
#> 2 106 0.9448773 0.3916068 0.08779169
#> 3 106 0.8720825 0.5242171 0.22403384
#> 4 106 0.9122357 0.4582008 0.15034618
#> 5 106 0.8734499 0.5249713 0.22145308
#>
#> Diagnostics: Two-level latent profile analysis, 2 profiles, 2 group classes
#> 1 check needs attention: pairs dependent within a class
#>
#> Estimation
#> ok best start converged yes
#> info best log likelihood reached by 4 of 4 starts
#> ok starts failed or unfinished 0 of 4
#> ok estimates at a bound no
#>
#> Class size
#> info smallest class individuals 41.3% (n = 588, class 2)
#> info modal vs estimated proportions individuals largest gap 0.001
#> ok classes with no assigned unit individuals 0 of 2
#> info smallest class groups 32.5% (n = 34, class 1)
#> info modal vs estimated proportions groups largest gap 0.005
#> ok classes with no assigned group groups 0 of 2
#>
#> Classification
#> info relative entropy individuals 0.938
#> info lowest average posterior individuals 0.982 (class 2)
#> info lowest odds of correct classification individuals 46.1 (class 1)
#> info relative entropy groups 0.940
#> info lowest average posterior groups 0.969 (class 1)
#> info lowest odds of correct classification groups 59.9 (class 2)
#>
#> Local independence
#> check pairs dependent within a class 9 of 20 tested pairs BH-adjusted p < 0.05
#> smallest adjusted p: lectures x attendance in profile_1, residual 0.234, adjusted p <1e-04
#>
#> Information
#> info log likelihood, parameters, BIC -8439.82, 23, 16986.89
#>
#> Every check with its reference: get_results(x, "checks"). Other tables: get_results(x, what = ).