Skip to content
18

Smyth-Broby Covariance

PortfolioOptimisers.SmythBroby0 Type
julia
struct SmythBroby0 <: SmythBrobyCovarianceAlgorithm

Implements the original Smyth-Broby covariance algorithm.

Constructors

julia
SmythBroby0() -> SmythBroby0

Examples

julia
julia> SmythBroby0()
SmythBroby0()

Related

source
PortfolioOptimisers.SmythBroby1 Type
julia
struct SmythBroby1 <: SmythBrobyCovarianceAlgorithm

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

Constructors

julia
SmythBroby1() -> SmythBroby1

Examples

julia
julia> SmythBroby1()
SmythBroby1()

Related

source
PortfolioOptimisers.SmythBroby2 Type
julia
struct SmythBroby2 <: SmythBrobyCovarianceAlgorithm

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

Constructors

julia
SmythBroby2() -> SmythBroby2

Examples

julia
julia> SmythBroby2()
SmythBroby2()

Related

source
PortfolioOptimisers.SmythBrobyGerber0 Type
julia
struct SmythBrobyGerber0 <: SmythBrobyCovarianceAlgorithm

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

Constructors

julia
SmythBrobyGerber0() -> SmythBrobyGerber0

Examples

julia
julia> SmythBrobyGerber0()
SmythBrobyGerber0()

Related

source
PortfolioOptimisers.SmythBrobyGerber1 Type
julia
struct SmythBrobyGerber1 <: SmythBrobyCovarianceAlgorithm

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

Constructors

julia
SmythBrobyGerber1() -> SmythBrobyGerber1

Examples

julia
julia> SmythBrobyGerber1()
SmythBrobyGerber1()

Related

source
PortfolioOptimisers.SmythBrobyGerber2 Type
julia
struct SmythBrobyGerber2 <: SmythBrobyCovarianceAlgorithm

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

Constructors

julia
SmythBrobyGerber2() -> SmythBrobyGerber2

Examples

julia
julia> SmythBrobyGerber2()
SmythBrobyGerber2()

Related

source
PortfolioOptimisers.SmythBrobyCount0 Type
julia
struct SmythBrobyCount0 <: SmythBrobyCovarianceAlgorithm

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

Constructors

julia
SmythBrobyCount0() -> SmythBrobyCount0

Examples

julia
julia> SmythBrobyCount0()
SmythBrobyCount0()

Related

source
PortfolioOptimisers.SmythBrobyCount1 Type
julia
struct SmythBrobyCount1 <: SmythBrobyCovarianceAlgorithm

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

Constructors

julia
SmythBrobyCount1() -> SmythBrobyCount1

Examples

julia
julia> SmythBrobyCount1()
SmythBrobyCount1()

Related

source
PortfolioOptimisers.SmythBrobyCount2 Type
julia
struct SmythBrobyCount2 <: SmythBrobyCovarianceAlgorithm

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

Constructors

julia
SmythBrobyCount2() -> SmythBrobyCount2

Examples

julia
julia> SmythBrobyCount2()
SmythBrobyCount2()

Related

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.

Mathematical definition

κ(ri,rj)=(1+|ri|)(1+|rj|),γ(ri,rj)=|rirj|.

Where:

  • κ(ri,rj): Amplitude kernel.

  • γ(ri,rj): Divergence measure between returns.

  • ri,rj: Absolute standardised returns for assets i and j.

δ(ri,rj,n)=κ(ri,rj)1+γ(ri,rj)n.

Where:

  • δ(ri,rj,n): Smyth-Broby kernel value.

  • n: Exponent parameter controlling kernel sharpness.

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, X::MatNum, mu::ArrNum, sd::ArrNum)

Compute the Smyth-Broby co-movement correlation matrix for the algorithm marker in ce.alg.

All nine variants share the pairwise kernel gerber_comovement! through a SmythBrobyKernel policy: observations are noise-gated by c1 * sigma, standardised, restricted to the [c2, c3] significance zone, and classified as concordant, discordant, or neutral by the sign of the product of standardised returns. The marker selects the accumulation family and denominator policy.

Mathematical definition

For each pair (i,j), accumulate over admissible observations t:

pos=tδ(|r~ti|,|r~tj|,n)1[r~tir~tj>0],neg=tδ(|r~ti|,|r~tj|,n)1[r~tir~tj<0],

with r~ti=(xtiμi)/σi and δ the sb_delta kernel. The Gerber-suffixed markers additionally track the counts c+,c of concordant and discordant observations and score pairs by posc+ and negc; the Count-suffixed markers use the bare counts. The variant number selects the reduction:

ρ^ij={(posneg)/(pos+neg)0(posneg)/(pos+neg+nn)1(posneg)/ρ^iiρ^jj2.

Where nn accumulates neutral (one-sided) observations for variant 1, and variant 2 standardises the raw matrix by the geometric mean of its diagonal.

Arguments

  • ce: Smyth-Broby covariance estimator.

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

  • mu: Vector of asset means.

  • sd: Vector of asset standard deviations.

Returns

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

Related

source
PortfolioOptimisers.GerberComovementZero Type

Union of Gerber-family co-movement algorithm markers whose pairwise statistic is (pos - neg) / (pos + neg), guarded to zero when the denominator vanishes.

Related

source
PortfolioOptimisers.GerberComovementOne Type

Union of Gerber-family co-movement algorithm markers whose pairwise statistic is (pos - neg) / (pos + neg + nn), including neutral co-movements in the denominator, guarded to zero when the denominator vanishes.

Related

source
PortfolioOptimisers.GerberComovementTwo Type

Union of Gerber-family co-movement algorithm markers whose pairwise statistic is the raw pos - neg, with the resulting matrix standardised by the geometric mean of its diagonal via standardise_comovement!.

Related

source
PortfolioOptimisers.SmythBrobyDeltaAlg Type

Union of Smyth-Broby algorithm markers that accumulate the sb_delta kernel values only.

Related

source
PortfolioOptimisers.SmythBrobyGerberAlg Type

Union of Smyth-Broby algorithm markers that accumulate both the sb_delta kernel values and co-movement counts, scoring pairs by their product.

Related

source
PortfolioOptimisers.SmythBrobyCountAlg Type

Union of Smyth-Broby algorithm markers that accumulate co-movement counts only.

Related

source
PortfolioOptimisers.SmythBrobyKernel Type
julia
struct SmythBrobyKernel{T1<:SmythBrobyCovarianceAlgorithm, T2<:(AbstractArray{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}}), T3<:(AbstractArray{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}}), T4<:Number, T5<:Number, T6<:Number, T7<:Number}

Co-movement policy for gerber_comovement! implementing the Smyth-Broby family.

Observations are centered and standardised per asset, thresholded by c1 * sigma (noise gate), the [c2, c3] significance zone, and classified by the sign of the product of standardised returns. The alg marker selects the accumulation family (sb_add_pos) and the denominator policy (comovement_ratio).

Fields

  • alg: Smyth-Broby algorithm marker.

  • mu: Vector of asset means.

  • sd: Vector of asset standard deviations.

  • c1, c2, c3: Noise-gate and significance-zone thresholds.

  • n: Exponent of the sb_delta kernel.

Related

source
PortfolioOptimisers.gerber_comovement! Function
julia
gerber_comovement!(
    rho::AbstractMatrix,
    ex::Transducers.Executor,
    X::AbstractMatrix{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}},
    pol
) -> Any

Fill the symmetric co-movement matrix rho by running the shared Gerber-family pairwise kernel.

For every asset pair (i, j) the kernel builds the pair state via comovement_pair_state, folds every observation through comovement_step into the accumulator (pos, neg, nn, cpos, cneg, cnn) of weighted scores and counts, and stores the reduction comovement_finalise symmetrically. The policy object pol (e.g. SmythBrobyKernel, GerberIQKernel) owns the thresholding, classification, and weighting of a single observation, and the reduction of a pair's accumulator; the loop skeleton lives here once.

Arguments

  • rho::AbstractMatrix: N × N output matrix, overwritten.

  • ex: FLoops executor parallelising over the outer asset index.

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

  • pol: Co-movement policy object.

Returns

  • nothing.

Related

source
PortfolioOptimisers.comovement_pair_state Function
julia
comovement_pair_state(
    pol::SmythBrobyKernel,
    i::Integer,
    j::Integer
) -> NamedTuple{(:mui, :muj, :sigmai, :sigmaj, :c1i, :c1j), <:NTuple{6, Any}}

Build the per-pair state consumed by comovement_step.

The Smyth-Broby method returns the pair's means, standard deviations, and noise-gate thresholds c1 * sigma. The Gerber IQ method returns the pair's threshold scaling factors and scaled thresholds.

Related

source
PortfolioOptimisers.comovement_step Function
julia
comovement_step(
    pol::SmythBrobyKernel,
    acc,
    st,
    xi::Number,
    xj::Number,
    _::Integer,
    _::Integer
) -> Any

Fold one observation of a pair into the co-movement accumulator.

The Smyth-Broby method skips observations inside the noise gate (|x| < c1 * sigma for both assets), centers and standardises the returns, skips observations outside the [c2, c3] significance zone, and classifies the rest as concordant, discordant, or neutral by the sign of the product of standardised returns. The Gerber IQ method thresholds absolute returns against the pair's scaled thresholds and weights observations by the IQ template and temporal decay via gerber_IQ_delta.

Arguments

  • pol: Co-movement policy object.

  • acc: Pair accumulator (pos, neg, nn, cpos, cneg, cnn).

  • st: Pair state from comovement_pair_state.

  • xi, xj: Returns of assets i and j at observation k.

  • T: Number of observations.

  • k: Observation index.

Returns

  • The updated accumulator.

Related

source
PortfolioOptimisers.comovement_finalise Function
julia
comovement_finalise(
    pol::SmythBrobyKernel,
    acc,
    _::Type{T}
) -> Any

Reduce a pair's accumulator to the pairwise co-movement statistic.

Selects the family scores (for Smyth-Broby, via sb_pair_scores) and applies the variant's denominator policy via comovement_ratio.

Related

source
PortfolioOptimisers.comovement_ratio Function
julia
comovement_ratio(
    _::Union{Gerber0, SmythBroby0, SmythBrobyCount0, SmythBrobyGerber0},
    p::Number,
    n::Number,
    nn::Number,
    _::Type{T}
) -> Any

Reduce a pair's accumulated positive, negative, and neutral co-movement scores to the pairwise correlation entry.

The variant marker selects the denominator policy:

Arguments

  • alg: Co-movement algorithm marker.

  • p, n, nn: Accumulated positive, negative, and neutral scores.

  • T: Element type used for the guarded zero.

Returns

  • The pairwise co-movement statistic.

Related

source
PortfolioOptimisers.standardise_comovement! Function
julia
standardise_comovement!(_, _::AbstractMatrix)

Standardise a raw co-movement matrix by the geometric mean of its diagonal.

Only the GerberComovementTwo variants standardise; the fall-through method is a no-op. Divides each entry by sqrt(rho[i, i] * rho[j, j]), clamping the diagonal roots away from zero.

Returns

  • nothing.

Related

source
PortfolioOptimisers.sb_add_pos Function
julia
sb_add_pos(
    _::Union{SmythBroby0, SmythBroby1, SmythBroby2},
    acc,
    ari::Number,
    arj::Number,
    n::Number
) -> Union{NamedTuple, DataStructures.SortedMultiDict}

Accumulate a concordant observation into the pair accumulator, according to the Smyth-Broby family of alg.

Related

source
PortfolioOptimisers.sb_add_neg Function
julia
sb_add_neg(
    _::Union{SmythBroby0, SmythBroby1, SmythBroby2},
    acc,
    ari::Number,
    arj::Number,
    n::Number
) -> Union{NamedTuple, DataStructures.SortedMultiDict}

Accumulate a discordant observation into the pair accumulator, according to the Smyth-Broby family of alg.

Mirrors sb_add_pos on the negative score and count.

Related

source
PortfolioOptimisers.sb_add_neutral Function
julia
sb_add_neutral(
    _::SmythBroby1,
    acc,
    ari::Number,
    arj::Number,
    n::Number
) -> Union{NamedTuple, DataStructures.SortedMultiDict}

Accumulate a neutral (one-sided) observation into the pair accumulator.

Only the GerberComovementOne variants track neutral co-movements, mirroring sb_add_pos on the neutral score and count; the fall-through method returns the accumulator unchanged.

Related

source
PortfolioOptimisers.sb_pair_scores Function
julia
sb_pair_scores(
    _::Union{SmythBroby0, SmythBroby1, SmythBroby2},
    acc
) -> Tuple{Any, Any, Any}

Select the pair's positive, negative, and neutral scores from the accumulator, according to the Smyth-Broby family of alg.

Related

source