PortfolioOptimisersCovariance: private API

PortfolioOptimisers.find_uncorrelated_indicesFunction
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.

Algorithm

  1. Compute the correlation matrix rho with ce, and take its absolute value when absolute is true.
  2. When scores is nothing, collapse each column of rho with measure into summary_rho, the default drop score. Otherwise take summary_rho from scores.
  3. Read the strict lower triangle of rho into tril_idx, giving each pair once.
  4. Keep the pairs whose correlation is at least t, and sort them from the most to the least correlated.
  5. Walk that list. For a pair whose two assets are both still present, remove the one with the higher drop score. When the two scores are equal, remove both — the library's "if we cannot tell them apart, trust neither" tie policy, which is why two identical columns leave no survivor.
  6. Return the indices that step 5 did not remove, in ascending order.

Step 5 skips a pair whose assets are already removed, so the result depends on the order step 4 fixes.

Arguments

  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • ce: Covariance estimator.
  • 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 produce the default drop score. Ignored when scores is given.
  • scores: Per-asset drop scores; the asset with the higher score is removed from a correlated pair.

Validation

  • If scores is not nothing, length(scores) == size(X, 2), else a DimensionMismatch is raised.

Returns

  • idx::Vector{Int}: Indices of assets that form a maximally uncorrelated subset.

Related

source
PortfolioOptimisers.gap_fill_valueMethod
gap_fill_value(ce::PortfolioOptimisersCovariance) -> Number

Answer what ce.ce answers, because the composite forwards the sample and the mask untouched.

The composite adds matrix processing to an inner estimator and reads no cell of the sample itself, so a gap is the inner estimator's to keep or to lose. A composite wrapping a gap-aware estimator is therefore gap-aware, and one wrapping a plain estimator is not.

Arguments

  • ce: Composite covariance estimator with post-processing.

Returns

Related

source
PortfolioOptimisers.show_fieldsMethod
show_fields(
    _::PortfolioOptimisersCovariance
) -> Tuple{Symbol, Symbol}

Renders every field of a PortfolioOptimisersCovariance except cache.

The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one. Set set_show_nothing_fields!(:PortfolioOptimisersCovariance, true) to render it.

Arguments

  • ::PortfolioOptimisersCovariance: Covariance estimator, read for its type alone.

Returns

  • fields::Tuple: The field names to render, which is (:ce, :mp).

Related

source
PortfolioOptimisers.supports_partial_fitMethod
supports_partial_fit(
    ce::PortfolioOptimisersCovariance
) -> Any

PortfolioOptimisersCovariance method of supports_partial_fit.

The composite folds by composition, so it folds exactly when both of its halves allow it: the inner estimator must fold, and mp must carry no sample-reading alg. A composite a wrapper has given a buffer folds whatever those two say, which is the default and is what makes an mp.alg reachable online at all.

Arguments

  • ce: Covariance estimator.

Returns

Related

source