Gerber Covariance

The Gerber Covariance replaces the correlation by the Gerber statistic, which counts only the periods in which returns move beyond a threshold (Gerber, Markowitz, Ernst, Miao, Javid and Sargen, 2022). Small moves, which are mostly noise, do not count, and neither does the size of large ones, so a few extreme returns do not dominate it.

The formula for the Gerber Covariance starts from the indicators \(U_{t , i}\) of an up move, a return \(r_{t , i}\) of at least c times the standard deviation \(s_{i}\) (ddof=1), and \(D_{t , i}\) of a down move, at most -c times it, with c the threshold, and counts per pair of assets the periods of concordant moves \(n_{c}\), of discordant moves \(n_{d}\) and of neither moving \(n_{n}\):

\[n_{c} = \sum_{t=1}^{T} (U_{t,i} \cdot U_{t,j} + D_{t,i} \cdot D_{t,j})\] \[n_{d} = \sum_{t=1}^{T} (U_{t,i} \cdot D_{t,j} + D_{t,i} \cdot U_{t,j})\] \[n_{n} = \sum_{t=1}^{T} (1 - U_{t,i} - D_{t,i}) \cdot (1 - U_{t,j} - D_{t,j})\]

The Gerber statistic \(g_{i , j}\) takes the concordant minus the discordant moves over the periods in which at least one of the two moved (the default statistic), over those in which both moved (the original statistic), or, with \(H_{i , j} = n_{c} - n_{d}\), over the square root of its diagonal (the matrix form):

\[g_{i,j} = \frac{n_{c} - n_{d}}{T - n_{n}}\] \[g_{i,j} = \frac{n_{c} - n_{d}}{n_{c} + n_{d}}\] \[g_{i,j} = \frac{H_{i,j}}{\sqrt{H_{i,i} \cdot H_{j,j}}}\]

The covariance scales it by the standard deviations:

\[\Sigma_{i,j} = g_{i,j} \cdot s_{i} \cdot s_{j}\]

Gerber et al. found that it leads to portfolios that did better out of sample than those of the sample covariance, as it is less affected by noise and outliers; the original statistic need not give a positive semidefinite matrix, which is then replaced by the nearest one.

Its parameters can be set, and it can be shown as a correlation matrix. The covariance matrix holds the variance of every asset and the covariance of every pair, the risk input of the mean-variance analysis of Markowitz (1952). With N assets it holds N (N + 1) / 2 numbers to estimate, and when N is not small compared to the number of periods T, the sample estimate is noisy and ill-conditioned: its smallest eigenvalues come out too small, and an optimizer that inverts it puts large weights on the combinations of assets that only look safe in the sample. The estimators differ in how they deal with this: by shrinking towards a structured target, by cleaning the eigenvalues, by weighting recent periods, by counting only large moves or by resisting outliers. Every estimate is annualized with the number of periods in a year.

Also known as: Gerber statistic, Gerber matrix.

In the Finance Toolkit this is get_covariance_estimate with method="gerber", the same function as Covariance Estimate.

Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_covariance_estimate:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "JNJ", "XOM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.portfolio.get_covariance_estimate(method="gerber")

Which returns:

References

  • Paper Gerber, S., Markowitz, H. M., Ernst, P. A., Miao, Y., Javid, B. and Sargen, P. (2022). “The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization.” The Journal of Portfolio Management, 48(3), 87-102.
  • Library Referenced against skfolio’s GerberCovariance (Gerber Covariance, statistics 1 and 2)
  • Library Referenced against Riskfolio-Lib’s gerber_cov_stat0 (Gerber Covariance, statistic 0)
  • Library Shares similar logic as Riskfolio-Lib’s gerber_cov_stat1 (Gerber Covariance, statistic 1)
  • Library Shares similar logic as Riskfolio-Lib’s gerber_cov_stat2 (Gerber Covariance, statistic 2)
Share