Coskewness
PortfolioOptimisers.Coskewness Type
struct Coskewness{T1, T2, T3} <: CoskewnessEstimator
me::T1
mp::T2
alg::T3
endContainer type for coskewness estimators.
Coskewness encapsulates the mean estimator, matrix processing estimator, and moment algorithm for coskewness estimation.
Fields
me: Mean estimator for expected returns.mp: Matrix processing estimator for coskewness tensors.alg: Moment algorithm.
Constructor
Coskewness(; me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns(),
mp::AbstractMatrixProcessingEstimator = DenoiseDetoneAlgMatrixProcessing(),
alg::AbstractMomentAlgorithm = Full())Keyword arguments correspond to the fields above.
Examples
julia> Coskewness()
Coskewness
me ┼ SimpleExpectedReturns
│ w ┼ nothing
│ idx ┴ nothing
mp ┼ DenoiseDetoneAlgMatrixProcessing
│ pdm ┼ Posdef
│ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton
│ │ kwargs ┴ @NamedTuple{}: NamedTuple()
│ dn ┼ nothing
│ dt ┼ nothing
│ alg ┼ nothing
│ order ┴ DenoiseDetoneAlg()
alg ┴ Full()Related
PortfolioOptimisers.coskewness Function
coskewness(ske::Option{<:Coskewness}, X::MatNum; dims::Int = 1,
mean = nothing, kwargs...)Compute the full coskewness tensor and processed matrix for a dataset. For Full, it uses all centered data; for Semi, it uses only negative deviations. If the estimator is nothing, returns (nothing, nothing).
Arguments
ske: Coskewness estimator.X: Data matrix (observations × assets).dims: Dimensions along which to perform the computation.mean: Optional mean vector. If not provided, computed using the estimator's mean estimator.kwargs...: Additional keyword arguments passed to the mean estimator.
Validation
dimsis either1or2.
Returns
cskew::Matrix{<:Number}: Coskewness tensor (observations × assets^2).V::Matrix{<:Number}: Processed coskewness matrix (assets × assets).
Examples
julia> using StableRNGs
julia> rng = StableRNG(123456789);
julia> X = randn(rng, 10, 3);
julia> cskew, V = coskewness(Coskewness(), X);
julia> cskew
3×9 Matrix{Float64}:
-0.329646 0.0782455 0.325842 … 0.325842 -0.250881 0.16769
0.0782455 -0.236104 -0.250881 -0.250881 0.266005 0.144546
0.325842 -0.250881 0.16769 0.16769 0.144546 -0.605589
julia> V
3×3 Matrix{Float64}:
0.513743 -0.0452078 -0.290893
-0.0452078 0.402765 -0.0372996
-0.290893 -0.0372996 0.837701Related
sourcePortfolioOptimisers.CoskewnessEstimator Type
abstract type CoskewnessEstimator <: AbstractEstimator endAbstract supertype for all coskewness estimators in PortfolioOptimisers.jl.
All concrete and/or abstract types implementing coskewness estimation algorithms should be subtypes of CoskewnessEstimator.
Related
sourcePortfolioOptimisers.negative_spectral_coskewness Function
negative_spectral_coskewness(cskew::MatNum, X::MatNum,
mp::AbstractMatrixProcessingEstimator)Internal helper for coskewness matrix processing.
negative_spectral_coskewness processes the coskewness tensor by applying the matrix processing estimator to each block, then projects the result using eigenvalue decomposition and clamps negative values. Used internally for robust coskewness estimation.
Arguments
cskew: Coskewness tensor (flattened or block matrix).X: Data matrix (observations × assets).mp: Matrix processing estimator.
Returns
V::Matrix{<:Number}: Processed coskewness matrix.
Related
sourcePortfolioOptimisers._coskewness Function
_coskewness(Y::MatNum, X::MatNum, mp::AbstractMatrixProcessingEstimator)Internal helper for coskewness computation.
_coskewness computes the coskewness tensor and applies matrix processing. Used internally by coskewness estimators.
Arguments
Y: Centered data vector (e.g.,X .- mean).X: Data matrix (observations × assets).mp: Matrix processing estimator.
Returns
cskew::Matrix{<:Number}: Coskewness tensor.V::Matrix{<:Number}: Processed coskewness matrix.
Related
source