FactorSVResult.conditional_covariance#

FactorSVResult.conditional_covariance()[source]#

Posterior-mean conditional covariance Lambda H_t Lambda' + D_t, (T, k, k).

Averaged over draws, so it is the posterior mean of the covariance rather than the covariance at the posterior mean; the two differ by the posterior uncertainty in loadings and paths. Symmetric and positive definite at every date, since each draw’s \(\Lambda H_t \Lambda'\) is positive semidefinite and \(D_t\) is positive.

Return type:

NDArray[double]

Returns:

An array of shape (T, k, k).

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> f = rng.standard_normal(200)
>>> y = np.outer(f, [1.0, 0.8, 0.6]) + 0.3 * rng.standard_normal((200, 3))
>>> res = FactorSV(y, n_factors=1).fit(n_draws=200, n_burn=50, seed=0)
>>> cov = res.conditional_covariance()
>>> cov.shape, bool(np.allclose(cov, np.swapaxes(cov, 1, 2)))
((200, 3, 3), True)
>>> bool(min(np.linalg.eigvalsh(c).min() for c in cov) > 0)
True
>>> bool(abs(cov[:, 0, 1].mean() - 0.8) < 0.2)
True