plot_clustering() and plot() on a clustering() result now return the
plots instead of drawing them: one type gives a ggplot object, several give
a saqr_plots list, named by type, that draws each when printed. This
follows latents 0.8.8, whose plot() methods return ggplot objects."parallel" and "pairs" (group "clusters") and "tree"
(group "selection").clustering() fits every candidate through latents::enumerate_lpa() (one
candidate is a grid of one) and returns the BIC-best fit. The result is now
a latents fit with class c("saqr_clustering", "multilpa"), so
as.data.frame(), latents::diagnostics(), latents::get_results() and
predict() work on it directly.summary() returns one row per candidate with aic, bic, icl,
entropy, boundary, delta_bic and selected (was best). icl is no
longer NA for a single model.fitted() matches columns by name, not position.message(). The latents single-level notice no
longer leaks into the output.vars raise saqrmisc_bad_input;
scaling and na_action are matched arguments.plot_clustering() takes type and passes ... (e.g.
scale = "standardized") to latents. Plot descriptions come from
latents::plot_views().cluster(), cluster_fit(),
get_cluster_assignments()/cluster_assignments() -> fitted();
compare_models()/cluster_compare(), model_comparison_table()/
cluster_compare_table(), list_models()/cluster_models(),
get_best_model()/cluster_best() -> summary();
cluster_diagnostics()/cluster_stability() -> latents::diagnostics();
generate_cluster_report()/cluster_report() -> print()/summary().plot_clustering(results, type, model, scale): one verb for every
figure of a clustering() result. type takes any mix of plot names, group
names, or "all":
"clusters": profile, heatmap, distribution, sizes."diagnostics": certainty (with relative entropy), avepp (average
posterior probability), projection (principal components)."selection": bic, aic, icl, with the best model circled.clustering_plots object that
draws every plot when printed and lists its contents via as.data.frame().clustering_plot_types() returns the catalogue as a data.frame.plot() on a clustering() result now draws through plot_clustering()
and takes the same type, model, and scale. Behaviour changes: the
default type is "clusters" (was "profile"); "comparison" is now
"selection" (see below);
"barchart" is no longer a plot() type (still available
in plot_model()).model accepts one or more model names or "all". Cluster and diagnostic
plots are drawn once per model (named "<model>/<type>"); selection plots
once. type = "all" draws every plot for every fitted model unless
model narrows it.mosaic_analysis() gains by =, which fits the var1 x var2 table
separately within each level of a third variable and draws one mosaic panel
per stratum. This is the standard check for effect modification and for
Simpson's paradox, where a pooled association weakens, vanishes or reverses
inside every subgroup.
min_count) is applied to the pooled table before
splitting, so every panel shows the same rows and columns.by_label, min_stratum_n, p_adjust, facet_ncol, facet_show_n
and seed arguments. Per-stratum p-values are corrected for multiplicity
(Benjamini-Hochberg by default) and reported beside the raw values.mosaic_stratified and the fields
strata_summary, strata_residuals, strata_table and overall_summary,
the last pairing the pooled test with a Cochran-Mantel-Haenszel test of the
association conditional on the stratifier.as.data.frame() method for mosaic_analysis objects, so results are
reached with as.data.frame(fit, what = "strata") rather than by indexing
into the object. what accepts "summary", "table", "residuals", "strata"
and "overall".print() and summary() methods for stratified fits.seed makes the Monte-Carlo Fisher p-value reproducible and restores the
caller's RNG stream on exit.tile_label = "count_percent" prints the count with its percentage on a
second line, e.g. 3,391 over (29.8%). The percentage follows
percentage_base ("total", "row" or "column") and, under stratification, is
computed within each panel. A two-line label is required to clear roughly
twice the tile height of a one-line label before it is drawn, so it is
suppressed in tiles too short to hold it rather than spilling over the edge.NaN
statistics. The test now runs on the non-empty core of the table (giving the
correct degrees of freedom) while residuals are padded back onto the shared
category grid so panels stay aligned. Affected strata are named in a warning.cluster() as a short alias for clustering().cluster_* aliases for the existing clustering helpers.
All original function names remain unchanged.clustering() model comparisons by storing the scalar fitted
log-likelihood instead of each model's variable-length iteration history.clustering() now stores a comparison table containing BIC, AIC, and ICL.
plot(..., type = "all") plots each criterion separately, while "bic",
"aic", and "icl" can be requested individually.get_cluster_assignments() now preserves rows omitted during complete-case
fitting and marks their assignments and probabilities as NA.summary() returns a ranked model tibble,
fitted() returns original rows with fitted clusters, and
get_best_model(..., what = "fit") extracts the raw MoEClust fit.plot(..., type = "all") now means every plot for every fitted model.
Added plot_best_model() and plot_model() for focused plotting.mosaic_analysis() no longer draws the variable-name axis titles by default,
which previously overprinted the category labels (especially next to thin
categories). Set show_varnames = TRUE to restore them.This is the initial release of the Saqrmisc package, providing comprehensive tools for data analysis and visualization.
Model-Based Clustering Analysis (run_full_moe_analysis)
Statistical Comparison Analysis (generate_comparison_plots)
Categorical Variable Analysis (mosaic_analysis)
Helper Functions
view_results() for easy visualization of clustering results