Compiles the draw- and candidate-varying coefficient state for an exact non-affine random-effect covariance update. The output remains compact in the number of posterior draws and grid values; it does not materialize one random-effect state for every draw-by-grid combination.

random_effects_marginal_update_grid(
  fit,
  update,
  values,
  posterior_samples = NULL,
  prior_list = NULL
)

Arguments

fit

a fitted object carrying formula random-effect metadata.

update

a plan returned by random_effects_marginal_update_plan().

values

finite candidate values on the scale declared by update. Source-coordinate factor updates replace source_parameter in the posterior. Quantity-scale factor updates accept non-negative values of the selected SD or variance; variance values are converted to SDs using the plan's coefficient_scale_transform.

posterior_samples

optional posterior sample object. By default the posterior is obtained from fit.

prior_list

optional formula prior list used to reconstruct random SD bindings. By default it is obtained from fit.

Value

A list of class BayesTools_random_effects_marginal_update_grid. Factor updates contain posterior coefficient scales, correlation Cholesky factors, and the selected candidate scales. The candidate scale replaces the scale of column component_index only for a plan that holds the sibling SDs fixed (a direct per-column SD), and of every column in driven_columns when the direct SD is shared by several columns. For a plan with held_fixed = "allocation_weights" (an allocation-derived component SD) the grid also contains column_factor (values by posterior draws), the factor candidate_scale / coefficient_scale[, component_index] by which the scale of every driven column (driven_columns, all columns when it is NULL) is multiplied; it is NA for the draws where the current selected SD is zero, which no allocation scale maps to a non-zero (or an unchanged zero) candidate. Markov updates contain posterior coefficient scales plus candidate correlation Cholesky factors, transitions, and innovation variances.

Details

This accessor supports plans whose family is "factor" or "markov". Every state is evaluated by the same compiled formula machinery used by random_effects_marginal_factor_states(). No covariance form is inferred from posterior samples or candidate covariance matrices.