Smyth-Broby Covariance
PortfolioOptimisers.BaseSmythBrobyCovariance
— Typeabstract type BaseSmythBrobyCovariance <: BaseGerberCovariance end
Abstract supertype for all Smyth-Broby covariance estimators in PortfolioOptimisers.jl.
All concrete types implementing Smyth-Broby covariance estimation algorithms should subtype BaseSmythBrobyCovariance
. This enables a consistent interface for Smyth-Broby-based covariance estimators throughout the package.
Related
PortfolioOptimisers.SmythBrobyCovarianceAlgorithm
— Typeabstract type SmythBrobyCovarianceAlgorithm <: AbstractMomentAlgorithm end
Abstract supertype for all Smyth-Broby covariance algorithm types in PortfolioOptimisers.jl.
All concrete types implementing specific Smyth-Broby covariance algorithms should subtype SmythBrobyCovarianceAlgorithm
. This enables flexible extension and dispatch of Smyth-Broby covariance routines.
These types are used to specify the algorithm when constructing a SmythBrobyCovariance
estimator.
Related
PortfolioOptimisers.UnNormalisedSmythBrobyCovarianceAlgorithm
— Typeabstract type UnNormalisedSmythBrobyCovarianceAlgorithm <: SmythBrobyCovarianceAlgorithm end
Abstract supertype for all unnormalised Smyth-Broby covariance algorithm types.
Concrete types implementing unnormalised Smyth-Broby covariance algorithms should subtype UnNormalisedSmythBrobyCovarianceAlgorithm
.
Related
PortfolioOptimisers.NormalisedSmythBrobyCovarianceAlgorithm
— Typeabstract type NormalisedSmythBrobyCovarianceAlgorithm <: SmythBrobyCovarianceAlgorithm end
Abstract supertype for all normalised Smyth-Broby covariance algorithm types. These Z-transform the data before applying the Smyth-Broby covariance algorithm.
Concrete types implementing normalised Smyth-Broby covariance algorithms should subtype NormalisedSmythBrobyCovarianceAlgorithm
.
Related
PortfolioOptimisers.SmythBroby0
— Typestruct SmythBroby0 <: UnNormalisedSmythBrobyCovarianceAlgorithm end
Implements the original Smyth-Broby covariance algorithm (unnormalised variant).
Related
PortfolioOptimisers.SmythBroby1
— Typestruct SmythBroby1 <: UnNormalisedSmythBrobyCovarianceAlgorithm end
Implements the first variant of the Smyth-Broby covariance algorithm (unnormalised).
Related
PortfolioOptimisers.SmythBroby2
— Typestruct SmythBroby2 <: UnNormalisedSmythBrobyCovarianceAlgorithm end
Implements the second variant of the Smyth-Broby covariance algorithm (unnormalised).
Related
PortfolioOptimisers.SmythBrobyGerber0
— Typestruct SmythBrobyGerber0 <: UnNormalisedSmythBrobyCovarianceAlgorithm end
Implements the original Gerber-style variant of the Smyth-Broby covariance algorithm (unnormalised).
Related
PortfolioOptimisers.SmythBrobyGerber1
— Typestruct SmythBrobyGerber1 <: UnNormalisedSmythBrobyCovarianceAlgorithm end
Implements the first Gerber-style variant of the Smyth-Broby covariance algorithm (unnormalised).
Related
PortfolioOptimisers.SmythBrobyGerber2
— Typestruct SmythBrobyGerber2 <: UnNormalisedSmythBrobyCovarianceAlgorithm end
Implements the second Gerber-style variant of the Smyth-Broby covariance algorithm (unnormalised).
Related
PortfolioOptimisers.NormalisedSmythBroby0
— Typestruct NormalisedSmythBroby0 <: NormalisedSmythBrobyCovarianceAlgorithm end
Implements the original Smyth-Broby covariance algorithm on Z-transformed data (normalised variant).
Related
PortfolioOptimisers.NormalisedSmythBroby1
— Typestruct NormalisedSmythBroby1 <: NormalisedSmythBrobyCovarianceAlgorithm end
Implements the first variant of the Smyth-Broby covariance algorithm on Z-transformed data (normalised).
Related
PortfolioOptimisers.NormalisedSmythBroby2
— Typestruct NormalisedSmythBroby2 <: NormalisedSmythBrobyCovarianceAlgorithm end
Implements the second variant of the Smyth-Broby covariance algorithm on Z-transformed data (normalised).
Related
PortfolioOptimisers.NormalisedSmythBrobyGerber0
— Typestruct NormalisedSmythBrobyGerber0 <: NormalisedSmythBrobyCovarianceAlgorithm end
Implements the original Gerber-style variant of the Smyth-Broby covariance algorithm on Z-transformed data (normalised).
Related
PortfolioOptimisers.NormalisedSmythBrobyGerber1
— Typestruct NormalisedSmythBrobyGerber1 <: NormalisedSmythBrobyCovarianceAlgorithm end
Implements the first Gerber-style variant of the Smyth-Broby covariance algorithm on Z-transformed data (normalised).
Related
PortfolioOptimisers.NormalisedSmythBrobyGerber2
— Typestruct NormalisedSmythBrobyGerber2 <: NormalisedSmythBrobyCovarianceAlgorithm end
Implements the second Gerber-style variant of the Smyth-Broby covariance algorithm on Z-transformed data (normalised).
Related
PortfolioOptimisers.SmythBrobyCovariance
— Typestruct SmythBrobyCovariance{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10} <:
BaseSmythBrobyCovariance
me::T1
ve::T2
pdm::T3
threshold::T4
c1::T5
c2::T6
c3::T7
n::T8
alg::T9
threads::T10
end
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. This enables modular and extensible workflows for robust covariance estimation using Smyth-Broby statistics.
Fields
me::AbstractExpectedReturnsEstimator
: Expected returns estimator.ve::StatsBase.CovarianceEstimator
: Variance estimator.pdm::Posdef
: Positive definite matrix estimator (seePosdef
).threshold::Real
: Threshold parameter for Smyth-Broby covariance computation (typically in (0, 1)).c1::Real
: Zone of confusion parameter (typically in (0, 1]).c2::Real
: Zone of indecision lower bound (typically in (0, 1]).c3::Real
: Zone of indecision upper bound (must satisfyc3 > c2
).n::Real
: Exponent parameter for the Smyth-Broby kernel.alg::SmythBrobyCovarianceAlgorithm
: Smyth-Broby covariance algorithm variant.threads::FLoops.Transducers.Executor
: Parallel execution strategy.
Constructor
SmythBrobyCovariance(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns(),
ve::StatsBase.CovarianceEstimator = SimpleVariance(),
pdm::Union{Nothing, <:Posdef} = Posdef(),
threshold::Real = 0.5, c1::Real = 0.5, c2::Real = 0.5,
c3::Real = 4.0, n::Real = 2.0,
alg::SmythBrobyCovarianceAlgorithm = SmythBrobyGerber1(),
threads::FLoops.Transducers.Executor = ThreadedEx())
Construct a SmythBrobyCovariance
estimator with the specified algorithm, estimators, parameters, and threading strategy.
Related
BaseSmythBrobyCovariance
AbstractExpectedReturnsEstimator
SimpleExpectedReturns
StatsBase.CovarianceEstimator
SimpleVariance
Posdef
SmythBrobyCovarianceAlgorithm
SmythBroby0
SmythBroby1
SmythBroby2
NormalisedSmythBroby0
NormalisedSmythBroby1
NormalisedSmythBroby2
SmythBrobyGerber0
SmythBrobyGerber1
SmythBrobyGerber2
NormalisedSmythBrobyGerber0
NormalisedSmythBrobyGerber1
NormalisedSmythBrobyGerber2
FLoops.Transducers.Executor
PortfolioOptimisers.SmythBrobyCovariance
— MethodSmythBrobyCovariance(;
me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns(),
ve::StatsBase.CovarianceEstimator = SimpleVariance(),
pdm::Union{Nothing, <:Posdef} = Posdef(),
threshold::Real = 0.5,
c1::Real = 0.5,
c2::Real = 0.5,
c3::Real = 4.0,
n::Real = 2.0,
alg::SmythBrobyCovarianceAlgorithm = SmythBrobyGerber1(),
threads::FLoops.Transducers.Executor = ThreadedEx()
)
Construct a SmythBrobyCovariance
estimator for robust Smyth-Broby-based covariance or correlation estimation.
This constructor creates a SmythBrobyCovariance
object using the specified Smyth-Broby algorithm, expected returns estimator, variance estimator, positive definite matrix estimator, algorithm parameters, and threading strategy. The estimator is highly modular, allowing users to select from different Smyth-Broby algorithm variants, as well as custom estimators and parallel execution strategies.
Arguments
me::AbstractExpectedReturnsEstimator
: Expected returns estimator.ve::StatsBase.CovarianceEstimator
: Variance estimator.pdm::Union{Nothing, <:Posdef}
: Positive definite matrix estimator.threshold::Real
: Threshold parameter for Smyth-Broby covariance computation (must satisfy0 < threshold < 1
).c1::Real
: Zone of confusion parameter (must satisfy0 < c1 ≤ 1
).c2::Real
: Zone of indecision lower bound (must satisfy0 < c2 ≤ 1
).c3::Real
: Zone of indecision upper bound (must satisfyc3 > c2
).n::Real
: Exponent parameter for the Smyth-Broby kernel.alg::SmythBrobyCovarianceAlgorithm
: Smyth-Broby covariance algorithm variant.threads::FLoops.Transducers.Executor
: Parallel execution strategy.
ReturnsResult
SmythBrobyCovariance
: A configured Smyth-Broby covariance estimator.
Validation
- Asserts that
threshold
is strictly in(0, 1)
. - Asserts that
c1
is in(0, 1]
. - Asserts that
c2
is in(0, 1]
andc3 > c2
.
Examples
julia> ce = SmythBrobyCovariance()
SmythBrobyCovariance
me | SimpleExpectedReturns
| w | nothing
ve | SimpleVariance
| me | SimpleExpectedReturns
| | w | nothing
| w | nothing
| corrected | Bool: true
pdm | Posdef
| alg | UnionAll: NearestCorrelationMatrix.Newton
threshold | Float64: 0.5
c1 | Float64: 0.5
c2 | Float64: 0.5
c3 | Float64: 4.0
n | Float64: 2.0
alg | SmythBrobyGerber1()
threads | Transducers.ThreadedEx{@NamedTuple{}}: Transducers.ThreadedEx()
Related
SmythBrobyCovariance
BaseSmythBrobyCovariance
AbstractExpectedReturnsEstimator
SimpleExpectedReturns
StatsBase.CovarianceEstimator
SimpleVariance
Posdef
SmythBrobyCovarianceAlgorithm
SmythBroby0
SmythBroby1
SmythBroby2
NormalisedSmythBroby0
NormalisedSmythBroby1
NormalisedSmythBroby2
SmythBrobyGerber0
SmythBrobyGerber1
SmythBrobyGerber2
NormalisedSmythBrobyGerber0
NormalisedSmythBrobyGerber1
NormalisedSmythBrobyGerber2
FLoops.Transducers.Executor
PortfolioOptimisers.sb_delta
— Functionsb_delta(xi::Real, xj::Real, mui::Real, muj::Real, sigmai::Real, sigmaj::Real,
c1::Real, c2::Real, c3::Real, n::Real)
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.
Arguments
xi::Real
: Return for asseti
.xj::Real
: Return for assetj
.mui::Real
: Mean for asseti
.muj::Real
: Mean for assetj
.sigmai::Real
: Standard deviation for asseti
.sigmaj::Real
: Standard deviation for assetj
.c1::Real
: Zone of confusion parameter (typically in (0, 1]).c2::Real
: Zone of indecision lower bound (typically in (0, 1]).c3::Real
: Zone of indecision upper bound (must satisfyc3 > c2
).n::Real
: Exponent parameter for the kernel.
ReturnsResult
kernel::Real
: The computed kernel value for the pair(xi, xj)
.
Details
- If both returns are within the zone of confusion (
abs(xi) < sigmai * c1
andabs(xj) < sigmaj * c1
), returns zero. - Computes centered and scaled returns
ri
,rj
. - If both are within the zone of indecision (
ri < c2 && rj < c2
) or both are above the upper bound (ri > c3 && rj > c3
), returns zero. - Otherwise, returns
sqrt((1 + ri) * (1 + rj)) / (1 + abs(ri - rj)^n)
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:SmythBroby0, <:Any},
X::AbstractMatrix, mean_vec::AbstractArray, std_vec::AbstractArray)
Implements the original Smyth-Broby covariance/correlation algorithm (unnormalised variant).
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::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBroby0, <:Any}
: Smyth-Broby covariance estimator configured with theSmythBroby0
algorithm.X::AbstractMatrix
: Data matrix (observations × assets).mean_vec::AbstractArray
: Vector of means for each asset, used for centering.std_vec::AbstractArray
: Vector of standard deviations for each asset, used for scaling and thresholding.
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, compute the centered and scaled returns for assets
i
andj
. - Apply the threshold to classify joint positive and negative co-movements.
- Use the
sb_delta
kernel to accumulate positive (pos
) and negative (neg
) contributions. - The correlation is computed as
(pos - neg) / (pos + neg)
if the denominator is nonzero, otherwise zero. - The resulting matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:NormalisedSmythBroby0, <:Any},
X::AbstractMatrix)
Implements the original Smyth-Broby covariance/correlation algorithm on Z-transformed data (normalised variant).
This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X
using the original NormalisedSmythBroby0
algorithm. The computation is performed on data that has already been Z-transformed (mean-centered and standardised), and is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive and negative co-movements.
Arguments
ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBroby0, <:Any}
: Smyth-Broby covariance estimator configured with theNormalisedSmythBroby0
algorithm.X::AbstractMatrix
: Z-transformed data matrix (observations × assets).
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, use the Z-transformed returns for assets
i
andj
. - Apply the threshold to classify joint positive and negative co-movements.
- Use the
sb_delta
kernel (with mean 0 and standard deviation 1) to accumulate positive (pos
) and negative (neg
) contributions. - The correlation is computed as
(pos - neg) / (pos + neg)
if the denominator is nonzero, otherwise zero. - The resulting matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:NormalisedSmythBroby0, <:Any},
X::AbstractMatrix)
Implements the original Smyth-Broby covariance/correlation algorithm on Z-transformed data (normalised variant).
This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X
using the original NormalisedSmythBroby0
algorithm. The computation is performed on data that has already been Z-transformed (mean-centered and standardised), and is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive and negative co-movements.
Arguments
ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBroby0, <:Any}
: Smyth-Broby covariance estimator configured with theNormalisedSmythBroby0
algorithm.X::AbstractMatrix
: Z-transformed data matrix (observations × assets).
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, use the Z-transformed returns for assets
i
andj
. - Apply the threshold to classify joint positive and negative co-movements.
- Use the
sb_delta
kernel (with mean 0 and standard deviation 1) to accumulate positive (pos
) and negative (neg
) contributions. - The correlation is computed as
(pos - neg) / (pos + neg)
if the denominator is nonzero, otherwise zero. - The resulting matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:NormalisedSmythBroby1, <:Any},
X::AbstractMatrix)
Implements the first variant of the Smyth-Broby covariance/correlation algorithm on Z-transformed data (normalised).
This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X
using the NormalisedSmythBroby1
algorithm. The computation is performed on data that has already been Z-transformed (mean-centered and standardised), and is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive, negative, and neutral (non-exceedance) co-movements.
Arguments
ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBroby1, <:Any}
: Smyth-Broby covariance estimator configured with theNormalisedSmythBroby1
algorithm.X::AbstractMatrix
: Z-transformed data matrix (observations × assets).
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, use the Z-transformed returns for assets
i
andj
. - Apply the threshold to classify joint positive, negative, and neutral co-movements.
- Use the
sb_delta
kernel (with mean 0 and standard deviation 1) to accumulate positive (pos
), negative (neg
), and neutral (nn
) contributions. - The correlation is computed as
(pos - neg) / (pos + neg + nn)
if the denominator is nonzero, otherwise zero. - The resulting matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:SmythBroby2, <:Any},
X::AbstractMatrix, mean_vec::AbstractArray, std_vec::AbstractArray)
Implements the second variant of the Smyth-Broby covariance/correlation algorithm (unnormalised).
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 normalised by the geometric mean of its diagonal elements.
Arguments
ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBroby2, <:Any}
: Smyth-Broby covariance estimator configured with theSmythBroby2
algorithm.X::AbstractMatrix
: Data matrix (observations × assets).mean_vec::AbstractArray
: Vector of means for each asset, used for centering.std_vec::AbstractArray
: Vector of standard deviations for each asset, used for scaling and thresholding.
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, normalised and projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, compute the centered and scaled returns for assets
i
andj
. - Apply the threshold to classify joint positive and negative co-movements.
- Use the
sb_delta
kernel to accumulate positive (pos
) and negative (neg
) contributions. - The raw correlation is computed as
pos - neg
. - The resulting matrix is normalised by dividing each element by the geometric mean of the corresponding diagonal elements.
- The matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:NormalisedSmythBroby2, <:Any},
X::AbstractMatrix)
Implements the second variant of the Smyth-Broby covariance/correlation algorithm on Z-transformed data (normalised).
This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X
using the NormalisedSmythBroby2
algorithm. The computation is performed on data that has already been Z-transformed (mean-centered and standardised), and is based on thresholding the data, applying the Smyth-Broby kernel, and aggregating positive and negative co-movements. The resulting matrix is then normalised by the geometric mean of its diagonal elements.
Arguments
ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBroby2, <:Any}
: Smyth-Broby covariance estimator configured with theNormalisedSmythBroby2
algorithm.X::AbstractMatrix
: Z-transformed data matrix (observations × assets).
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, normalised and projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, use the Z-transformed returns for assets
i
andj
. - Apply the threshold to classify joint positive and negative co-movements.
- Use the
sb_delta
kernel (with mean 0 and standard deviation 1) to accumulate positive (pos
) and negative (neg
) contributions. - The raw correlation is computed as
pos - neg
. - The resulting matrix is normalised by dividing each element by the geometric mean of the corresponding diagonal elements.
- The matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:SmythBrobyGerber0, <:Any},
X::AbstractMatrix, mean_vec::AbstractArray, std_vec::AbstractArray)
Implements the original Gerber-style variant of the Smyth-Broby covariance/correlation algorithm (unnormalised).
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::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBrobyGerber0, <:Any}
: Smyth-Broby covariance estimator configured with theSmythBrobyGerber0
algorithm.X::AbstractMatrix
: Data matrix (observations × assets).mean_vec::AbstractArray
: Vector of means for each asset, used for centering.std_vec::AbstractArray
: Vector of standard deviations for each asset, used for scaling and thresholding.
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, compute the centered and scaled returns for assets
i
andj
. - Apply the threshold to classify joint positive and negative co-movements.
- 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. - The correlation is computed as
(pos * cpos - neg * cneg) / (pos * cpos + neg * cneg)
if the denominator is nonzero, otherwise zero. - The resulting matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:NormalisedSmythBrobyGerber0, <:Any},
X::AbstractMatrix)
Implements the original Gerber-style variant of the Smyth-Broby covariance/correlation algorithm on Z-transformed data (normalised).
This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X
using the NormalisedSmythBrobyGerber0
algorithm. The computation is performed on data that has already been Z-transformed (mean-centered and standardised), and 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::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyGerber0, <:Any}
: Smyth-Broby covariance estimator configured with theNormalisedSmythBrobyGerber0
algorithm.X::AbstractMatrix
: Z-transformed data matrix (observations × assets).
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, use the Z-transformed returns for assets
i
andj
. - Apply the threshold to classify joint positive and negative co-movements.
- Use the
sb_delta
kernel (with mean 0 and standard deviation 1) to accumulate positive (pos
) and negative (neg
) contributions, and count the number of positive (cpos
) and negative (cneg
) co-movements. - The correlation is computed as
(pos * cpos - neg * cneg) / (pos * cpos + neg * cneg)
if the denominator is nonzero, otherwise zero. - The resulting matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:SmythBrobyGerber1, <:Any},
X::AbstractMatrix, mean_vec::AbstractArray, std_vec::AbstractArray)
Implements the first Gerber-style variant of the Smyth-Broby covariance/correlation algorithm (unnormalised).
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::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBrobyGerber1, <:Any}
: Smyth-Broby covariance estimator configured with theSmythBrobyGerber1
algorithm.X::AbstractMatrix
: Data matrix (observations × assets).mean_vec::AbstractArray
: Vector of means for each asset, used for centering.std_vec::AbstractArray
: Vector of standard deviations for each asset, used for scaling and thresholding.
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, compute the centered and scaled returns for assets
i
andj
. - Apply the threshold to classify joint positive, negative, and neutral co-movements.
- 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. - The correlation is computed as
(pos * cpos - neg * cneg) / (pos * cpos + neg * cneg + nn * cnn)
if the denominator is nonzero, otherwise zero. - The resulting matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:NormalisedSmythBrobyGerber1, <:Any},
X::AbstractMatrix)
Implements the first Gerber-style variant of the Smyth-Broby covariance/correlation algorithm on Z-transformed data (normalised).
This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X
using the NormalisedSmythBrobyGerber1
algorithm. The computation is performed on data that has already been Z-transformed (mean-centered and standardised), and 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::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyGerber1, <:Any}
: Smyth-Broby covariance estimator configured with theNormalisedSmythBrobyGerber1
algorithm.X::AbstractMatrix
: Z-transformed data matrix (observations × assets).
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, use the Z-transformed returns for assets
i
andj
. - Apply the threshold to classify joint positive, negative, and neutral co-movements.
- Use the
sb_delta
kernel (with mean 0 and standard deviation 1) to accumulate positive (pos
), negative (neg
), and neutral (nn
) contributions, and count the number of positive (cpos
), negative (cneg
), and neutral (cnn
) co-movements. - The correlation is computed as
(pos * cpos - neg * cneg) / (pos * cpos + neg * cneg + nn * cnn)
if the denominator is nonzero, otherwise zero. - The resulting matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:SmythBrobyGerber2, <:Any},
X::AbstractMatrix, mean_vec::AbstractArray, std_vec::AbstractArray)
Implements the second Gerber-style variant of the Smyth-Broby covariance/correlation algorithm (unnormalised).
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 normalised by the geometric mean of its diagonal elements.
Arguments
ce::SmythBrobyCovariance{..., SmythBrobyGerber2, ...}
: Smyth-Broby covariance estimator configured with theSmythBrobyGerber2
algorithm.X::AbstractMatrix
: Data matrix (observations × assets).mean_vec::AbstractArray
: Vector of means for each asset, used for centering.std_vec::AbstractArray
: Vector of standard deviations for each asset, used for scaling and thresholding.
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, normalised and projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, compute the centered and scaled returns for assets
i
andj
. - Apply the threshold to classify joint positive and negative co-movements.
- 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. - The raw correlation is computed as
pos * cpos - neg * cneg
. - The resulting matrix is normalised by dividing each element by the geometric mean of the corresponding diagonal elements.
- The matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
PortfolioOptimisers.smythbroby
— Methodsmythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:NormalisedSmythBrobyGerber2, <:Any},
X::AbstractMatrix)
Implements the second Gerber-style variant of the Smyth-Broby covariance/correlation algorithm on Z-transformed data (normalised).
This method computes the Smyth-Broby correlation or covariance matrix for the input data matrix X
using the NormalisedSmythBrobyGerber2
algorithm. The computation is performed on data that has already been Z-transformed (mean-centered and standardised), and 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 normalised by the geometric mean of its diagonal elements.
Arguments
ce::SmythBrobyCovariance{..., NormalisedSmythBrobyGerber2, ...}
: Smyth-Broby covariance estimator configured with theNormalisedSmythBrobyGerber2
algorithm.X::AbstractMatrix
: Z-transformed data matrix (observations × assets).
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix, normalised and projected to be positive definite using the estimator'spdm
field.
Details
The algorithm proceeds as follows:
- For each pair of assets
(i, j)
, iterate over all observations. - For each observation, use the Z-transformed returns for assets
i
andj
. - Apply the threshold to classify joint positive and negative co-movements.
- Use the
sb_delta
kernel (with mean 0 and standard deviation 1) to accumulate positive (pos
) and negative (neg
) contributions, and count the number of positive (cpos
) and negative (cneg
) co-movements. - The raw correlation is computed as
pos * cpos - neg * cneg
. - The resulting matrix is normalised by dividing each element by the geometric mean of the corresponding diagonal elements.
- The matrix is projected to the nearest positive definite matrix using
posdef!
.
Related
Statistics.cov
— Methodcov(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any,
<:UnNormalisedSmythBrobyCovarianceAlgorithm,
<:Any}, X::AbstractMatrix; dims::Int = 1,
mean = nothing, kwargs...)
Compute the Smyth-Broby covariance matrix using an unnormalised Smyth-Broby covariance estimator.
This method computes the Smyth-Broby covariance matrix for the input data matrix X
using the specified unnormalised Smyth-Broby covariance estimator UnNormalisedSmythBrobyCovarianceAlgorithm
. The mean and standard deviation vectors are computed using the estimator's expected returns and variance estimators. The Smyth-Broby correlation is computed via smythbroby
, and the result is rescaled to a covariance matrix using the standard deviation vector.
Arguments
ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:UnNormalisedSmythBrobyCovarianceAlgorithm, <:Any}
: Smyth-Broby covariance estimator.X::AbstractMatrix
: Data matrix (observations × assets).dims::Int
: Dimension along which to compute the covariance.mean
: Optional mean vector for centering. If not provided, computed usingce.me
.kwargs...
: Additional keyword arguments passed to the mean and standard deviation estimators.
ReturnsResult
sigma::Matrix{Float64}
: The Smyth-Broby covariance matrix.
Validation
- Asserts that
dims
is either1
or2
.
Related
SmythBrobyCovariance
UnNormalisedSmythBrobyCovarianceAlgorithm
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBroby0, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBroby1, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBroby2, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBrobyGerber0, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBrobyGerber1, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBrobyGerber2, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
cor(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:UnNormalisedSmythBrobyCovarianceAlgorithm, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
Statistics.cor
— Methodcor(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any,
<:UnNormalisedSmythBrobyCovarianceAlgorithm,
<:Any}, X::AbstractMatrix; dims::Int = 1,
mean = nothing, kwargs...)
Compute the Smyth-Broby correlation matrix using an unnormalised Smyth-Broby covariance estimator.
This method computes the Smyth-Broby correlation matrix for the input data matrix X
using the specified unnormalised Smyth-Broby covariance estimator UnNormalisedSmythBrobyCovarianceAlgorithm
. 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::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:UnNormalisedSmythBrobyCovarianceAlgorithm, <:Any}
: Smyth-Broby covariance estimator.X::AbstractMatrix
: Data matrix (observations × assets).dims::Int
: Dimension along which to compute the correlation.mean
: Optional mean vector for centering. If not provided, computed usingce.me
.kwargs...
: Additional keyword arguments passed to the mean and standard deviation estimators.
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix.
Validation
- Asserts that
dims
is either1
or2
.
Related
SmythBrobyCovariance
UnNormalisedSmythBrobyCovarianceAlgorithm
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBroby0, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBroby1, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBroby2, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBrobyGerber0, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBrobyGerber1, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:SmythBrobyGerber2, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
cov(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:UnNormalisedSmythBrobyCovarianceAlgorithm, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
Statistics.cov
— Methodcov(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:NormalisedSmythBrobyCovarianceAlgorithm,
<:Any}, X::AbstractMatrix; dims::Int = 1,
mean = nothing, kwargs...)
Compute the Smyth-Broby covariance matrix using a normalised Smyth-Broby covariance estimator.
This method computes the Smyth-Broby covariance matrix for the input data matrix X
using the specified normalised Smyth-Broby covariance estimator NormalisedSmythBrobyCovarianceAlgorithm
. The mean and standard deviation vectors are computed using the estimator's expected returns and variance estimators, and the data is Z-transformed before applying the Smyth-Broby algorithm. The resulting correlation matrix is rescaled to a covariance matrix using the standard deviation vector.
Arguments
ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyCovarianceAlgorithm, <:Any}
: Smyth-Broby covariance estimator.X::AbstractMatrix
: Data matrix (observations × assets).dims::Int
: Dimension along which to compute the covariance.mean
: Optional mean vector for centering. If not provided, computed usingce.me
.kwargs...
: Additional keyword arguments passed to the mean and standard deviation estimators.
ReturnsResult
sigma::Matrix{Float64}
: The Smyth-Broby covariance matrix.
Validation
- Asserts that
dims
is either1
or2
.
Details
- The input data is Z-transformed (mean-centered and standardised) before applying the Smyth-Broby algorithm.
- The resulting correlation matrix is rescaled to a covariance matrix using the standard deviation vector.
Related
SmythBrobyCovariance
NormalisedSmythBrobyCovarianceAlgorithm
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBroby0, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBroby1, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBroby2, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyGerber0, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyGerber1, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyGerber2, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
cor(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyCovarianceAlgorithm, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
Statistics.cor
— Methodcor(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:NormalisedSmythBrobyCovarianceAlgorithm,
<:Any}, X::AbstractMatrix; dims::Int = 1,
mean = nothing, kwargs...)
Compute the Smyth-Broby correlation matrix using a normalised Smyth-Broby covariance estimator.
This method computes the Smyth-Broby correlation matrix for the input data matrix X
using the specified normalised Smyth-Broby covariance estimator NormalisedSmythBrobyCovarianceAlgorithm
. The mean and standard deviation vectors are computed using the estimator's expected returns and variance estimators, and the data is Z-transformed before applying the Smyth-Broby algorithm.
Arguments
ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyCovarianceAlgorithm, <:Any}
: Smyth-Broby covariance estimator.X::AbstractMatrix
: Data matrix (observations × assets).dims::Int
: Dimension along which to compute the correlation.mean
: Optional mean vector for centering. If not provided, computed usingce.me
.kwargs...
: Additional keyword arguments passed to the mean and standard deviation estimators.
ReturnsResult
rho::Matrix{Float64}
: The Smyth-Broby correlation matrix.
Validation
- Asserts that
dims
is either1
or2
.
Details
- The input data is Z-transformed (mean-centered and standardised) before applying the Smyth-Broby algorithm.
Related
SmythBrobyCovariance
NormalisedSmythBrobyCovarianceAlgorithm
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBroby0, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBroby1, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBroby2, <:Any}, X::AbstractMatrix)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyGerber0, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyGerber1, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
smythbroby(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyGerber2, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)
cov(ce::SmythBrobyCovariance{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:NormalisedSmythBrobyCovarianceAlgorithm, <:Any}, X::AbstractMatrix; dims::Int = 1, mean = nothing, kwargs...)