HorseshoePrior._scale_variance#

HorseshoePrior._scale_variance(scales, context)[source]#

ratio**2 * tau**2 * lambda**2 on the lag block, loose elsewhere.

The raw-coefficient variance the current scales imply: the lag block carries \((s_i / s_j)^2 \tau^2 \lambda_{ij}^2\), and every deterministic and exogenous row carries \((\text{deterministic\_scale} \cdot s_i)^2\). At the initial scales this is what coefficient_variance() reports.

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

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

Return type:

NDArray[double]

Returns:

A (width, k) array of positive variances in design-column order.

Example

At the initial scales, with residual scales one and four, the lag block is the squared unit ratio and the intercept row is a hundred times the squared residual scale:

>>> import numpy as np
>>> from cultivars.bayes.priors import PriorContext
>>> ctx = PriorContext(
...     k_endog=2, order=1, scales=np.array([1.0, 4.0]),
...     presample_mean=np.zeros(2),
... )
>>> prior = HorseshoePrior()
>>> state = prior._initial_scales(ctx, prior._unit_ratio(ctx))
>>> prior._scale_variance(state, ctx)
array([[1.00e+02, 1.60e+03],
       [1.00e+00, 1.60e+01],
       [6.25e-02, 1.00e+00]])