Evaluates the observation-level marginal variance represented by random_effects_marginal_factor_states() without reconstructing dense covariance matrices or recompiling the random-effect formula metadata.

random_effects_marginal_factor_diagonal(factors, by_block = FALSE)

Arguments

factors

a BayesTools_random_effects_marginal_factor_states object.

by_block

whether to return one variance matrix per random-effect block.

Value

A numeric matrix with one posterior draw per row and one fitted observation per column when by_block = FALSE; otherwise a named list of such matrices in fitted random-block order.