Rank Covariances
PortfolioOptimisers.KendallCovariance Type
struct KendallCovariance{__T_ve} <: RankCovarianceEstimatorRobust covariance estimator based on Kendall's tau rank correlation.
KendallCovariance implements a covariance estimator that uses Kendall's tau rank correlation to measure the monotonic association between pairs of asset returns. This estimator is robust to outliers and non-Gaussian data, making it suitable for financial applications where heavy tails or non-linear dependencies are present.
Fields
ve: Variance estimator.
Constructors
KendallCovariance(;
ve::AbstractVarianceEstimator = SimpleVariance()
) -> KendallCovarianceKeywords correspond to the struct's fields.
Examples
julia> KendallCovariance()
KendallCovariance
ve ┼ SimpleVariance
│ me ┼ SimpleExpectedReturns
│ │ w ┴ nothing
│ w ┼ nothing
│ corrected ┴ Bool: trueRelated
sourcePortfolioOptimisers.factory Method
factory(
ce::StatsBase.CovarianceEstimator,
args...;
kwargs...
) -> StatsBase.CovarianceEstimatorFallback for covariance estimator factory methods.
Arguments
ce: Covariance estimator.args...: Optional arguments (ignored).kwargs...: Optional keyword arguments (ignored).
Returns
ce::StatsBase.CovarianceEstimator: The original covariance estimator.
Related
sourceStatistics.cov Method
Statistics.cov(ce::KendallCovariance, X::MatNum; dims::Int = 1, kwargs...)Compute the Kendall's tau rank covariance matrix using a KendallCovariance estimator.
This method computes the covariance matrix for the input data matrix X by combining the Kendall's tau rank correlation matrix with the marginal standard deviations estimated by the variance estimator in ce. This approach is robust to outliers and non-Gaussian data.
Arguments
ce: Kendall's tau-based covariance estimator.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the variance estimator.
Returns
sigma::Matrix{<:Number}: Symmetric matrix of Kendall's tau rank covariances.
Validation
dimsis either1or2.
Examples
julia> X = [0.01 0.02; 0.03 0.04; 0.02 0.03];
julia> cov(KendallCovariance(), X)
2×2 Matrix{Float64}:
0.0001 0.0001
0.0001 0.0001Related
sourceStatistics.cor Method
Statistics.cor(::KendallCovariance, X::MatNum; dims::Int = 1, kwargs...)Compute the Kendall's tau rank correlation matrix using a KendallCovariance estimator.
This method computes the pairwise Kendall's tau rank correlation matrix for the input data matrix X. Kendall's tau measures the monotonic association between pairs of asset returns and is robust to outliers and non-Gaussian data.
Mathematical definition
For two asset return series
Where:
: Kendall's rank correlation between assets and . : Number of concordant pairs; a pair is concordant if . : Number of discordant pairs; a pair is discordant if . : Number of observations.
Arguments
ce: Kendall's tau-based covariance estimator.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments (currently unused).
Returns
rho::Matrix{<:Number}: Symmetric matrix of Kendall's tau rank correlation coefficients.
Validation
dimsis either1or2.
Examples
julia> X = [0.01 0.02; 0.03 0.04; 0.02 0.03];
julia> cor(KendallCovariance(), X)
2×2 Matrix{Float64}:
1.0 1.0
1.0 1.0Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(x, i, args...; kwargs...) -> nothing_scalar_array_view(x, i)Universal fallback for port_opt_view. Any value that has no more specific port_opt_view method is treated as leaf data: it is delegated to nothing_scalar_array_view, which slices arrays/VecScalars and passes scalars, nothing, estimators, and algorithms through unchanged. Composed structs that need to recurse into children define their own (more specific) method — emitted by the @vprop tag or hand-written.
The threaded tail args... (typically the returns matrix X for the JuMP families) and any kwargs are accepted and dropped here, so a macro-threaded port_opt_view(child, i, X) never MethodErrors on a leaf field.
Related
sourceport_opt_view(
ce::CovarianceEstimator,
_,
args...
) -> CorrelationCovariance{<:CovarianceEstimator}No-op fallback for getting the view of a covariance estimator.
Arguments
ce: Covariance estimator.args...: Optional arguments (ignored).
Returns
ce::StatsBase.CovarianceEstimator: The original covariance estimator.
Related
sourcePortfolioOptimisers.SpearmanCovariance Type
struct SpearmanCovariance{__T_ve} <: RankCovarianceEstimatorRobust covariance estimator based on Spearman's rho rank correlation.
SpearmanCovariance implements a covariance estimator that uses Spearman's rho rank correlation to measure the monotonic association between pairs of asset returns. This estimator is robust to outliers and non-Gaussian data, making it suitable for financial applications where heavy tails or non-linear dependencies are present.
Fields
ve: Variance estimator.
Constructors
SpearmanCovariance(;
ve::AbstractVarianceEstimator = SimpleVariance()
) -> SpearmanCovarianceKeywords correspond to the struct's fields.
Examples
julia> SpearmanCovariance()
SpearmanCovariance
ve ┼ SimpleVariance
│ me ┼ SimpleExpectedReturns
│ │ w ┴ nothing
│ w ┼ nothing
│ corrected ┴ Bool: trueRelated
sourcePortfolioOptimisers.factory Method
factory(
ce::StatsBase.CovarianceEstimator,
args...;
kwargs...
) -> StatsBase.CovarianceEstimatorFallback for covariance estimator factory methods.
Arguments
ce: Covariance estimator.args...: Optional arguments (ignored).kwargs...: Optional keyword arguments (ignored).
Returns
ce::StatsBase.CovarianceEstimator: The original covariance estimator.
Related
sourceStatistics.cov Method
Statistics.cov(ce::SpearmanCovariance, X::MatNum; dims::Int = 1, kwargs...)Compute the Spearman's rho rank covariance matrix using a SpearmanCovariance estimator.
This method computes the covariance matrix for the input data matrix X by combining the Spearman's rho rank correlation matrix with the marginal standard deviations estimated by the variance estimator in ce. This approach is robust to outliers and non-Gaussian data.
Arguments
ce: Spearman's rho-based covariance estimator.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the variance estimator.
Returns
sigma::Matrix{<:Number}: Symmetric matrix of Spearman's rho rank covariances.
Validation
dimsis either1or2.
Examples
julia> X = [0.01 0.02; 0.03 0.04; 0.02 0.03];
julia> cov(SpearmanCovariance(), X)
2×2 Matrix{Float64}:
0.0001 0.0001
0.0001 0.0001Related
sourceStatistics.cor Method
Statistics.cor(::SpearmanCovariance, X::MatNum; dims::Int = 1, kwargs...)Compute the Spearman's rho rank correlation matrix using a SpearmanCovariance estimator.
This method computes the pairwise Spearman's rho rank correlation matrix for the input data matrix X. Spearman's rho measures the monotonic association between pairs of asset returns and is robust to outliers and non-Gaussian data.
Mathematical definition
Spearman's
Where:
: Spearman's rank correlation between assets and . : Number of observations. : Return of asset at time . : Difference in ranks between assets and at time . : Rank function.
Arguments
ce: Spearman's rho-based covariance estimator.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments (currently unused).
Returns
rho::Matrix{<:Number}: Symmetric matrix of Spearman's rho rank correlation coefficients.
Validation
dimsis either1or2.
Examples
julia> X = [0.01 0.02; 0.03 0.04; 0.02 0.03];
julia> cor(SpearmanCovariance(), X)
2×2 Matrix{Float64}:
1.0 1.0
1.0 1.0Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(x, i, args...; kwargs...) -> nothing_scalar_array_view(x, i)Universal fallback for port_opt_view. Any value that has no more specific port_opt_view method is treated as leaf data: it is delegated to nothing_scalar_array_view, which slices arrays/VecScalars and passes scalars, nothing, estimators, and algorithms through unchanged. Composed structs that need to recurse into children define their own (more specific) method — emitted by the @vprop tag or hand-written.
The threaded tail args... (typically the returns matrix X for the JuMP families) and any kwargs are accepted and dropped here, so a macro-threaded port_opt_view(child, i, X) never MethodErrors on a leaf field.
Related
sourceport_opt_view(
ce::CovarianceEstimator,
_,
args...
) -> CorrelationCovariance{<:CovarianceEstimator}No-op fallback for getting the view of a covariance estimator.
Arguments
ce: Covariance estimator.args...: Optional arguments (ignored).
Returns
ce::StatsBase.CovarianceEstimator: The original covariance estimator.
Related
sourcePortfolioOptimisers.RankCovarianceEstimator Type
abstract type RankCovarianceEstimator <: AbstractCovarianceEstimatorAbstract supertype for all rank-based covariance estimators in PortfolioOptimisers.jl.
All concrete and/or abstract types implementing rank-based covariance estimation algorithms should be subtypes of RankCovarianceEstimator.
Related
source