PortfolioOptimisersCovariance
PortfolioOptimisers.find_uncorrelated_indices Function
find_uncorrelated_indices(X::MatNum;
ce::StatsBase.CovarianceEstimator = PortfolioOptimisersCovariance(),
t::Number = 0.95, absolute::Bool = false,
measure::Num_VecToScaM = MeanValue(),
scores::Option{<:VecNum} = nothing)Find indices of a maximally uncorrelated subset of assets from a data matrix.
This function identifies a subset of asset columns in X such that no two assets in the subset have a pairwise (absolute) correlation exceeding the threshold t. When two assets are too correlated, the one with the higher drop score is removed. The function returns the indices of the remaining uncorrelated assets.
By default the drop score is each asset's summary correlation to every other asset, so the asset that is redundant with the most of the universe goes first. Supplying scores replaces that criterion — higher means "drop me" — which is how RedundancySelector makes the survivor of each correlated pair the better-scoring asset under a risk measure.
Internal machinery — the caller-facing form is RedundancySelector with a PairwiseCorrelation algorithm.
Arguments
X: Data matrix of asset returns (observations × assets).ce: Covariance estimator used to compute the correlation matrix.t: Correlation threshold above which two assets are considered too correlated.absolute: Iftrue, the absolute value of the correlation is used for comparison.measure: Summary measure applied to each column of the correlation matrix (e.g., mean) to produce the default drop score. Ignored whenscoresis given.scores: Per-asset drop scores; the asset with the higher score is removed from a correlated pair.
Returns
idx::Vector{Int}: Indices of assets that form a maximally uncorrelated subset.
Details
Computes the (absolute) correlation matrix for all assets.
Identifies pairs of assets with correlation at or above
t, sorted from most to least correlated.For each correlated pair (not yet removed), removes the asset with the higher drop score. If both assets score equally, both are removed — the library's "if we cannot tell them apart, trust neither" tie policy, which is why two identical columns leave no survivor.
Returns the indices of assets not in the removed set.
Related
sourcePortfolioOptimisers.PortfolioOptimisersCovariance Type
struct PortfolioOptimisersCovariance{__T_ce, __T_mp} <: AbstractCovarianceEstimatorComposite covariance estimator with post-processing.
PortfolioOptimisersCovariance is a flexible container type that combines any covariance estimator with a matrix post-processing step.
Fields
ce: Covariance estimator.mp: Matrix processing estimator.
Constructors
PortfolioOptimisersCovariance(;
ce::StatsBase.CovarianceEstimator = Covariance(),
mp::AbstractMatrixProcessingEstimator = MatrixProcessing()
) -> PortfolioOptimisersCovarianceKeywords correspond to the struct's fields.
Examples
julia> PortfolioOptimisersCovariance()
PortfolioOptimisersCovariance
ce ┼ Covariance
│ me ┼ SimpleExpectedReturns
│ │ w ┴ nothing
│ ce ┼ GeneralCovariance
│ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
│ │ w ┴ nothing
│ alg ┴ FullMoment()
mp ┼ MatrixProcessing
│ pdm ┼ Posdef
│ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton
│ │ kwargs ┴ @NamedTuple{}: NamedTuple()
│ dn ┼ nothing
│ dt ┼ nothing
│ alg ┼ nothing
│ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)Related
sourceStatistics.cov Method
Statistics.cov(ce::PortfolioOptimisersCovariance, X::MatNum; dims = 1, kwargs...)Compute the covariance matrix with post-processing using a PortfolioOptimisersCovariance estimator.
This method computes the covariance matrix for the input data matrix X using the underlying covariance estimator in ce, and then applies the matrix post-processing step specified by ce.mp.
Arguments
ce: Composite covariance estimator with post-processing.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the underlying covariance estimator and matrix processing step.
Returns
sigma::Matrix{<:Number}: The processed covariance matrix.
Validation
dimsis either1or2.
Related
sourceStatistics.cor Method
Statistics.cor(ce::PortfolioOptimisersCovariance, X::MatNum; dims = 1, kwargs...)Compute the correlation matrix with post-processing using a PortfolioOptimisersCovariance estimator.
This method computes the correlation matrix for the input data matrix X using the underlying covariance estimator in ce, and then applies the matrix post-processing step specified by ce.mp.
Arguments
ce: Composite covariance estimator with post-processing.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the underlying covariance estimator and matrix processing step.
Returns
rho::Matrix{<:Number}: The processed correlation matrix.
Validation
dimsis either1or2.
Related
source