Visualizes the hierarchical shrinkage model fit. Creates either:
"shrinkage"— Shows pre/post-shrunk estimates with arrows"diagnostics"— Multi-panel view with hyperparameters and shrinkage factor
The shrinkage plot displays:
Pre-shrunk estimates (hollow circles) — from stage 1 mixture or MLEs
Post-shrunk estimates (filled circles) — posterior means of theta
Global mean (dashed line) — posterior mean of mu
Credible intervals (optional) — for shrunken estimates
Arrows (optional) — showing direction and magnitude of shrinkage
Arguments
- x
A
shrinkr_fitobject fromshrink().- type
Character; type of plot. Options:
"shrinkage"- Basic shrinkage visualization (default)"diagnostics"- Multi-panel with hyperparameters and shrinkage factor
- group_names
Optional character vector of length G to label groups. If
NULL, uses names fromx$data$varsor defaults to "group1", etc.- show_arrows
Logical; draw arrows from pre-shrunk to post-shrunk estimates? Default
FALSE. Only applies whentype = "shrinkage".- show_intervals
Logical; show credible intervals for both pre-shrunk and post-shrunk estimates? Default
TRUE. Only applies whentype = "shrinkage".- interval_prob
Numeric; probability mass for credible intervals. Default 0.95 for 95% intervals. Only applies when
type = "shrinkage".- point_size
Numeric; size of points. Default 3.
- arrow_alpha
Numeric; transparency of arrows (0-1). Default 0.6. Only applies when
show_arrows = TRUE.- dodge_width
Numeric; horizontal spacing between pre-shrunk and post-shrunk estimates in the side-by-side display. Default 0.3. Larger values increase separation between estimate types.
- title
Character; plot title. If
NULL, uses default title.- subtitle
Character; plot subtitle. If
NULL, auto-generates from global mean and tau.- ...
Additional arguments (currently unused).
Value
A ggplot2 object (for type = "shrinkage"), or a patchwork object/list
(for type = "diagnostics").
See also
shrink() for fitting models,
extract_mu_tau() for hyperparameter draws