Detone
Financial data is often responds to broad market conditions. This market-wide behaviour can obscure specific correlation signals. By removing the largest n eigenvalues, the idiosyncratic relationships between assets are allowed to shine through [1].
Detoned matrices may be non-positive definite, so they can be unsuitable for traditional optimisations, but they can be quite effective for clustering ones.
PortfolioOptimisers.AbstractDetoneEstimator Type
abstract type AbstractDetoneEstimator <: AbstractEstimator endAbstract supertype for all detoning estimators in PortfolioOptimisers.jl.
All concrete types representing detoning estimators (such as Detone) should subtype AbstractDetoneEstimator. This enables a consistent interface for detoning routines and downstream analysis.
Related
sourcePortfolioOptimisers.Detone Type
struct Detone{T1, T2} <: AbstractDetoneEstimator
n::T1
pdm::T2
endA concrete detoning estimator for removing the largest n principal components (market modes) from a covariance or correlation matrix in detone! and detone.
For financial data, the leading principal components often represent market-wide movements that can obscure asset-specific signals. The Detone estimator allows users to specify the number of these leading components to remove, thereby enhancing the focus on idiosyncratic relationships between market members [1].
Detoned matrices may not be suitable for non-clustering optimisations because it can make the matrix non-positive definite. However, they can be quite effective for clustering optimsations.
Fields
n: Number of leading principal components to remove.pdm: Optional Positive definite matrix estimator. If provided, ensures the output is positive definite.
Constructor
Detone(; n::Integer = 1, pdm::Option{<:Posdef} = Posdef())Keyword arguments correspond to the fields above.
Validation
n > 0.
Examples
julia> Detone(; n = 2)
Detone
n ┼ Int64: 2
pdm ┼ Posdef
│ alg ┼ UnionAll: NearestCorrelationMatrix.Newton
│ kwargs ┴ @NamedTuple{}: NamedTuple()Related
References
- [1] M. M. De Prado. Machine learning for asset managers (Cambridge University Press, 2020). Chapter 2.
PortfolioOptimisers.detone! Function
detone!(dt::Detone, X::MatNum)
detone!(::Nothing, args...)In-place removal of the top n principal components (market modes) from a covariance or correlation matrix.
For matrices without unit diagonal, the function converts them into correlation matrices i.e. matrices with unit diagonal, applies the algorithm, and rescales them back.
Arguments
dt: The estimator specifying the detoning algorithm.dt::Detone: The topnprincipal components are removed fromXin-place.dt::Nothing: No-op and returnsnothing.
X: The covariance or correlation matrix to be detoned (modified in-place).
Returns
nothing. The input matrixXis modified in-place.
Validation
1 <= dt.n <= size(X, 2).
Examples
julia> using StableRNGs
julia> rng = StableRNG(123456789);
julia> X = rand(rng, 10, 5);
julia> X = X' * X
5×5 Matrix{Float64}:
3.29494 2.0765 1.73334 2.01524 1.77493
2.0765 2.46967 1.39953 1.97242 2.07886
1.73334 1.39953 1.90712 1.17071 1.30459
2.01524 1.97242 1.17071 2.24818 1.87091
1.77493 2.07886 1.30459 1.87091 2.44414
julia> detone!(Detone(), X)
julia> X
5×5 Matrix{Float64}:
3.29494 -1.14673 0.0868439 -0.502106 -1.71581
-1.14673 2.46967 -0.876289 -0.0864304 0.274663
0.0868439 -0.876289 1.90712 -1.18851 -0.750345
-0.502106 -0.0864304 -1.18851 2.24818 -0.0774753
-1.71581 0.274663 -0.750345 -0.0774753 2.44414Related
References
- [1] M. M. De Prado. Machine learning for asset managers (Cambridge University Press, 2020). Chapter 2.