Gerber covariance

The Gerber statistic is a vote-based robust co-movement measure. It ignores fluctuations below a threshold while limiting the effect of extreme movements. It extends Kendall's Tau coefficient by counting the proportion of concordant and discordant movements within the window defined by the upper and lower limits [12].

Three variants have been published and all three have been implemented because each has unique characteristics [13].

Abstract Gerber covariance types

These serve as the scaffolding for defining Gerber covariance estimators and algorithms.

PortfolioOptimisers.BaseGerberCovarianceType
abstract type BaseGerberCovariance <: AbstractCovarianceEstimator

Abstract supertype for all Gerber covariance estimators.

All concrete and/or abstract types implementing Gerber covariance estimation algorithms should be subtypes of BaseGerberCovariance.

Interfaces

If moving away from the already established Gerber covariance algorithms, you must follow AbstractCovarianceEstimator to implement the entire chain.

Related

References

  • [12] S. Gerber, H. Markowitz, P. Ernst, Y. Miao, P. Sargen and others. The Gerber statistic: A robust co-movement measure for portfolio optimization. Available at SSRN 3880054 (2021).
  • [13] E. Flint and D. Polakow. Deconstructing the Gerber statistic. Finance Research Letters 56, 104144 (2023).
source
PortfolioOptimisers.GerberCovarianceAlgorithmType
abstract type GerberCovarianceAlgorithm <: AbstractMomentAlgorithm

Abstract supertype for all Gerber covariance algorithm types.

All concrete and/or abstract types implementing specific Gerber covariance algorithms should be subtypes of GerberCovarianceAlgorithm. These types are used to specify the algorithm when constructing a GerberCovariance estimator. A subtype selects the denominator that comovement_ratio puts under the net co-movement vote, so a new subtype is a new method of that function.

Interfaces

If moving away from the already established Gerber covariance algorithms, you must follow AbstractCovarianceEstimator to implement the entire chain.

Related

References

  • [12] S. Gerber, H. Markowitz, P. Ernst, Y. Miao, P. Sargen and others. The Gerber statistic: A robust co-movement measure for portfolio optimization. Available at SSRN 3880054 (2021).
source

Concrete Gerber covariance implementations

These define the concrete implementations of the Gerber covariance estimators and algorithms.

PortfolioOptimisers.Gerber0Type
struct Gerber0 <: GerberCovarianceAlgorithm

Normalises the net co-movement vote by the observations on which both assets crossed their threshold. This is the original Gerber statistic.

Mathematical definition

\[\begin{align} \rho_{i,\,j} &= \frac{n_{c} - n_{d}}{n_{c} + n_{d}}\,. \end{align}\]

Where:

  • $\rho_{i,\,j}$: Pairwise correlation coefficient between assets $i$ and $j$.
  • $n_{c}$: Concordant count of a pair, the observations on which both assets crossed their thresholds in the same direction.
  • $n_{d}$: Discordant count of a pair, the observations on which both assets crossed their thresholds in opposite directions.

An observation votes only when both assets cross, so an observation on which exactly one asset crossed leaves the statistic unchanged. The denominator vanishes when no observation moved both assets, and the statistic is zero there.

Algorithm

The branch of comovement_ratio that this tag selects runs these steps.

  1. Add the concordant and discordant counts into the denominator den.
  2. Return zero(T) when den is zero. An asset that never crosses its own threshold gives that case for every pair it belongs to.
  3. Otherwise return (p - n) / den.

Constructors

Gerber0() -> Gerber0

Examples

julia> Gerber0()Gerber0()

Related

References

  • [12] S. Gerber, H. Markowitz, P. Ernst, Y. Miao, P. Sargen and others. The Gerber statistic: A robust co-movement measure for portfolio optimization. Available at SSRN 3880054 (2021).
source
PortfolioOptimisers.Gerber1Type
struct Gerber1 <: GerberCovarianceAlgorithm

Normalises the net co-movement vote by every observation on which at least one asset crossed its threshold.

Mathematical definition

\[\begin{align} \rho_{i,\,j} &= \frac{n_{c} - n_{d}}{n_{c} + n_{d} + n_{n}}\,. \end{align}\]

Where:

  • $\rho_{i,\,j}$: Pairwise correlation coefficient between assets $i$ and $j$.
  • $n_{c}$: Concordant count of a pair, the observations on which both assets crossed their thresholds in the same direction.
  • $n_{d}$: Discordant count of a pair, the observations on which both assets crossed their thresholds in opposite directions.
  • $n_{n}$: Neutral count of a pair, the observations on which exactly one of the two assets crossed its threshold.

The denominator carries $n_{n}$ on top of Gerber0's, so it is never smaller and the statistic is never larger in magnitude. The two agree when every crossing is shared.

Algorithm

The branch of comovement_ratio that this tag selects runs these steps.

  1. Add the concordant, discordant and neutral counts into the denominator den.
  2. Return zero(T) when den is zero. An asset that never crosses its own threshold gives that case for every pair it belongs to.
  3. Otherwise return (p - n) / den.

Constructors

Gerber1() -> Gerber1

Examples

julia> Gerber1()Gerber1()

Related

References

  • [12] S. Gerber, H. Markowitz, P. Ernst, Y. Miao, P. Sargen and others. The Gerber statistic: A robust co-movement measure for portfolio optimization. Available at SSRN 3880054 (2021).
source
PortfolioOptimisers.Gerber2Type
struct Gerber2 <: GerberCovarianceAlgorithm

Normalises the raw net co-movement vote by the geometric mean of its own diagonal.

Mathematical definition

\[\begin{align} h_{i,\,j} &= n_{c} - n_{d}\,, \\ \rho_{i,\,j} &= \frac{h_{i,\,j}}{\sqrt{h_{i,\,i} \, h_{j,\,j}}}\,. \end{align}\]

Where:

  • $\rho_{i,\,j}$: Pairwise correlation coefficient between assets $i$ and $j$.
  • $h_{i,\,j}$: Net co-movement vote of the pair, before any normalisation.
  • $n_{c}$: Concordant count of a pair, the observations on which both assets crossed their thresholds in the same direction.
  • $n_{d}$: Discordant count of a pair, the observations on which both assets crossed their thresholds in opposite directions.

The normalisation is a property of the whole matrix and not of one pair, so the diagonal is unit by construction rather than by a per-pair denominator as in Gerber0 and Gerber1. An asset crosses concordantly with itself at every crossing, so $h_{i,\,i}$ counts the crossings of asset $i$.

Algorithm

The branch of comovement_ratio and of standardise_comovement! that this tag selects runs these steps.

  1. Return the raw difference p - n for every pair. This branch applies no denominator of its own.
  2. Divide the assembled matrix by the outer product of the square roots of its own diagonal. The roots are clamped from below by sqrt(eps(eltype(rho))), so an asset that never crosses gives a zero row rather than a division by zero.

Constructors

Gerber2() -> Gerber2

Examples

julia> Gerber2()Gerber2()

Related

References

  • [12] S. Gerber, H. Markowitz, P. Ernst, Y. Miao, P. Sargen and others. The Gerber statistic: A robust co-movement measure for portfolio optimization. Available at SSRN 3880054 (2021).
source
PortfolioOptimisers.GerberCovarianceType
struct GerberCovariance{__T_ve, __T_me, __T_pdm, __T_t, __T_alg} <: BaseGerberCovariance

Configures and applies Gerber covariance estimators.

GerberCovariance encapsulates all components required for Gerber-based covariance or correlation estimation, including the variance estimator, positive definite matrix estimator, t parameter, and the specific Gerber algorithm variant. A Gerber matrix is a matrix of pairwise votes and is not positive definite in general, so pdm projects the result onto the nearest positive definite matrix; pdm = nothing returns the raw statistic instead.

Fields

  • ve: Variance estimator.
  • me: Expected returns estimator. Used for centering the returns.
  • pdm: Positive definite matrix estimator.
  • t: Threshold value.
  • alg: Gerber covariance algorithm.

Constructors

GerberCovariance(;    ve::StatsBase.CovarianceEstimator = SimpleVariance(),    me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns(),    pdm::Option{<:AbstractPosdefEstimator} = Posdef(),    t::Number = 0.5,    alg::GerberCovarianceAlgorithm = Gerber1()) -> GerberCovariance

Keywords correspond to the struct's fields.

Validation

  • 0 <= t.

Propagated parameters

When factory is called on this type, the following @fprop-tagged fields are automatically propagated:

  • ve: Recursively updated via factory.
  • me: Recursively updated via factory.
  • alg: Recursively updated via factory.

View parameters

When port_opt_view is called on this type, the following @vprop-tagged fields are automatically subset to the selected indices:

Examples

julia> GerberCovariance()GerberCovariance   ve ┼ SimpleVariance      │          me ┼ SimpleExpectedReturns      │             │   w ┴ nothing      │           w ┼ nothing      │   corrected ┴ Bool: true   me ┼ SimpleExpectedReturns      │   w ┴ nothing  pdm ┼ Posdef      │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton      │   kwargs ┴ @NamedTuple{}: NamedTuple()    t ┼ Float64: 0.5  alg ┴ Gerber1()

Related

References

  • [12] S. Gerber, H. Markowitz, P. Ernst, Y. Miao, P. Sargen and others. The Gerber statistic: A robust co-movement measure for portfolio optimization. Available at SSRN 3880054 (2021).
source
Statistics.covMethod
Statistics.cov(
    ce::GerberCovariance,
    X::MatNum;
    dims::Int = 1,
    kwargs...
) -> MatNum

Compute the Gerber covariance matrix using the algorithm specified in ce.alg.

Mathematical definition

\[\begin{align} \hat{\mathbf{\Sigma}} &= \mathrm{Diag}(\boldsymbol{\sigma}) \, \hat{\boldsymbol{\rho}} \, \mathrm{Diag}(\boldsymbol{\sigma})\,. \end{align}\]

Where:

  • $\hat{\mathbf{\Sigma}}$: Gerber covariance matrix.
  • $\hat{\boldsymbol{\rho}}$: Gerber correlation matrix of the same estimator.
  • $\boldsymbol{\sigma}$: Standard deviation vector of the assets.

The Gerber statistic sets the correlations alone, so the variances come from ce.ve and the diagonal of $\hat{\mathbf{\Sigma}}$ is $\boldsymbol{\sigma}^2$.

Algorithm

  1. Orient X to observations × assets with dims_oriented.
  2. Compute the standard deviation vector sd with ce.ve, and raise each entry to at least eps(eltype(sd)). A constant column leaves a standard deviation and a centring residual of the same round-off order, so the unraised threshold marks every one of its observations as a crossing; the raised threshold marks none of them.
  3. Centre the returns with ce.me through demean_returns.
  4. Compute the Gerber correlation matrix sigma with gerber, through the branch that ce.alg selects.
  5. Rescale sigma in place to a covariance matrix with StatsBase.cor2cov! and sd.

Arguments

  • ce: Gerber covariance estimator.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • dims: Dimension along which to perform the computation.
  • kwargs...: Additional keyword arguments passed to the standard deviation estimator.

Validation

  • dims in (1, 2).

Returns

  • sigma::MatNum: Covariance matrix assets x assets.

Related

References

  • [12] S. Gerber, H. Markowitz, P. Ernst, Y. Miao, P. Sargen and others. The Gerber statistic: A robust co-movement measure for portfolio optimization. Available at SSRN 3880054 (2021).
source
Statistics.corMethod
Statistics.cor(
    ce::GerberCovariance,
    X::MatNum;
    dims::Int = 1,
    kwargs...
) -> MatNum

Compute the Gerber correlation matrix using the algorithm specified in ce.alg.

Algorithm

  1. Orient X to observations × assets with dims_oriented.
  2. Compute the standard deviation vector sd with ce.ve, and raise each entry to at least eps(eltype(sd)). A constant column leaves a standard deviation and a centring residual of the same round-off order, so the unraised threshold marks every one of its observations as a crossing; the raised threshold marks none of them.
  3. Centre the returns with ce.me through demean_returns.
  4. Return the Gerber correlation matrix from gerber, through the branch that ce.alg selects.

Arguments

  • ce: Gerber covariance estimator.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • dims: Dimension along which to perform the computation.
  • kwargs...: Additional keyword arguments passed to the standard deviation estimator.

Validation

  • dims in (1, 2).

Returns

  • rho::MatNum: Correlation matrix assets x assets.

Related

References

  • [12] S. Gerber, H. Markowitz, P. Ernst, Y. Miao, P. Sargen and others. The Gerber statistic: A robust co-movement measure for portfolio optimization. Available at SSRN 3880054 (2021).
source

References

[12]
S. Gerber, H. Markowitz, P. Ernst, Y. Miao, P. Sargen and others. The Gerber statistic: A robust co-movement measure for portfolio optimization. Available at SSRN 3880054 (2021).
[13]
E. Flint and D. Polakow. Deconstructing the Gerber statistic. Finance Research Letters 56, 104144 (2023).