qis.regimes.compute_regime_mixture_covar_from_sample

qis.regimes.compute_regime_mixture_covar_from_sample(sampled_returns_with_regime_id, benchmark, af, betas=None, regime_column='regime')[source]

Annualised regime-mixture covariance of one complete classified panel.

Equation (10) of Sepp and Kastenholz (2026) in one call. The betas come from compute_regime_betas unless a frozen sheet is supplied, and compute_regime_mixture_covar assembles the covariance with the empirical regime frequencies and the population benchmark moments of compute_sample_regime_moments, all over the classified periods. The residual volatilities keep the sample convention of compute_regime_betas (ddof=1). Residuals are uncorrelated across assets and with the benchmark, and the fitted regime intercepts are discarded. A ragged panel is rejected: choose the common sample before classifying it.

Parameters:
  • sampled_returns_with_regime_id (DataFrame) – periodic simple returns with a regime column; unclassified periods are excluded and every other asset return must be finite. The regime label total, in any case, is reserved by the beta_total column

  • benchmark (str) – name of the benchmark column, inserted first with unit betas and zero residual

  • af (float) – annualisation factor of the periodic returns, finite and positive

  • betas (DataFrame | None) – optional frozen sheet in the format of compute_regime_betas, indexed by exactly the non-benchmark assets, with beta_<regime id in lower case> columns and a finite, non-negative idio_vol annualised with the same af; other columns are ignored. None estimates the betas on this panel, which needs 24 periods and two distinct benchmark returns in every regime

  • regime_column (str) – name of the regime column

Returns:

the annualised covariance, the benchmark first and then the other assets in the panel’s column order. On a full sample it is descriptive; a rolling caller passes only the periods, and frozen betas, known at the decision date, and answers for the estimation dates and the annualisation of frozen betas

Raises:

ValueError – if the panel, af, the identification of a regression or the frozen betas are invalid

Return type:

DataFrame