SpikeAndSlabPrior._tracked#

SpikeAndSlabPrior._tracked(scales, context)[source]#

The Rao-Blackwellized inclusion probability per lag coefficient.

The conditional probability from the last sweep rather than the binary indicator: averaging the exact conditional over sweeps estimates the marginal inclusion probability with less Monte Carlo error than averaging zero-one draws. The sampler accumulates this into the result’s shrinkage; deterministic and exogenous rows are reported as zero because they are never candidates.

Parameters:
  • scales (dict[str, NDArray[double]]) – The current latent state.

  • context (_PriorContext) – The sample description; width, k_endog, order, and lag_offset are read.

Return type:

NDArray[double]

Returns:

A (width, k) array in [0, 1], zero off the lag block.

Example

>>> import numpy as np
>>> from cultivars.bayes.priors import PriorContext
>>> ctx = PriorContext(
...     k_endog=2, order=1, scales=np.ones(2), presample_mean=np.zeros(2)
... )
>>> prior = SpikeAndSlabPrior(inclusion=0.2)
>>> state = prior._initial_scales(ctx, np.full((3, 2), 0.05))
>>> prior._tracked(state, ctx)
array([[0. , 0. ],
       [0.2, 0.2],
       [0.2, 0.2]])