DirichletLaplacePrior._initial_scales#

DirichletLaplacePrior._initial_scales(context, reference)[source]#

Uniform simplex, unit local scales, unit global magnitude.

Every \(\phi_{ij}\) starts at \(1/m\), the centre of the simplex, with \(\psi_{ij} = 1\) and \(\tau = 1\), so the first coefficient draw is under a Gaussian of standard deviation \(1/m\) on the standardized scale: tight, and the first sweeps redistribute the budget from there.

Parameters:
  • context (_PriorContext) – The sample description; k_endog and order are read.

  • reference (NDArray[double]) – Data-driven reference scales, ignored: the Dirichlet-Laplace does not anchor on least-squares standard errors.

Return type:

dict[str, NDArray[double]]

Returns:

{"psi", "phi"} of shape (k * p, k) and {"tau"} of shape (1,); phi sums to one.

Raises:

SpecificationError – If a hyperparameter is out of range.

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 = DirichletLaplacePrior()
>>> state = prior._initial_scales(ctx, prior._unit_ratio(ctx))
>>> state["phi"]
array([[0.25, 0.25],
       [0.25, 0.25]])
>>> state["psi"].sum(), state["tau"]
(np.float64(4.0), array([1.]))