NormalInverseWishartPrior.coefficient_variance#

NormalInverseWishartPrior.coefficient_variance(context)[source]#

Litterman’s variances with the cross-equation weight at one.

Delegates to MinnesotaPrior.coefficient_variance() through _minnesota(), so an own lag at lag \(l\) gets \((\lambda_1 / l^{\lambda_3})^2\), a cross lag the same times \((s_i / s_j)^2\), and the deterministic and exogenous block \((\lambda_1 \lambda_4 s_i)^2\). Every column of the result is \(s_i^2\) times a column-specific constant, which is the factorization the conjugate estimator checks before it proceeds.

Parameters:

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

Return type:

NDArray[double]

Returns:

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

Raises:

SpecificationError – If a hyperparameter is out of range.

Example

Dividing each column by \(s_i^2\) leaves a column-wise constant, the factorization that makes the posterior exact:

>>> 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),
... )
>>> variance = NormalInverseWishartPrior().coefficient_variance(ctx)
>>> (variance / ctx.scales**2).round(4)
array([[4.0e+02, 4.0e+02],
       [4.0e-02, 4.0e-02],
       [2.5e-03, 2.5e-03]])