Skip to content
13

PortfolioOptimisersCovariance

PortfolioOptimisers.find_uncorrelated_indices Function
julia
find_uncorrelated_indices(X::MatNum;
                          ce::StatsBase.CovarianceEstimator = PortfolioOptimisersCovariance(),
                          t::Number = 0.95, absolute::Bool = false,
                          measure::VectorToScalarMeasure = MeanValue())

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 summary correlation measure (across all assets) is removed. The function returns the indices of the remaining uncorrelated assets.

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: If true, 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 decide which asset to remove when two are too correlated.

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 summary correlation value. If both assets have equal summary values, both are removed.

  • Returns the indices of assets not in the removed set.

Related

source
PortfolioOptimisers.PortfolioOptimisersCovariance Type
julia
struct PortfolioOptimisersCovariance{__T_ce, __T_mp} <: AbstractCovarianceEstimator

Composite 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

julia
PortfolioOptimisersCovariance(;
    ce::StatsBase.CovarianceEstimator = Covariance(),
    mp::AbstractMatrixProcessingEstimator = DenoiseDetoneAlgMatrixProcessing()
) -> PortfolioOptimisersCovariance

Keywords correspond to the struct's fields.

Examples

julia
julia> PortfolioOptimisersCovariance()
PortfolioOptimisersCovariance
  ce ┼ Covariance
     │    me ┼ SimpleExpectedReturns
     │       │   w ┴ nothing
     │    ce ┼ GeneralCovariance
     │       │   ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
     │       │    w ┴ nothing
     │   alg ┴ Full()
  mp ┼ DenoiseDetoneAlgMatrixProcessing
     │     pdm ┼ Posdef
     │         │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton
     │         │   kwargs ┴ @NamedTuple{}: NamedTuple()
     │      dn ┼ nothing
     │      dt ┼ nothing
     │     alg ┼ nothing
     │   order ┴ DenoiseDetoneAlg()

Related

source
Statistics.cov Method
julia
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

  • dims is either 1 or 2.

Related

source
Statistics.cor Method
julia
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

  • dims is either 1 or 2.

Related

source