
Extract a report-ready table of Sigma or correlation entries
Source:R/extract-sigma-table.R
extract_Sigma_table.Rdextract_Sigma() returns matrices because that is the most convenient
interactive representation. extract_Sigma_table() returns the same
covariance target as one row per matrix entry so articles, tables, and
plot helpers can work without hand-indexing matrices. It can also turn a
bootstrap_Sigma() result into the same row schema with bootstrap interval
columns filled in.
Arguments
- fit
A fit returned by
gllvmTMB(), an admittedengine = "julia"bridge fit, or abootstrap_Sigma()result.- level
Character vector of covariance levels, or
"all"for every level present in the fit. Canonical levels are"unit","unit_obs","cluster","cluster2","phy", and"spatial"; namedkernel_*()tiers are accepted by their fittedname; legacy aliases"B","W", and"spde"are accepted. ForgllvmTMB_juliaobjects, only"unit"is currently routed;"all"maps to that tier.- part
One of
"total"(default),"shared", or"unique", passed toextract_Sigma().- measure
One of
"covariance"(default) or"correlation". Correlation tables are available only forpart = "total"because the report-ready correlation target is based on the fullLambda Lambda^T + Psicovariance.- entries
Which symmetric matrix entries to return.
"unique"(default) returns the diagonal plus upper triangle, one row per unique estimand."all"returns every cell, useful for heatmaps."upper","lower","offdiag", and"diag"return the corresponding subsets.- link_residual
Passed to
extract_Sigma()."auto"(default) adds family/link implicit residual variances to non-Gaussian trait diagonals;"none"returns only the fitted model-implied covariance.
Value
A data frame with one row per requested entry and stable columns:
estimand, trait_i, trait_j, integer indices i and j, level,
component, matrix, estimate, lower, upper, interval_method,
interval_status, scale, diagonal, and
triangle. Interval columns are NA with interval_method = "none"
because this helper is point-estimate only.
Details
The helper reshapes the same covariance and correlation matrices returned by
extract_Sigma(). A bootstrap_Sigma() object can supply interval columns.
Julia bridge fits currently expose only point estimates for the ordinary unit
tier. The helper does not create profile or Wald intervals.
The table is a point-estimate view over extract_Sigma(). It does not
compute confidence intervals from a fitted model directly. Use
extract_correlations() when you need pairwise correlation intervals, or
bootstrap_Sigma() followed by extract_Sigma_table() when you need
bootstrap intervals for Sigma or correlation matrix entries.
See also
extract_Sigma() for the underlying matrix extractor;
extract_correlations() for pairwise correlation intervals;
bootstrap_Sigma() for bootstrap uncertainty.
Examples
if (FALSE) { # \dontrun{
fit <- gllvmTMB(
value ~ 0 + trait +
latent(0 + trait | unit, d = 2),
data = df,
trait = "trait",
unit = "unit"
)
extract_Sigma_table(fit, level = "unit")
extract_Sigma_table(fit, level = "unit", measure = "correlation")
extract_Sigma_table(fit, level = c("unit", "unit_obs"), entries = "all")
boot <- bootstrap_Sigma(fit, n_boot = 50, level = "unit",
what = "Sigma", progress = FALSE)
extract_Sigma_table(boot, level = "unit", entries = "upper")
} # }