DirichletLaplacePrior._scale_variance#

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

ratio**2 * psi * (phi * tau)**2 on the lag block, loose elsewhere.

The raw-coefficient variance the current state implies: the lag block carries \((s_i / s_j)^2 \psi_{ij} \phi_{ij}^2 \tau^2\), the normal-mixture representation of the Laplace at the current mixing scale, 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 four lag coefficients, the lag block is the squared unit ratio over sixteen:

>>> 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 = DirichletLaplacePrior()
>>> state = prior._initial_scales(ctx, prior._unit_ratio(ctx))
>>> prior._scale_variance(state, ctx)
array([[1.00000e+02, 1.60000e+03],
       [6.25000e-02, 1.00000e+00],
       [3.90625e-03, 6.25000e-02]])