Skip to content
13

Smyth-Broby Covariance

PortfolioOptimisers.SmythBroby0 Type
julia
struct SmythBroby0 <: SmythBrobyCovarianceAlgorithm

Implements the original Smyth-Broby covariance algorithm.

Related

source
PortfolioOptimisers.SmythBroby1 Type
julia
struct SmythBroby1 <: SmythBrobyCovarianceAlgorithm

Implements the first variant of the Smyth-Broby covariance algorithm.

Related

source
PortfolioOptimisers.SmythBroby2 Type
julia
struct SmythBroby2 <: SmythBrobyCovarianceAlgorithm

Implements the second variant of the Smyth-Broby covariance algorithm.

Related

source
PortfolioOptimisers.SmythBrobyGerber0 Type
julia
struct SmythBrobyGerber0 <: SmythBrobyCovarianceAlgorithm

Implements the original Smyth-Broby covariance algorithm scaled by vote counts.

Related

source
PortfolioOptimisers.SmythBrobyGerber1 Type
julia
struct SmythBrobyGerber1 <: SmythBrobyCovarianceAlgorithm

Implements the first variant of the Smyth-Broby covariance algorithm scaled by vote counts.

Related

source
PortfolioOptimisers.SmythBrobyGerber2 Type
julia
struct SmythBrobyGerber2 <: SmythBrobyCovarianceAlgorithm

Implements the second variant of the Smyth-Broby covariance algorithm scaled by vote counts.

Related

source
PortfolioOptimisers.SmythBrobyCount0 Type
julia
struct SmythBrobyCount0 <: SmythBrobyCovarianceAlgorithm

Implements the original Smyth-Broby covariance algorithm using vote counts only.

Related

julia
- [`SmythBrobyCovarianceAlgorithm`](@ref)
- [`SmythBrobyCovariance`](@ref)
- [`SmythBrobyCount1`](@ref)
- [`SmythBrobyCount2`](@ref)
source
PortfolioOptimisers.SmythBrobyCount1 Type
julia
struct SmythBrobyCount1 <: SmythBrobyCovarianceAlgorithm

Implements the first variant of the Smyth-Broby covariance algorithm using vote counts only.

Related

julia
- [`SmythBrobyCovarianceAlgorithm`](@ref)
- [`SmythBrobyCovariance`](@ref)
- [`SmythBrobyCount0`](@ref)
- [`SmythBrobyCount2`](@ref)
source
PortfolioOptimisers.SmythBrobyCount2 Type
julia
struct SmythBrobyCount2 <: SmythBrobyCovarianceAlgorithm

Implements the second variant of the Smyth-Broby covariance algorithm using vote counts only.

Related

julia
- [`SmythBrobyCovarianceAlgorithm`](@ref)
- [`SmythBrobyCovariance`](@ref)
- [`SmythBrobyCount0`](@ref)
- [`SmythBrobyCount1`](@ref)
source
PortfolioOptimisers.SmythBrobyCovariance Type
julia
struct SmythBrobyCovariance{__T_ve, __T_me, __T_pdm, __T_c1, __T_c2, __T_c3, __T_n, __T_alg, __T_ex} <: BaseSmythBrobyCovariance

A flexible container type for configuring and applying Smyth-Broby covariance estimators in PortfolioOptimisers.jl.

SmythBrobyCovariance encapsulates all components required for Smyth-Broby-based covariance or correlation estimation, including the expected returns estimator, variance estimator, positive definite matrix estimator, algorithm parameters, and the specific Smyth-Broby algorithm variant.

Fields

  • ve: Variance estimator.

  • me: Expected returns estimator. Used for optionally centering the returns.

  • pdm: Positive definite matrix estimator.

  • c1: Zone of confusion parameter.

  • c2: Zone of indecision lower bound.

  • c3: Zone of indecision upper bound.

  • n: Exponent parameter for the Smyth-Broby kernel.

  • alg: Smyth-Broby covariance algorithm.

  • ex: Parallel execution strategy.

Constructors

julia
SmythBrobyCovariance(;
    ve::StatsBase.CovarianceEstimator = SimpleVariance(),
    me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns(),
    pdm::Option{<:Posdef} = Posdef(),
    c1::Number = 0.5,
    c2::Number = 0.5,
    c3::Number = 4,
    n::Number = 2,
    alg::SmythBrobyCovarianceAlgorithm = SmythBrobyGerber1(),
    ex::FLoops.Transducers.Executor = ThreadedEx()
) -> SmythBrobyCovariance

Keywords correspond to the struct's fields.

Validation

  • c3 > c2.

Examples

julia
julia> SmythBrobyCovariance()
SmythBrobyCovariance
   ve ┼ SimpleVariance
      │          me ┼ SimpleExpectedReturns
      │             │   w ┴ nothing
      │           w ┼ nothing
      │   corrected ┴ Bool: true
   me ┼ SimpleExpectedReturns
      │   w ┴ nothing
  pdm ┼ Posdef
      │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton
      │   kwargs ┴ @NamedTuple{}: NamedTuple()
   c1 ┼ Float64: 0.5
   c2 ┼ Float64: 0.5
   c3 ┼ Int64: 4
    n ┼ Int64: 2
  alg ┼ SmythBrobyGerber1()
   ex ┴ Transducers.ThreadedEx{@NamedTuple{}}: Transducers.ThreadedEx()

Related

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

Compute the Smyth-Broby covariance matrix.

This method computes the Smyth-Broby covariance matrix for the input data matrix X. The mean and standard deviation vectors are computed using the estimator's expected returns and variance estimators. The Smyth-Broby covariance is then computed via smythbroby.

Arguments

  • ce: Smyth-Broby covariance estimator.

    • ce::SmythBrobyCovariance: Compute the unstandardised Smyth-Broby covariance matrix.
  • X: Data matrix (observations × assets).

  • dims: Dimension along which to perform the computation.

  • kwargs...: Additional keyword arguments passed to the mean and standard deviation estimators.

Returns

  • sigma::Matrix{<:Number}: The Smyth-Broby covariance matrix.

Validation

  • dims is either 1 or 2.

Related

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

Compute the Smyth-Broby correlation matrix.

This method computes the Smyth-Broby correlation matrix for the input data matrix X. The mean and standard deviation vectors are computed using the estimator's expected returns and variance estimators. The Smyth-Broby correlation is then computed via smythbroby.

Arguments

  • ce: Smyth-Broby covariance estimator.

    • ce::SmythBrobyCovariance: Compute the unstandardised Smyth-Broby correlation matrix.
  • X: Data matrix (observations × assets).

  • dims: Dimension along which to perform the computation.

  • kwargs...: Additional keyword arguments passed to the mean and standard deviation estimators.

Returns

  • rho::Matrix{<:Number}: The Smyth-Broby correlation matrix.

Validation

  • dims is either 1 or 2.

Related

source
PortfolioOptimisers.BaseSmythBrobyCovariance Type
julia
abstract type BaseSmythBrobyCovariance <: BaseGerberCovariance

Abstract supertype for all Smyth-Broby covariance estimators in PortfolioOptimisers.jl.

All concrete and/or abstract types implementing Smyth-Broby covariance estimation algorithms should be subtypes of BaseSmythBrobyCovariance.

Related

source
PortfolioOptimisers.SmythBrobyCovarianceAlgorithm Type
julia
abstract type SmythBrobyCovarianceAlgorithm <: AbstractMomentAlgorithm

Abstract supertype for all Smyth-Broby covariance algorithm types in PortfolioOptimisers.jl.

All concrete and/or abstract types implementing specific Smyth-Broby covariance algorithms should be subtypes of SmythBrobyCovarianceAlgorithm.

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

Related

source
PortfolioOptimisers.sb_delta Function
julia
sb_delta(ri::Number, rj::Number, n::Number) -> Number

Smyth-Broby kernel function for covariance and correlation computation.

This function computes the kernel value for a pair of asset returns, applying the Smyth-Broby logic for zones of confusion and indecision. It is used to aggregate positive and negative co-movements in Smyth-Broby covariance algorithms. It assumes the returns are centered around zero.

Arguments

  • ri: Absolute standardised return for asset i.

  • rj: Absolute standardised return for asset j.

  • n: Exponent parameter for the kernel.

Returns

  • score::Number: The computed score for the pair (xi, xj).

Details

  • Returns (sqrt((1 + ri) * (1 + rj)) / (1 + abs(ri - rj)^n), 1).

Related

source
PortfolioOptimisers.smythbroby Function
julia
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                                    <:Any, <:SmythBroby0}, X::MatNum, mu::ArrNum,
           sd::ArrNum)

Implements the original Smyth-Broby covariance/correlation algorithm.

This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X using the original SmythBroby0 algorithm. The computation is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive and negative co-movements.

Arguments

  • ce: Smyth-Broby covariance estimator configured with the SmythBroby0 algorithm.

  • X: Data matrix (observations × assets).

  • sd: Vector of standard deviations for each asset, used for scaling and thresholding.

Returns

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

Details

The algorithm proceeds as follows:

  1. For each pair of assets (i, j), iterate over all observations.

  2. For each observation, compute the centered and scaled returns for assets i and j.

  3. Apply the threshold to classify joint positive and negative co-movements.

  4. Use the sb_delta kernel to accumulate positive (pos) and negative (neg) contributions.

  5. The correlation is computed as (pos - neg) / (pos + neg) if the denominator is nonzero, otherwise zero.

  6. The resulting matrix is projected to the nearest positive definite matrix using posdef!.

Related

source
julia
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                                    <:Any, <:SmythBroby1}, X::MatNum, mu::ArrNum,
           sd::ArrNum)

Implements the first variant of the Smyth-Broby covariance/correlation algorithm.

This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X using the original SmythBroby1 algorithm. The computation is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive, negative, and neutral co-movements.

Arguments

  • ce: Smyth-Broby covariance estimator configured with the SmythBroby1 algorithm.

  • X: Data matrix observations × features if the dims keyword does not exist or dims = 1, features × observations when dims = 2.

Returns

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

Details

The algorithm proceeds as follows:

  1. For each pair of assets (i, j), iterate over all observations.

  2. For each observation, use the returns for assets i and j.

  3. Apply the threshold to classify joint positive, negative, and neutral co-movements.

  4. Use the sb_delta kernel to accumulate positive (pos), negative (neg), and neutral (nn) contributions.

  5. The correlation is computed as (pos - neg) / (pos + neg + nn) if the denominator is nonzero, otherwise zero.

  6. The resulting matrix is projected to the nearest positive definite matrix using posdef!.

Related

source
julia
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                                    <:Any, <:SmythBroby2}, X::MatNum, mu::ArrNum,
           sd::ArrNum)

Implements the second variant of the Smyth-Broby covariance/correlation algorithm.

This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X using the SmythBroby2 algorithm. The computation is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive and negative co-movements. The resulting matrix is then standardised by the geometric mean of its diagonal elements.

Arguments

  • ce: Smyth-Broby covariance estimator configured with the SmythBroby2 algorithm.

  • X: Data matrix (observations × assets).

  • sd: Vector of standard deviations for each asset, used for scaling and thresholding.

Returns

  • rho::Matrix{<:Number}: The Smyth-Broby correlation matrix, standardised and projected to be positive definite using the estimator's pdm field.

Details

The algorithm proceeds as follows:

  1. For each pair of assets (i, j), iterate over all observations.

  2. For each observation, compute the centered and scaled returns for assets i and j.

  3. Apply the threshold to classify joint positive and negative co-movements.

  4. Use the sb_delta kernel to accumulate positive (pos) and negative (neg) contributions.

  5. The raw correlation is computed as pos - neg.

  6. The resulting matrix is standardised by dividing each element by the geometric mean of the corresponding diagonal elements.

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

Related

source
julia
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                                    <:Any, <:SmythBrobyGerber0}, X::MatNum,
           mu::ArrNum, sd::ArrNum)

Implements the original Gerber-style variant of the Smyth-Broby covariance/correlation algorithm.

This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X using the SmythBrobyGerber0 algorithm. The computation is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive and negative co-movements, with additional weighting by the count of co-movements.

Arguments

  • ce: Smyth-Broby covariance estimator configured with the SmythBrobyGerber0 algorithm.

  • X: Data matrix (observations × assets).

  • sd: Vector of standard deviations for each asset, used for scaling and thresholding.

Returns

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

Details

The algorithm proceeds as follows:

  1. For each pair of assets (i, j), iterate over all observations.

  2. For each observation, compute the centered and scaled returns for assets i and j.

  3. Apply the threshold to classify joint positive and negative co-movements.

  4. Use the sb_delta kernel to accumulate positive (pos) and negative (neg) contributions, and count the number of positive (cpos) and negative (cneg) co-movements.

  5. The correlation is computed as (pos * cpos - neg * cneg) / (pos * cpos + neg * cneg) if the denominator is nonzero, otherwise zero.

  6. The resulting matrix is projected to the nearest positive definite matrix using posdef!.

Related

source
julia
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                                    <:Any, <:SmythBrobyGerber1}, X::MatNum,
           mu::ArrNum, sd::ArrNum)

Implements the first Gerber-style variant of the Smyth-Broby covariance/correlation algorithm.

This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X using the SmythBrobyGerber1 algorithm. The computation is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive, negative, and neutral co-movements, with additional weighting by the count of co-movements.

Arguments

  • ce: Smyth-Broby covariance estimator configured with the SmythBrobyGerber1 algorithm.

  • X: Data matrix (observations × assets).

  • sd: Vector of standard deviations for each asset, used for scaling and thresholding.

Returns

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

Details

The algorithm proceeds as follows:

  1. For each pair of assets (i, j), iterate over all observations.

  2. For each observation, compute the centered and scaled returns for assets i and j.

  3. Apply the threshold to classify joint positive, negative, and neutral co-movements.

  4. Use the sb_delta kernel to accumulate positive (pos), negative (neg), and neutral (nn) contributions, and count the number of positive (cpos), negative (cneg), and neutral (cnn) co-movements.

  5. The correlation is computed as (pos * cpos - neg * cneg) / (pos * cpos + neg * cneg + nn * cnn) if the denominator is nonzero, otherwise zero.

  6. The resulting matrix is projected to the nearest positive definite matrix using posdef!.

Related

source
julia
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                                    <:Any, <:SmythBrobyGerber2}, X::MatNum,
           mu::ArrNum, sd::ArrNum)

Implements the second Gerber-style variant of the Smyth-Broby covariance/correlation algorithm.

This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X using the SmythBrobyGerber2 algorithm. The computation is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive and negative co-movements, with additional weighting by the count of co-movements. The resulting matrix is then standardised by the geometric mean of its diagonal elements.

Arguments

  • ce: Smyth-Broby covariance estimator configured with the SmythBrobyGerber2 algorithm.

  • X: Data matrix (observations × assets).

  • sd: Vector of standard deviations for each asset, used for scaling and thresholding.

Returns

  • rho::Matrix{<:Number}: The Smyth-Broby correlation matrix, standardised and projected to be positive definite using the estimator's pdm field.

Details

The algorithm proceeds as follows:

  1. For each pair of assets (i, j), iterate over all observations.

  2. For each observation, compute the centered and scaled returns for assets i and j.

  3. Apply the threshold to classify joint positive and negative co-movements.

  4. Use the sb_delta kernel to accumulate positive (pos) and negative (neg) contributions, and count the number of positive (cpos) and negative (cneg) co-movements.

  5. The raw correlation is computed as pos * cpos - neg * cneg.

  6. The resulting matrix is standardised by dividing each element by the geometric mean of the corresponding diagonal elements.

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

Related

source
julia
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                                    <:Any, <:SmythBrobyCount0}, X::MatNum,
           mu::ArrNum, sd::ArrNum)

Implements the original Gerber-style variant of the Smyth-Broby covariance/correlation algorithm.

This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X using the SmythBrobyGerber0 algorithm. The computation is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive and negative co-movements, with additional weighting by the count of co-movements.

Arguments

  • ce: Smyth-Broby covariance estimator configured with the SmythBrobyGerber0 algorithm.

  • X: Data matrix (observations × assets).

  • sd: Vector of standard deviations for each asset, used for scaling and thresholding.

Returns

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

Details

The algorithm proceeds as follows:

  1. For each pair of assets (i, j), iterate over all observations.

  2. For each observation, compute the centered and scaled returns for assets i and j.

  3. Apply the threshold to classify joint positive and negative co-movements.

  4. Use the sb_delta kernel to accumulate positive (pos) and negative (neg) contributions, and count the number of positive (cpos) and negative (cneg) co-movements.

  5. The correlation is computed as (pos * cpos - neg * cneg) / (pos * cpos + neg * cneg) if the denominator is nonzero, otherwise zero.

  6. The resulting matrix is projected to the nearest positive definite matrix using posdef!.

Related

source
julia
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                                    <:Any, <:SmythBrobyCount1}, X::MatNum,
            mu::ArrNum, sd::ArrNum)

Implements the first Gerber-style variant of the Smyth-Broby covariance/correlation algorithm.

This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X using the SmythBrobyGerber1 algorithm. The computation is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive, negative, and neutral co-movements, with additional weighting by the count of co-movements.

Arguments

  • ce: Smyth-Broby covariance estimator configured with the SmythBrobyGerber1 algorithm.

  • X: Data matrix (observations × assets).

  • sd: Vector of standard deviations for each asset, used for scaling and thresholding.

Returns

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

Details

The algorithm proceeds as follows:

  1. For each pair of assets (i, j), iterate over all observations.

  2. For each observation, compute the centered and scaled returns for assets i and j.

  3. Apply the threshold to classify joint positive, negative, and neutral co-movements.

  4. Use the sb_delta kernel to accumulate positive (pos), negative (neg), and neutral (nn) contributions, and count the number of positive (cpos), negative (cneg), and neutral (cnn) co-movements.

  5. The correlation is computed as (pos * cpos - neg * cneg) / (pos * cpos + neg * cneg + nn * cnn) if the denominator is nonzero, otherwise zero.

  6. The resulting matrix is projected to the nearest positive definite matrix using posdef!.

Related

source
julia
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                                    <:Any, <:SmythBrobyCount2}, X::MatNum,
            mu::ArrNum, sd::ArrNum)

Implements the second Gerber-style variant of the Smyth-Broby covariance/correlation algorithm.

This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X using the SmythBrobyGerber2 algorithm. The computation is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive and negative co-movements, with additional weighting by the count of co-movements. The resulting matrix is then standardised by the geometric mean of its diagonal elements.

Arguments

  • ce: Smyth-Broby covariance estimator configured with the SmythBrobyGerber2 algorithm.

  • X: Data matrix (observations × assets).

  • sd: Vector of standard deviations for each asset, used for scaling and thresholding.

Returns

  • rho::Matrix{<:Number}: The Smyth-Broby correlation matrix, standardised and projected to be positive definite using the estimator's pdm field.

Details

The algorithm proceeds as follows:

  1. For each pair of assets (i, j), iterate over all observations.

  2. For each observation, compute the centered and scaled returns for assets i and j.

  3. Apply the threshold to classify joint positive and negative co-movements.

  4. Use the sb_delta kernel to accumulate positive (pos) and negative (neg) contributions, and count the number of positive (cpos) and negative (cneg) co-movements.

  5. The raw correlation is computed as pos * cpos - neg * cneg.

  6. The resulting matrix is standardised by dividing each element by the geometric mean of the corresponding diagonal elements.

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

Related

source