Skip to content
5

Gerber Covariance

PortfolioOptimisers.Gerber0 Type
julia
struct Gerber0 <: UnstandardisedGerberCovarianceAlgorithm end

Implements the original Gerber covariance algorithm.

Related

source
PortfolioOptimisers.Gerber1 Type
julia
struct Gerber1 <: UnstandardisedGerberCovarianceAlgorithm end

Implements the first variant of the Gerber covariance algorithm.

Related

source
PortfolioOptimisers.Gerber2 Type
julia
struct Gerber2 <: UnstandardisedGerberCovarianceAlgorithm end

Implements the second variant of the Gerber covariance algorithm.

Related

source
PortfolioOptimisers.StandardisedGerber0 Type
julia
struct StandardisedGerber0{T1} <: StandardisedGerberCovarianceAlgorithm
    me::T1
end

Implements the original Gerber covariance algorithm on Z-transformed data.

Fields

  • me: Expected returns estimator used for mean-centering prior to normalisation.

Constructor

julia
StandardisedGerber0(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())

Keyword arguments correspond to the fields above.

Examples

julia
julia> StandardisedGerber0()
StandardisedGerber0
  me ┼ SimpleExpectedReturns
     │   w ┴ nothing

Related

source
PortfolioOptimisers.StandardisedGerber1 Type
julia
struct StandardisedGerber1{T1} <: StandardisedGerberCovarianceAlgorithm
    me::T1
end

Implements 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

julia
StandardisedGerber1(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())

Keyword arguments correspond to the fields above.

Examples

julia
julia> StandardisedGerber1()
StandardisedGerber1
  me ┼ SimpleExpectedReturns
     │   w ┴ nothing

Related

source
PortfolioOptimisers.StandardisedGerber2 Type
julia
struct StandardisedGerber2{T1} <: StandardisedGerberCovarianceAlgorithm
    me::T1
end

Implements 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

julia
StandardisedGerber2(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())

Keyword arguments correspond to the fields above.

Examples

julia
julia> StandardisedGerber2()
StandardisedGerber2
  me ┼ SimpleExpectedReturns
     │   w ┴ nothing

Related

source
PortfolioOptimisers.GerberCovariance Type
julia
struct GerberCovariance{T1, T2, T3, T4} <: BaseGerberCovariance
    ve::T1
    pdm::T2
    threshold::T3
    alg::T4
end

A 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, threshold parameter, and the specific Gerber algorithm variant. This enables modular and extensible workflows for robust covariance estimation using Gerber statistics.

Fields

  • ve: Variance estimator.

  • pdm: Positive definite matrix estimator (see Posdef).

  • threshold: Threshold parameter for Gerber covariance computation.

  • alg: Gerber covariance algorithm variant.

Constructor

julia
GerberCovariance(; ve::StatsBase.CovarianceEstimator = SimpleVariance(),
                 pdm::Union{Nothing, <:Posdef} = Posdef(), threshold::Real = 0.5,
                 alg::GerberCovarianceAlgorithm = Gerber1())

Keyword arguments correspond to the fields above.

Validation

  • 0 < threshold < 1.

Related

source
Statistics.cov Method
julia
cov(ce::GerberCovariance, X::AbstractMatrix; dims::Int = 1, kwargs...)

Compute the Gerber covariance matrix using an unstandardised Gerber covariance estimator.

This method computes the Gerber covariance matrix for the input data matrix X using the specified unstandardised Gerber covariance estimator. The standard deviation vector is computed using the estimator's variance estimator. The Gerber correlation is computed via gerber, and the result is rescaled to a covariance matrix using the standard deviation vector.

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{<:Real}: The Gerber covariance matrix.

Validation

  • dims is either 1 or 2.

Related

source
Statistics.cor Method
julia
cor(ce::GerberCovariance, X::AbstractMatrix; dims::Int = 1, kwargs...)

Compute the Gerber correlation matrix using an unstandardised Gerber covariance estimator.

This method computes the Gerber correlation matrix for the input data matrix X using the specified unstandardised Gerber covariance estimator. The standard deviation vector is computed using the estimator's variance estimator. The Gerber correlation is then computed via gerber.

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{<:Real}: The Gerber correlation matrix.

Validation

  • dims is either 1 or 2.

Related

source
PortfolioOptimisers.BaseGerberCovariance Type
julia
abstract type BaseGerberCovariance <: AbstractCovarianceEstimator end

Abstract supertype for all Gerber covariance estimators in PortfolioOptimisers.jl.

All concrete types implementing Gerber covariance estimation algorithms should subtype BaseGerberCovariance. This enables a consistent interface for Gerber-based covariance estimators throughout the package.

Related

source
PortfolioOptimisers.GerberCovarianceAlgorithm Type
julia
abstract type GerberCovarianceAlgorithm <: AbstractMomentAlgorithm end

Abstract supertype for all Gerber covariance algorithm types in PortfolioOptimisers.jl.

All concrete types implementing specific Gerber covariance algorithms should subtype GerberCovarianceAlgorithm. This enables flexible extension and dispatch of Gerber covariance routines.

These types are used to specify the algorithm when constructing a GerberCovariance estimator.

Related

source
PortfolioOptimisers.UnstandardisedGerberCovarianceAlgorithm Type
julia
abstract type UnstandardisedGerberCovarianceAlgorithm <: GerberCovarianceAlgorithm end

Abstract supertype for all unstandardised Gerber covariance algorithm types.

Concrete types implementing unstandardised Gerber covariance algorithms should subtype UnstandardisedGerberCovarianceAlgorithm.

Related

source
PortfolioOptimisers.StandardisedGerberCovarianceAlgorithm Type
julia
abstract type StandardisedGerberCovarianceAlgorithm <: GerberCovarianceAlgorithm end

Abstract 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

source
PortfolioOptimisers.gerber Method
julia
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber0}, X::AbstractMatrix,
       std_vec::AbstractArray)

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 the Gerber0 algorithm.

  • X: Data matrix (observations × assets).

  • std_vec: Vector of standard deviations for each asset, used to scale the threshold.

Returns

  • rho::Matrix{<:Real}: The Gerber correlation, projected to be positive definite using the estimator's pdm field.

Details

The algorithm proceeds as follows:

  1. For each entry in X, compute two Boolean matrices:
  • U: Entries where X exceeds threshold * std_vec.

  • D: Entries where X is less than -threshold * std_vec.

  1. Compute UmD = U - D and UpD = U + D.

  2. The Gerber correlation is given by (UmD' * UmD) ⊘ (UpD' * UpD).

  3. The result is projected to the nearest positive definite matrix using posdef!.

Related

source
PortfolioOptimisers.gerber Method
julia
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber0}, X::AbstractMatrix)

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 the StandardisedGerber0 algorithm.

  • X: Z-transformed data matrix (observations × assets).

Returns

  • rho::Matrix{<:Real}: The Gerber correlation matrix, projected to be positive definite using the estimator's pdm field.

Details

The algorithm proceeds as follows:

  1. For each entry in X, compute two Boolean matrices:
  • U: Entries where X exceeds ce.threshold.

  • D: Entries where X is less than -ce.threshold.

  1. Compute UmD = U - D and UpD = U + D.

  2. The Gerber correlation is given by (UmD' * UmD) ⊘ (UpD' * UpD).

  3. The result is projected to the nearest positive definite matrix using posdef!.

Related

source
PortfolioOptimisers.gerber Method
julia
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber1}, X::AbstractMatrix,
       std_vec::AbstractArray)

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 the Gerber1 algorithm.

  • X: Data matrix (observations × assets).

  • std_vec: Vector of standard deviations for each asset, used to scale the threshold.

Returns

  • rho::Matrix{<:Real}: The Gerber correlation matrix, projected to be positive definite using the estimator's pdm field.

Details

The algorithm proceeds as follows:

  1. For each entry in X, compute three Boolean matrices:
  • U: Entries where X exceeds threshold * std_vec.

  • D: Entries where X is less than -threshold * std_vec.

  • N: Entries where X is within [-threshold * std_vec, threshold * std_vec] (i.e., neither up nor down).

  1. Compute UmD = U - D.

  2. The Gerber1 correlation is given by (UmD' * UmD) ⊘ (T .- (N' * N)), where T is the number of observations.

  3. The result is projected to the nearest positive definite matrix using posdef!.

source
PortfolioOptimisers.gerber Method
julia
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber1}, X::AbstractMatrix)

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 the StandardisedGerber1 algorithm.

  • X: Z-transformed data matrix (observations × assets).

Returns

  • rho::Matrix{<:Real}: The Gerber correlation matrix, projected to be positive definite using the estimator's pdm field.

Details

The algorithm proceeds as follows:

  1. For each entry in X, compute three Boolean matrices:
  • U: Entries where X exceeds ce.threshold.

  • D: Entries where X is less than -ce.threshold.

  • N: Entries where X is within [-ce.threshold, ce.threshold] (i.e., neither up nor down).

  1. Compute UmD = U - D.

  2. The Gerber1 correlation is given by (UmD' * UmD) ⊘ (T .- (N' * N)), where T is the number of observations.

  3. The result is projected to the nearest positive definite matrix using posdef!.

Related

source
PortfolioOptimisers.gerber Method
julia
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber2}, X::AbstractMatrix,
       std_vec::AbstractArray)

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 the Gerber2 algorithm.

  • X: Data matrix (observations × assets).

  • std_vec: Vector of standard deviations for each asset, used to scale the threshold.

Returns

  • rho::Matrix{<:Real}: The Gerber correlation or correlation matrix, projected to be positive definite using the estimator's pdm field.

Details

The algorithm proceeds as follows:

  1. For each entry in X, compute two Boolean matrices:
  • U: Entries where X exceeds threshold * std_vec.

  • D: Entries where X is less than -threshold * std_vec.

  1. Compute the signed indicator matrix UmD = U - D.

  2. Compute the raw Gerber2 matrix H = UmD' * UmD.

  3. Normalize: rho = H ⊘ (h * h'), where h = sqrt.(diag(H)).

  4. The result is projected to the nearest positive definite matrix using posdef!.

Related

source
PortfolioOptimisers.gerber Method
julia
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:StandardisedGerber2}, X::AbstractMatrix)

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 the StandardisedGerber2 algorithm.

  • X: Z-transformed data matrix (observations × assets).

Returns

  • rho::Matrix{<:Real}: The Gerber correlation matrix, projected to be positive definite using the estimator's pdm field.

Details

The algorithm proceeds as follows:

  1. For each entry in X, compute two Boolean matrices:
  • U: Entries where X exceeds ce.threshold.

  • D: Entries where X is less than -ce.threshold.

  1. Compute the signed indicator matrix UmD = U - D.

  2. Compute the raw Gerber2 matrix H = UmD' * UmD.

  3. Normalize: rho = H ⊘ (h * h'), where h = sqrt.(diag(H)).

  4. The result is projected to the nearest positive definite matrix using posdef!.

Related

source