qis.regimes.compute_regime_ewm_betas

qis.regimes.compute_regime_ewm_betas(sampled_returns_with_regime_id, benchmark, span=40.0, regime_column='regime')[source]

EWMA-weighted per-regime betas on the benchmark and the calendar-time residual variances.

Within each regime the betas use the regime-time EWMA covariance of the demeaned pair, seeded at the sample covariance, and an intercept at the EWMA means, which is discarded. The idiosyncratic variance is the calendar-time EWMA of the squared pooled residuals.

Parameters:
  • sampled_returns_with_regime_id (DataFrame) – periodic returns with a regime column

  • benchmark (str) – name of the benchmark column

  • span (float) – EWMA span in periods

  • regime_column (str) – name of the regime column

Returns:

the betas, assets in rows and regimes in columns in bucket order, and the per-period residual variance of each asset, to be annualised by the caller

Return type:

Tuple[DataFrame, Series]