Detone
PortfolioOptimisers.Detone
— Typestruct Detone{T1} <: AbstractDetoneEstimator
n::T1
end
A concrete detoning estimator for removing the top n
principal components (market modes) from a covariance or correlation matrix.
Fields
n::Integer
: Number of leading principal components to remove.
Related
PortfolioOptimisers.Detone
— MethodDetone(; n::Integer = 1)
Construct a Detone
estimator for removing the top n
principal components (market modes) from a covariance or correlation matrix.
Arguments
n::Integer
: Number of leading principal components to remove. Must satisfyn ≥ 0
.
ReturnsResult
Detone
: A detoning estimator.
Examples
julia> dt = Detone(; n = 2)
Detone
n | Int64: 2
Related
PortfolioOptimisers.detone!
— Functiondetone!(dt::Detone, X::AbstractMatrix, pdm::Union{Nothing, <:Posdef} = Posdef())
detone!(::Nothing, args...)
In-place removal of the top n
principal components (market modes) from a covariance or correlation matrix.
- If
dt
isnothing
, this is a no-op and returnsnothing
. - If
dt
is aDetone
object, the topn
principal components are removed fromX
in-place. Optionally, aPosdef
can be provided to ensure the output is positive definite.
Arguments
dt::Detone
: The detoning estimator specifying the number of components to remove.X::AbstractMatrix
: The covariance or correlation matrix to be detoned (modified in-place).pdm::Union{Nothing, <:Posdef}
: Optional positive definite matrix estimator.
ReturnsResult
nothing
. The input matrixX
is modified in-place.
Validation
- If
X
is a covariance matrix, it is internally converted to a correlation matrix for detoning and then rescaled. - The number of components removed is validated to be within the matrix size.
- If
pdm
is provided, the result is projected to the nearest positive definite matrix.
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.44414
Related
PortfolioOptimisers.detone
— Functiondetone(dt::Detone, X::AbstractMatrix, pdm::Union{Nothing, <:Posdef} = Posdef())
detone(::Nothing, args...)
Same as detone!
, but returns a new matrix instead of modifying X
in-place.
- If
dt
isnothing
, this is a no-op and returnsnothing
.
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> Xd = detone(Detone(), 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.44414
Related
PortfolioOptimisers.AbstractDetoneEstimator
— Typeabstract type AbstractDetoneEstimator <: AbstractEstimator end
Abstract 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