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].
Abstract Gerber covariance types
These serve as the scaffolding for defining Gerber covariance estimators and algorithms.
PortfolioOptimisers.BaseGerberCovariance Type
abstract type BaseGerberCovariance <: AbstractCovarianceEstimatorAbstract 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.
Interfaces
If moving away from the already established Gerber covariance algorithms, you must follow AbstractCovarianceEstimator to implement the entire chain.
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 <: AbstractMomentAlgorithmAbstract 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.
Interfaces
If moving away from the already established Gerber covariance algorithms, you must follow AbstractCovarianceEstimator to implement the entire chain. Else you can follow the instructions and examples in GerberCovarianceAlgorithm.
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
Concrete Gerber covariance implementations
These define the concrete implementations of the Gerber covariance estimators and algorithms.
PortfolioOptimisers.Gerber0 Type
struct Gerber0 <: GerberCovarianceAlgorithmImplements 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 <: GerberCovarianceAlgorithmImplements 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 <: GerberCovarianceAlgorithmImplements 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.GerberCovariance Type
struct GerberCovariance{__T_ve, __T_me, __T_pdm, __T_t, __T_alg} <: BaseGerberCovarianceA 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.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{<:Posdef} = Posdef(),
t::Number = 0.5,
alg::GerberCovarianceAlgorithm = Gerber1()
) -> GerberCovarianceKeywords correspond to the struct's fields.
Validation
0 <= t.
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(
ce::GerberCovariance,
w::Union{DynamicAbstractWeights, AbstractWeights}
) -> Union{GerberCovariance{<:CovarianceEstimator, <:AbstractExpectedReturnsEstimator, Nothing, <:Number, <:GerberCovarianceAlgorithm}, GerberCovariance{var"#s179", var"#s1791", Posdef{__T_alg, __T_kwargs}, <:Number, <:GerberCovarianceAlgorithm} where {var"#s179"<:CovarianceEstimator, var"#s1791"<:AbstractExpectedReturnsEstimator, __T_alg, __T_kwargs}}Return a new GerberCovariance estimator with the specified observation weights.
Arguments
ce: Covariance estimator.w: Optional observation weights vectorobservations × 1, or a concrete subtype ofDynamicAbstractWeights. Ifnothing, the computation is unweighted.
Returns
ce: New covariance estimator of the same type as the argument, with the new weights applied.
Details
Calls
factory(ce.alg, w)to update the algorithm (current algorithms do not use weights, this for future proofing).Calls
factory(ce.ve, w)to update the variance estimator.Calls
factory(ce.me, w)to update the expected returns estimator.Preserves the other fields of the original estimator.
Examples
julia> ce = 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()
julia> factory(ce, StatsBase.Weights([0.1, 0.2, 0.7]))
GerberCovariance
ve ┼ SimpleVariance
│ me ┼ SimpleExpectedReturns
│ │ w ┴ StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.1, 0.2, 0.7]
│ w ┼ StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.1, 0.2, 0.7]
│ corrected ┴ Bool: true
me ┼ SimpleExpectedReturns
│ w ┴ StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.1, 0.2, 0.7]
pdm ┼ Posdef
│ alg ┼ UnionAll: NearestCorrelationMatrix.Newton
│ kwargs ┴ @NamedTuple{}: NamedTuple()
t ┼ Float64: 0.5
alg ┴ Gerber1()Related
sourcePortfolioOptimisers.gerber Method
gerber(
ce::GerberCovariance{<:Any, <:Any, <:Any, <:Any, <:Gerber0},
X::MatNum,
sd::ArrNum
) -> MatNumImplements the original Gerber correlation algorithm.
Arguments
ce: Gerber covariance estimator.. Configured with theGerber0algorithm.X: Data matrixobservations × featuresif thedimskeyword does not exist ordims = 1,features × observationswhendims = 2.sd: Standard deviation vector ofX, shaped to be consistent withX.
Returns
rho::MatNum: Correlation matrixfeatures x features.
Details
The algorithm proceeds as follows:
For each entry in
X, compute two Boolean matrices:U: Entries whereX .>= ce.t * sd.D: Entries whereX .<= -ce.t * sd.
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,
sd::ArrNum
) -> MatNumImplements the first variant of the Gerber correlation algorithm.
Arguments
ce: Gerber covariance estimator.. Configured with theGerber1algorithm.X: Data matrixobservations × featuresif thedimskeyword does not exist ordims = 1,features × observationswhendims = 2.sd: Standard deviation vector ofX, shaped to be consistent withX.
Returns
rho::MatNum: Correlation matrixfeatures x features.
Details
The algorithm proceeds as follows:
For each entry in
X, compute three Boolean matrices:U: Entries whereX .>= ce.t * sd.D: Entries whereX .<= -ce.t * sd.N: Entries whereX in (-ce.t * sd, ce.t * sd)(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,
sd::ArrNum
) -> MatNumImplements the second variant of the Gerber correlation algorithm.
Arguments
ce: Gerber covariance estimator.. Configured with theGerber2algorithm.X: Data matrixobservations × featuresif thedimskeyword does not exist ordims = 1,features × observationswhendims = 2.sd: Standard deviation vector ofX, shaped to be consistent withX.
Returns
rho::MatNum: Correlation matrixfeatures x features.
Details
The algorithm proceeds as follows:
For each entry in
X, compute two Boolean matrices:U: Entries whereX .>= ce.t * sd.D: Entries whereX .<= -ce.t * sd.
Compute the signed indicator matrix
UmD = U - D.Compute the raw Gerber2 matrix
H = UmD' * UmD.Normalise
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
Statistics.cov Method
Statistics.cov(
ce::GerberCovariance,
X::MatNum;
dims::Int = 1,
kwargs...
) -> MatNumCompute the Gerber covariance matrix using the algorithm specified in ce.alg.
Arguments
ce: Gerber covariance estimator.X: Data matrixobservations × featuresif thedimskeyword does not exist ordims = 1,features × observationswhendims = 2.dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the standard deviation estimator.
Returns
rho: Correlation matrixfeatures × features.
Validation
dims in (1, 2).
Details
Computes the standard deviation vector for each asset using the estimator's variance estimator.
Demeans the returns with
ce.meanddemean_returns.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, <:Any, <:Gerber0}, X::MatNum, sd::ArrNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Any, <:Gerber1}, X::MatNum, sd::ArrNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Any, <:Gerber2}, X::MatNum, sd::ArrNum)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...
) -> MatNumCompute the Gerber correlation matrix using the algorithm specified in ce.alg.
Arguments
ce: Gerber covariance estimator.X: Data matrixobservations × featuresif thedimskeyword does not exist ordims = 1,features × observationswhendims = 2.dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the standard deviation estimator.
Returns
rho: Correlation matrixfeatures × features.
Validation
dims in (1, 2).
Details
Computes the standard deviation vector for each asset using the estimator's variance estimator.
Demeans the returns with
ce.meanddemean_returns.Computes the Gerber correlation matrix using the Gerber algorithm in
ce.alg.
Related
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Any, <:Gerber0}, X::MatNum, sd::ArrNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Any, <:Gerber1}, X::MatNum, sd::ArrNum)gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Any, <:Gerber2}, X::MatNum, sd::ArrNum)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