Gerber Covariance
PortfolioOptimisers.BaseGerberCovariance
— Typeabstract 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
PortfolioOptimisers.GerberCovarianceAlgorithm
— Typeabstract 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
PortfolioOptimisers.UnNormalisedGerberCovarianceAlgorithm
— Typeabstract type UnNormalisedGerberCovarianceAlgorithm <: GerberCovarianceAlgorithm end
Abstract supertype for all unnormalised Gerber covariance algorithm types.
Concrete types implementing unnormalised Gerber covariance algorithms should subtype UnNormalisedGerberCovarianceAlgorithm
.
Related
PortfolioOptimisers.NormalisedGerberCovarianceAlgorithm
— Typeabstract type NormalisedGerberCovarianceAlgorithm <: GerberCovarianceAlgorithm end
Abstract supertype for all normalised Gerber covariance algorithm types. These Z-transform the data before applying the Gerber covariance algorithm.
Concrete types implementing normalised Gerber covariance algorithms should subtype NormalisedGerberCovarianceAlgorithm
.
Related
PortfolioOptimisers.Gerber0
— Typestruct Gerber0 <: UnNormalisedGerberCovarianceAlgorithm end
Implements the original Gerber covariance algorithm.
Related
PortfolioOptimisers.Gerber1
— Typestruct Gerber1 <: UnNormalisedGerberCovarianceAlgorithm end
Implements the first variant of the Gerber covariance algorithm.
Related
PortfolioOptimisers.Gerber2
— Typestruct Gerber2 <: UnNormalisedGerberCovarianceAlgorithm end
Implements the second variant of the Gerber covariance algorithm.
Related
PortfolioOptimisers.NormalisedGerber0
— Typestruct NormalisedGerber0{T1} <: NormalisedGerberCovarianceAlgorithm
me::T1
end
Implements the original Gerber covariance algorithm on Z-transformed data.
Fields
me::AbstractExpectedReturnsEstimator
: Expected returns estimator used for mean-centering prior to normalisation.
Constructor
NormalisedGerber0(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())
: Construct the original normalised Gerber covariance algorithm.
Related
PortfolioOptimisers.NormalisedGerber0
— MethodNormalisedGerber0(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())
Creates a NormalisedGerber0
object using the specified expected returns estimator for mean-centering prior to normalisation.
Arguments
me::AbstractExpectedReturnsEstimator
: Expected returns estimator used for mean-centering before normalisation.
ReturnsResult
NormalisedGerber0
: An instance of the original normalised Gerber covariance algorithm.
Examples
julia> ng0 = NormalisedGerber0()
NormalisedGerber0
me | SimpleExpectedReturns
| w | nothing
Related
PortfolioOptimisers.NormalisedGerber1
— Typestruct NormalisedGerber1{T1} <: NormalisedGerberCovarianceAlgorithm
me::T1
end
Implements the first variant of the Gerber covariance algorithm on Z-transformed data.
Fields
me::AbstractExpectedReturnsEstimator
: Expected returns estimator used for mean-centering prior to normalisation.
Constructor
NormalisedGerber1(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())
: Construct the first variant of the normalised Gerber covariance algorithm.
Related
PortfolioOptimisers.NormalisedGerber1
— MethodNormalisedGerber1(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())
Creates a NormalisedGerber1
object using the specified expected returns estimator for mean-centering prior to normalisation.
Arguments
me::AbstractExpectedReturnsEstimator
: Expected returns estimator used for mean-centering before normalisation.
ReturnsResult
NormalisedGerber1
: An instance of the original normalised Gerber covariance algorithm.
Examples
julia> ng0 = NormalisedGerber1()
NormalisedGerber1
me | SimpleExpectedReturns
| w | nothing
Related
PortfolioOptimisers.NormalisedGerber2
— Typestruct NormalisedGerber2{T1} <: NormalisedGerberCovarianceAlgorithm
me::T1
end
Implements the second variant of the Gerber covariance algorithm on Z-transformed data.
Fields
me::AbstractExpectedReturnsEstimator
: Expected returns estimator used for mean-centering prior to normalisation.
Constructors
NormalisedGerber2(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())
: Construct the second variant of the normalised Gerber covariance algorithm.
These types are used to specify the algorithm when constructing a GerberCovariance
estimator with normalisation.
Related
PortfolioOptimisers.NormalisedGerber2
— MethodNormalisedGerber2(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns())
Creates a NormalisedGerber2
object using the specified expected returns estimator for mean-centering prior to normalisation.
Arguments
me::AbstractExpectedReturnsEstimator
: Expected returns estimator used for mean-centering before normalisation.
ReturnsResult
NormalisedGerber2
: An instance of the original normalised Gerber covariance algorithm.
Examples
julia> ng0 = NormalisedGerber2()
NormalisedGerber2
me | SimpleExpectedReturns
| w | nothing
Related
PortfolioOptimisers.GerberCovariance
— Typestruct 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::StatsBase.CovarianceEstimator
: Variance estimator.pdm::Posdef
: Positive definite matrix estimator (seePosdef
).threshold::Real
: Threshold parameter for Gerber covariance computation (typically in (0, 1)).alg::GerberCovarianceAlgorithm
: Gerber covariance algorithm variant.
Constructor
GerberCovariance(; alg::GerberCovarianceAlgorithm = Gerber1(),
ve::StatsBase.CovarianceEstimator = SimpleVariance(),
pdm::Union{Nothing, <:Posdef} = Posdef(),
threshold::Real = 0.5)
Construct a GerberCovariance
estimator with the specified algorithm, variance estimator, positive definite estimator, and threshold.
Related
PortfolioOptimisers.GerberCovariance
— MethodGerberCovariance(; ve::StatsBase.CovarianceEstimator = SimpleVariance(),
pdm::Union{Nothing, <:Posdef} = Posdef(),
threshold::Real = 0.5,
alg::GerberCovarianceAlgorithm = Gerber1())
Construct a GerberCovariance
estimator for robust Gerber-based covariance or correlation estimation.
This constructor creates a GerberCovariance
object using the specified Gerber algorithm, variance estimator, positive definite matrix estimator, and threshold parameter. The estimator is highly modular, allowing users to select from different Gerber algorithm variants, and positive definite projections.
Arguments
ve::StatsBase.CovarianceEstimator
: Variance estimator.pdm::Union{Nothing, <:Posdef}
: Positive definite matrix estimator.threshold::Real
: Threshold parameter for Gerber covariance computation.alg::GerberCovarianceAlgorithm
: Gerber covariance algorithm variant.
ReturnsResult
GerberCovariance
: A configured Gerber covariance estimator.
Validation
- Asserts that
threshold
is strictly in(0, 1)
.
Examples
julia> gc = GerberCovariance()
GerberCovariance
ve | SimpleVariance
| me | SimpleExpectedReturns
| | w | nothing
| w | nothing
| corrected | Bool: true
pdm | Posdef
| alg | UnionAll: NearestCorrelationMatrix.Newton
threshold | Float64: 0.5
alg | Gerber1()
Related
Statistics.cov
— Methodcov(ce::GerberCovariance{<:Any, <:Any, <:Any, <:UnNormalisedGerberCovarianceAlgorithm},
X::AbstractMatrix; dims::Int = 1, kwargs...)
Compute the Gerber covariance matrix using an unnormalised Gerber covariance estimator.
This method computes the Gerber covariance matrix for the input data matrix X
using the specified unnormalised 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{<:Any, <:Any, <:Any, <:UnNormalisedGerberCovarianceAlgorithm}
: Gerber covariance estimator.X::AbstractMatrix
: Data matrix (observations × assets).dims::Int
: Dimension along which to compute the covariance.kwargs...
: Additional keyword arguments passed to the standard deviation estimator.
ReturnsResult
sigma::Matrix{Float64}
: The Gerber covariance matrix.
Validation
- Asserts that
dims
is either1
or2
.
Related
GerberCovariance
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber0}, X::AbstractMatrix, std_vec::AbstractArray)
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber1}, X::AbstractMatrix, std_vec::AbstractArray)
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber2}, X::AbstractMatrix, std_vec::AbstractArray)
cor(ce::GerberCovariance{<:Any, <:Any, <:Any, <:UnNormalisedGerberCovarianceAlgorithm}, X::AbstractMatrix; dims::Int = 1, kwargs...)
Statistics.cov
— Methodcov(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerberCovarianceAlgorithm},
X::AbstractMatrix; dims::Int = 1, kwargs...)
Compute the Gerber covariance matrix using a normalised Gerber covariance estimator.
This method computes the Gerber covariance matrix for the input data matrix X
using the specified normalised 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{<:Any, <:Any, <:Any, <:NormalisedGerberCovarianceAlgorithm}
: Gerber covariance estimator.X::AbstractMatrix
: Data matrix (observations × assets).dims::Int
: Dimension along which to compute the covariance.kwargs...
: Additional keyword arguments passed to the standard deviation estimator.
ReturnsResult
sigma::Matrix{Float64}
: The Gerber covariance matrix.
Validation
- Asserts that
dims
is either1
or2
.
Related
GerberCovariance
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber0}, X::AbstractMatrix)
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber1}, X::AbstractMatrix)
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber2}, X::AbstractMatrix)
cor(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerberCovarianceAlgorithm}, X::AbstractMatrix; dims::Int = 1, kwargs...)
Statistics.cor
— Methodcor(ce::GerberCovariance{<:Any, <:Any, <:Any, <:UnNormalisedGerberCovarianceAlgorithm},
X::AbstractMatrix; dims::Int = 1, kwargs...)
Compute the Gerber correlation matrix using an unnormalised Gerber covariance estimator.
This method computes the Gerber correlation matrix for the input data matrix X
using the specified unnormalised 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{<:Any, <:Any, <:Any, <:UnNormalisedGerberCovarianceAlgorithm}
: Gerber covariance estimator.X::AbstractMatrix
: Data matrix (observations × assets).dims::Int
: Dimension along which to compute the correlation.kwargs...
: Additional keyword arguments passed to the standard deviation estimator.
ReturnsResult
rho::Matrix{Float64}
: The Gerber correlation matrix.
Validation
- Asserts that
dims
is either1
or2
.
Related
GerberCovariance
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber0}, X::AbstractMatrix, std_vec::AbstractArray)
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber1}, X::AbstractMatrix, std_vec::AbstractArray)
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber2}, X::AbstractMatrix, std_vec::AbstractArray)
cov(ce::GerberCovariance{<:Any, <:Any, <:Any, <:UnNormalisedGerberCovarianceAlgorithm}, X::AbstractMatrix; dims::Int = 1, kwargs...)
Statistics.cor
— Methodcor(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerberCovarianceAlgorithm},
X::AbstractMatrix; dims::Int = 1, kwargs...)
Compute the Gerber correlation matrix using a normalised Gerber covariance estimator.
This method computes the Gerber correlation matrix for the input data matrix X
using the specified normalised 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{<:Any, <:Any, <:Any, <:NormalisedGerberCovarianceAlgorithm}
: Gerber covariance estimator.X::AbstractMatrix
: Data matrix (observations × assets).dims::Int
: Dimension along which to compute the correlation.kwargs...
: Additional keyword arguments passed to the standard deviation estimator.
ReturnsResult
rho::Matrix{Float64}
: The Gerber correlation matrix.
Validation
- Asserts that
dims
is either1
or2
.
Related
GerberCovariance
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber0}, X::AbstractMatrix)
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber1}, X::AbstractMatrix)
gerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber2}, X::AbstractMatrix)
cov(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerberCovarianceAlgorithm}, X::AbstractMatrix; dims::Int = 1, kwargs...)
PortfolioOptimisers.gerber
— Methodgerber(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::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber0}
: Gerber correlation estimator configured with theGerber0
algorithm.X::AbstractMatrix
: Data matrix (observations × assets).std_vec::AbstractArray
: Vector of standard deviations for each asset, used to scale the threshold.
ReturnsResult
rho::Matrix{Float64}
: The Gerber correlation, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
For each entry in
X
, compute two Boolean matrices:U
: Entries whereX
exceedsthreshold * std_vec
.D
: Entries whereX
is less than-threshold * std_vec
.
Compute
UmD = U - D
andUpD = 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
PortfolioOptimisers.gerber
— Methodgerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber0}, 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 NormalisedGerber0
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::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber0}
: Gerber correlation estimator configured with theNormalisedGerber0
algorithm.X::AbstractMatrix
: Z-transformed data matrix (observations × assets).
ReturnsResult
rho::Matrix{Float64}
: The Gerber correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
For each entry in
X
, compute two Boolean matrices:U
: Entries whereX
exceedsce.threshold
.D
: Entries whereX
is less than-ce.threshold
.
Compute
UmD = U - D
andUpD = 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
PortfolioOptimisers.gerber
— Methodgerber(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::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber1}
: Gerber correlation estimator configured with theGerber1
algorithm.X::AbstractMatrix
: Data matrix (observations × assets).std_vec::AbstractArray
: Vector of standard deviations for each asset, used to scale the threshold.
ReturnsResult
rho::Matrix{Float64}
: The Gerber correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
For each entry in
X
, compute three Boolean matrices:U
: Entries whereX
exceedsthreshold * std_vec
.D
: Entries whereX
is less than-threshold * std_vec
.N
: Entries whereX
is within[-threshold * std_vec, threshold * std_vec]
(i.e., neither up nor down).
Compute
UmD = U - D
.The Gerber1 correlation is given by
(UmD' * UmD) ⊘ (T .- (N' * N))
, whereT
is the number of observations.The result is projected to the nearest positive definite matrix using
posdef!
.
PortfolioOptimisers.gerber
— Methodgerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber1}, 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 NormalisedGerber1
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::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber1}
: Gerber correlation estimator configured with theNormalisedGerber1
algorithm.X::AbstractMatrix
: Z-transformed data matrix (observations × assets).
ReturnsResult
rho::Matrix{Float64}
: The Gerber correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
For each entry in
X
, compute three Boolean matrices:U
: Entries whereX
exceedsce.threshold
.D
: Entries whereX
is less than-ce.threshold
.N
: Entries whereX
is within[-ce.threshold, ce.threshold]
(i.e., neither up nor down).
Compute
UmD = U - D
.The Gerber1 correlation is given by
(UmD' * UmD) ⊘ (T .- (N' * N))
, whereT
is the number of observations.The result is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.gerber
— Methodgerber(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::GerberCovariance{<:Any, <:Any, <:Any, <:Gerber2}
: Gerber correlation estimator configured with theGerber2
algorithm.X::AbstractMatrix
: Data matrix (observations × assets).std_vec::AbstractArray
: Vector of standard deviations for each asset, used to scale the threshold.
ReturnsResult
rho::Matrix{Float64}
: The Gerber correlation or correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
For each entry in
X
, compute two Boolean matrices:U
: Entries whereX
exceedsthreshold * std_vec
.D
: Entries whereX
is less than-threshold * 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.(diag(H))
.The result is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.gerber
— Methodgerber(ce::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber2}, 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 NormalisedGerber2
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::GerberCovariance{<:Any, <:Any, <:Any, <:NormalisedGerber2}
: Gerber correlation estimator configured with theNormalisedGerber2
algorithm.X::AbstractMatrix
: Z-transformed data matrix (observations × assets).
ReturnsResult
rho::Matrix{Float64}
: The Gerber correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
For each entry in
X
, compute two Boolean matrices:U
: Entries whereX
exceedsce.threshold
.D
: Entries whereX
is less than-ce.threshold
.
Compute the signed indicator matrix
UmD = U - D
.Compute the raw Gerber2 matrix
H = UmD' * UmD
.Normalize:
rho = H ⊘ (h * h')
, whereh = sqrt.(diag(H))
.The result is projected to the nearest positive definite matrix using
posdef!
.
Related