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 [5].
Three variants have been published and all three have been implemented because each has unique characteristics [6]. We have also implemented extensions which Z-normalise the data and thus treat the thresholds as relative rather than absolute values.
PortfolioOptimisers.Gerber0 Type
struct Gerber0 <: UnstandardisedGerberCovarianceAlgorithm endImplements the original Gerber covariance algorithm.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.Gerber1 Type
struct Gerber1 <: UnstandardisedGerberCovarianceAlgorithm endImplements the first variant of the Gerber covariance algorithm.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.Gerber2 Type
struct Gerber2 <: UnstandardisedGerberCovarianceAlgorithm endImplements the second variant of the Gerber covariance algorithm.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.StandardisedGerber0 Type
struct StandardisedGerber0{T1} <: StandardisedGerberCovarianceAlgorithm
me::T1
endImplements the original Gerber covariance algorithm on Z-transformed data.
Fields
me: Expected returns estimator used for mean-centering prior to normalisation.
Constructor
StandardisedGerber0(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())Keyword arguments correspond to the fields above.
Examples
julia> StandardisedGerber0()
StandardisedGerber0
me ┼ SimpleExpectedReturns
│ w ┴ nothingRelated
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.StandardisedGerber1 Type
struct StandardisedGerber1{T1} <: StandardisedGerberCovarianceAlgorithm
me::T1
endImplements the first variant of the Gerber covariance algorithm on Z-transformed data.
Fields
me: Expected returns estimator used for mean-centering prior to normalisation.
Constructor
StandardisedGerber1(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())Keyword arguments correspond to the fields above.
Examples
julia> StandardisedGerber1()
StandardisedGerber1
me ┼ SimpleExpectedReturns
│ w ┴ nothingRelated
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.StandardisedGerber2 Type
struct StandardisedGerber2{T1} <: StandardisedGerberCovarianceAlgorithm
me::T1
endImplements the second variant of the Gerber covariance algorithm on Z-transformed data.
Fields
me: Expected returns estimator used for mean-centering prior to normalisation.
Constructor
StandardisedGerber2(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())Keyword arguments correspond to the fields above.
Examples
julia> StandardisedGerber2()
StandardisedGerber2
me ┼ SimpleExpectedReturns
│ w ┴ nothingRelated
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.GerberCovariance Type
struct GerberCovariance{T1, T2, T3, T4} <: BaseGerberCovariance
ve::T1
pdm::T2
t::T3
alg::T4
endA flexible container type for configuring and applying Gerber covariance estimators in PortfolioOptimisers.jl.
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.
Fields
ve: Variance estimator.pdm: Positive definite matrix estimator (seePosdef).t: Threshold parameter for Gerber covariance computation.alg: Gerber covariance algorithm variant.
Constructor
GerberCovariance(; ve::StatsBase.CovarianceEstimator = SimpleVariance(),
pdm::Option{<:Posdef} = Posdef(), t::Number = 0.5,
alg::GerberCovarianceAlgorithm = Gerber1())Keyword arguments correspond to the fields above.
Validation
0 < t < 1.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
Statistics.cov Method
Statistics.cov(ce::GerberCovariance, X::MatNum; dims::Int = 1, kwargs...)Compute the Gerber covariance matrix using the algorithm specified in ce.alg.
Arguments
ce::GerberCovariance: Gerber covariance estimator.ce::GerberCovariance{<:Any, <:Any, <:Any, <:UnstandardisedGerberCovarianceAlgorithm}: Compute the unstandardised Gerber covariance matrix.ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerberCovarianceAlgorithm}: Compute the standardised Gerber covariance matrix.
X: Data matrix (observations × assets).dims: Dimension along which to compute the covariance.kwargs...: Additional keyword arguments passed to the standard deviation estimator.
Returns
sigma::Matrix{<:Number}: The Gerber covariance matrix.
Validation
dimsis either1or2.
Details
Computes the standard deviation vector for each asset using the estimator's variance estimator.
If using a standardised algorithm, Z-transforms the data prior to Gerber correlation computation.
Computes the Gerber correlation matrix using the Gerber algorithm in
ce.alg.Rescales the Gerber correlation matrix to a covariance matrix by multiplying with the standard deviation vector outer product.
Related
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber0}, X::MatNum, std_vec::ArrNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber1}, X::MatNum, std_vec::ArrNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber2}, X::MatNum, std_vec::ArrNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber0}, X::MatNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber1}, X::MatNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber2}, X::MatNum)cor(ce::GerberCovariance, X::MatNum; dims::Int = 1, kwargs...)
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
Statistics.cor Method
Statistics.cor(ce::GerberCovariance, X::MatNum; dims::Int = 1, kwargs...)Compute the Gerber correlation matrix using an unstandardised Gerber covariance estimator.
Arguments
ce::GerberCovariance: Gerber covariance estimator.ce::GerberCovariance{<:Any, <:Any, <:Any, <:UnstandardisedGerberCovarianceAlgorithm}: Compute the unstandardised Gerber correlation matrix.ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerberCovarianceAlgorithm}: Compute the standardised Gerber correlation matrix.
X: Data matrix (observations × assets).dims: Dimension along which to compute the correlation.kwargs...: Additional keyword arguments passed to the standard deviation estimator.
Returns
rho::Matrix{<:Number}: The Gerber correlation matrix.
Validation
dimsis either1or2.
Details
Computes the standard deviation vector for each asset using the estimator's variance estimator.
If using a standardised algorithm, Z-transforms the data prior to Gerber correlation computation.
Computes the Gerber correlation matrix using the Gerber algorithm in
ce.alg.
Related
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber0}, X::MatNum, std_vec::ArrNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber1}, X::MatNum, std_vec::ArrNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber2}, X::MatNum, std_vec::ArrNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber0}, X::MatNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber1}, X::MatNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber2}, X::MatNum)cov(ce::GerberCovariance, X::MatNum; dims::Int = 1, kwargs...)
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.BaseGerberCovariance Type
abstract type BaseGerberCovariance <: AbstractCovarianceEstimator endAbstract supertype for all Gerber covariance estimators in PortfolioOptimisers.jl.
All concrete and/or abstract types implementing Gerber covariance estimation algorithms should be subtypes of BaseGerberCovariance.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.GerberCovarianceAlgorithm Type
abstract type GerberCovarianceAlgorithm <: AbstractMomentAlgorithm endAbstract supertype for all Gerber covariance algorithm types in PortfolioOptimisers.jl.
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.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.UnstandardisedGerberCovarianceAlgorithm Type
abstract type UnstandardisedGerberCovarianceAlgorithm <: GerberCovarianceAlgorithm endAbstract supertype for all unstandardised Gerber covariance algorithm types.
Concrete types implementing unstandardised Gerber covariance algorithms should subtype UnstandardisedGerberCovarianceAlgorithm.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.StandardisedGerberCovarianceAlgorithm Type
abstract type StandardisedGerberCovarianceAlgorithm <: GerberCovarianceAlgorithm endAbstract supertype for all standardised Gerber covariance algorithm types. These Z-transform the data before applying the Gerber covariance algorithm.
Concrete types implementing standardised Gerber covariance algorithms should subtype StandardisedGerberCovarianceAlgorithm.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.gerber Method
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber0}, X::MatNum,
std_vec::ArrNum)Implements the original Gerber correlation algorithm.
This method computes the Gerber correlation or correlation matrix for the input data matrix X using the original Gerber0 algorithm. The computation is based on thresholding the standardized data and counting co-occurrences of threshold exceedances.
Arguments
ce: Gerber correlation estimator configured with theGerber0algorithm.X: Data matrix (observations × assets).std_vec: Vector of standard deviations for each asset, used to scale the threshold.
Returns
rho::Matrix{<:Number}: The Gerber correlation, projected to be positive definite using the estimator'spdmfield.
Details
The algorithm proceeds as follows:
- For each entry in
X, compute two Boolean matrices:
U: Entries whereXexceedst * std_vec.D: Entries whereXis less than-t * std_vec.
Compute
UmD = U - DandUpD = U + D.The Gerber correlation is given by
(UmD' * UmD) ⊘ (UpD' * UpD).The result is projected to the nearest positive definite matrix using
posdef!.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.gerber Method
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber0}, X::MatNum)Implements the original Gerber correlation algorithm on Z-transformed data.
This method computes the Gerber correlation or correlation matrix for the input data matrix X using the original StandardisedGerber0 algorithm. The computation is performed on data that has already been Z-transformed (mean-centered and standardised), and is based on thresholding and counting co-occurrences of threshold exceedances.
Arguments
ce: Gerber correlation estimator configured with theStandardisedGerber0algorithm.X: Z-transformed data matrix (observations × assets).
Returns
rho::Matrix{<:Number}: The Gerber correlation matrix, projected to be positive definite using the estimator'spdmfield.
Details
The algorithm proceeds as follows:
- For each entry in
X, compute two Boolean matrices:
U: Entries whereXexceedsce.t.D: Entries whereXis less than-ce.t.
Compute
UmD = U - DandUpD = U + D.The Gerber correlation is given by
(UmD' * UmD) ⊘ (UpD' * UpD).The result is projected to the nearest positive definite matrix using
posdef!.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.gerber Method
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber1}, X::MatNum,
std_vec::ArrNum)Implements the first variant of the Gerber correlation algorithm.
This method computes the Gerber correlation or correlation matrix for the input data matrix X using the Gerber1 algorithm. The computation is based on thresholding the standardized data, counting co-occurrences of threshold exceedances, and adjusting for non-exceedance events.
Arguments
ce: Gerber correlation estimator configured with theGerber1algorithm.X: Data matrix (observations × assets).std_vec: Vector of standard deviations for each asset, used to scale the threshold.
Returns
rho::Matrix{<:Number}: The Gerber correlation matrix, projected to be positive definite using the estimator'spdmfield.
Details
The algorithm proceeds as follows:
- For each entry in
X, compute three Boolean matrices:
U: Entries whereXexceedst * std_vec.D: Entries whereXis less than-t * std_vec.N: Entries whereXis within[-t * std_vec, t * std_vec](i.e., neither up nor down).
Compute
UmD = U - D.The Gerber1 correlation is given by
(UmD' * UmD) ⊘ (T .- (N' * N)), whereTis the number of observations.The result is projected to the nearest positive definite matrix using
posdef!.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.gerber Method
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber1}, X::MatNum)Implements the first variant of the Gerber correlation algorithm on Z-transformed data.
This method computes the Gerber correlation or correlation matrix for the input data matrix X using the StandardisedGerber1 algorithm. The computation is performed on data that has already been Z-transformed (mean-centered and standardised), and is based on thresholding, counting co-occurrences of threshold exceedances, and adjusting for non-exceedance events.
Arguments
ce: Gerber correlation estimator configured with theStandardisedGerber1algorithm.X: Z-transformed data matrix (observations × assets).
Returns
rho::Matrix{<:Number}: The Gerber correlation matrix, projected to be positive definite using the estimator'spdmfield.
Details
The algorithm proceeds as follows:
- For each entry in
X, compute three Boolean matrices:
U: Entries whereXexceedsce.t.D: Entries whereXis less than-ce.t.N: Entries whereXis within[-ce.t, ce.t](i.e., neither up nor down).
Compute
UmD = U - D.The Gerber1 correlation is given by
(UmD' * UmD) ⊘ (T .- (N' * N)), whereTis the number of observations.The result is projected to the nearest positive definite matrix using
posdef!.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.gerber Method
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber2}, X::MatNum,
std_vec::ArrNum)Implements the second variant of the Gerber correlation algorithm.
This method computes the Gerber correlation or correlation matrix for the input data matrix X using the Gerber2 algorithm. The computation is based on thresholding the standardized data, constructing a signed indicator matrix, and normalizing by the geometric mean of diagonal elements.
Arguments
ce: Gerber correlation estimator configured with theGerber2algorithm.X: Data matrix (observations × assets).std_vec: Vector of standard deviations for each asset, used to scale the threshold.
Returns
rho::Matrix{<:Number}: The Gerber correlation or correlation matrix, projected to be positive definite using the estimator'spdmfield.
Details
The algorithm proceeds as follows:
- For each entry in
X, compute two Boolean matrices:
U: Entries whereXexceedst * std_vec.D: Entries whereXis less than-t * std_vec.
Compute the signed indicator matrix
UmD = U - D.Compute the raw Gerber2 matrix
H = UmD' * UmD.Normalize:
rho = H ⊘ (h * h'), whereh = sqrt.(LinearAlgebra.diag(H)).The result is projected to the nearest positive definite matrix using
posdef!.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.gerber Method
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber2}, X::MatNum)Implements the second variant of the Gerber correlation algorithm on Z-transformed data.
This method computes the Gerber correlation or correlation matrix for the input data matrix X using the StandardisedGerber2 algorithm. The computation is performed on data that has already been Z-transformed (mean-centered and standardised), and is based on thresholding, constructing a signed indicator matrix, and normalizing by the geometric mean of diagonal elements.
Arguments
ce: Gerber correlation estimator configured with theStandardisedGerber2algorithm.X: Z-transformed data matrix (observations × assets).
Returns
rho::Matrix{<:Number}: The Gerber correlation matrix, projected to be positive definite using the estimator'spdmfield.
Details
The algorithm proceeds as follows:
- For each entry in
X, compute two Boolean matrices:
U: Entries whereXexceedsce.t.D: Entries whereXis less than-ce.t.
Compute the signed indicator matrix
UmD = U - D.Compute the raw Gerber2 matrix
H = UmD' * UmD.Normalize:
rho = H ⊘ (h * h'), whereh = sqrt.(LinearAlgebra.diag(H)).The result is projected to the nearest positive definite matrix using
posdef!.
Related
References
- [5] Gerber, Sander and Markowitz, Harry and Ernst, Philip and Miao, Yinsen and Name, No and Sargen, Paul, The Gerber Statistic: A Robust Co-Movement Measure for Portfolio Optimization (July 4, 2021). Available at SSRN: https://ssrn.com/abstract=3880054 or http://dx.doi.org/10.2139/ssrn.3880054
PortfolioOptimisers.factory Method
factory(alg::Gerber0, ::Any)
factory(alg::Gerber1, ::Any)
factory(alg::Gerber2, ::Any)Return the provided Gerber covariance algorithm instance unchanged.
These methods are used to support the factory interface for Gerber covariance algorithm types that do not require weights or additional configuration. They enable consistent construction and dispatch for Gerber algorithm variants.
Arguments
alg: Gerber covariance algorithm instance.Unused for API compatibility.
Returns
alg: The input.
Details
These methods allow the
factoryinterface to return the algorithm instance directly for unweighted Gerber algorithms.Used internally when constructing Gerber covariance estimators.
Related
sourcePortfolioOptimisers.factory Function
factory(a::Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
<:AbstractResult}, args...; kwargs...)No-op factory function for constructing objects with a uniform interface.
Defining methods which dispatch on the first argument allows for a consistent factory interface across different types.
Arguments
a: Indicates no object should be constructed.args...: Arbitrary positional arguments (ignored).kwargs...: Arbitrary keyword arguments (ignored).
Returns
a: The input unchanged.
Related
source