Skip to contents

Produces a variety of ggplot2 visualisations for a stacked-trait multivariate GLLVM. Dispatches on type to one of five panels:

Usage

# S3 method for class 'gllvmTMB_multi'
plot(
  x,
  type = c("correlation", "loadings", "integration", "variance", "ordination"),
  level = c("unit", "unit_obs"),
  boot = NULL,
  axes = c(1L, 2L),
  ...
)

Arguments

x

A gllvmTMB_multi fit.

type

One of "correlation", "loadings", "integration", "variance", "ordination".

level

"unit" (between-unit) or "unit_obs" (within-unit). Legacy aliases "B" and "W" are accepted with a deprecation warning. Used by "loadings" (which level to plot; the default c("unit", "unit_obs") means "both available levels, faceted side-by-side"; pass a length-1 string to plot one tier) and "ordination" (single level required, default "unit"). Ignored for "correlation" (which always shows both if available), "integration", and "variance".

Note: the default level = c("unit", "unit_obs") is intentionally a length-2 vector, not the usual match.arg shortcut. The dispatcher does not call match.arg(level) itself; each helper inspects level and decides whether to plot one tier or both. If you copy one of these helpers into your own code, mirror that pattern rather than reflexively calling match.arg(level) (which would silently collapse the default to "B" and drop the W panel).

boot

Optional bootstrap object (currently a list with elements repeatability, communality_B, communality_W, each a data frame with columns trait, lower, upper) used to add whiskers to the "integration" plot. Default NULL skips whiskers.

axes

Length-2 integer vector for "ordination" when d >= 2. Default c(1, 2). Ignored when d = 1.

...

Currently unused.

Value

A ggplot object.

Details

"correlation"

Combined heatmap of trait correlations. Upper triangle = between-unit correlations (level = "unit"), lower triangle = within-unit correlations (level = "unit_obs"), diagonal = 1. Falls back to whichever level is present if the other tier is absent.

"loadings"

Tile heatmap of Lambda_B (and Lambda_W if present), faceted by level. Rows = traits, columns = factors. Pinned cells (from lambda_constraint) are drawn with a heavy outline.

"integration"

Dot-and-whisker plot of repeatability (ICC), between-tier communality and within-tier communality per trait, sorted by repeatability. Optional whiskers from a boot object (skipped if boot = NULL).

"variance"

Stacked-bar variance partition per trait, using extract_proportions(format = "long"). One bar per trait, stacks summing to 1.

"ordination"

Two-axis biplot of latent scores plus loading arrows. 1D fits (d = 1) get a horizontal lollipop; 2D fits get a standard biplot; for d >= 3 pick the axis pair via axes.