Compiles sampled or marginalized formula random-effect metadata into deterministic JAGS nodes containing observation-level covariance contributions. The compiler is intentionally likelihood agnostic: callers provide dependency-preserving row blocks and choose which terms contribute by subsetting the formula design. Sampling latent coordinates does not change their population covariance.

JAGS_formula_random_marginal_covariance(
  formula_design,
  row_blocks,
  prefix = "random_marginal_covariance",
  representation = c("dense", "auto")
)

Arguments

formula_design

a BayesTools_formula_design object created by JAGS_formula().

row_blocks

list of integer vectors partitioning the fitted rows.

prefix

valid JAGS node prefix used for generated nodes and data.

representation

covariance representation to compile. "dense" preserves the lower-triangle interface. "auto" returns the complete structurally certified diagonal-plus-factor representation when available and otherwise uses the dense representation.

Value

A list of class BayesTools_JAGS_random_marginal_covariance with syntax (the JAGS model syntax as one string), data (the named list of data the syntax reads), row_blocks (the validated integer row vectors), representation ("dense", or the diagonal-plus-factor representation that "auto" returns when it is structurally certified), term_names (the compiled random-effect block names), and the node names per row block. Dense results contain one lower-triangle covariance node name per row block in lower_names and NA in diagonal_names and loading_names. Diagonal-plus-factor results instead contain diagonal_names, loading_names (NA for a block without loading columns), and structural loading_ranks. A formula design without random effects returns empty syntax and data.