Robust shrinkage
PortfolioOptimisers.AbstractRobustShrinkageIntensity — Type
abstract type AbstractRobustShrinkageIntensity <: AbstractAlgorithmAbstract supertype for the rules that find the shrinkage intensity of a robust scatter from the data.
A shrunk robust scatter is a blend of the scatter of the data and of a target. The intensity is the weight of the target, in [0, 1]. A member of this family finds it when the fit runs. The slot also takes a number, the intensity itself.
Interfaces
A subtype implements one method for TylerShrinkage:
PortfolioOptimisers.tyler_intensity(rule, alg::AbstractTylerShrinkageAlgorithm, W::MatNum, w::Option{<:StatsBase.AbstractWeights}) -> Number: Returns the intensity that the formalgreads, for the centred dataW,observations × assets, in the coordinates that turn the target into the identity matrix.
A rule that MCDShrinkage can also hold subtypes AbstractSubsetShrinkageIntensity.
Related
PortfolioOptimisers.AbstractSubsetShrinkageIntensity — Type
abstract type AbstractSubsetShrinkageIntensity <: AbstractRobustShrinkageIntensityAbstract supertype for the shrinkage rules that can also read the scatter of one subset of the observations.
MCDShrinkage takes these rules, because the minimum covariance determinant shrinks the scatter of a subset. TylerShrinkage takes them too.
Interfaces
A subtype implements the method of AbstractRobustShrinkageIntensity, and one more:
PortfolioOptimisers.mcd_intensity(rule, W::MatNum, idx::AbstractVector{<:Integer}, c::Number, fixed::Bool) -> Number: Returns the intensity for the observationsidxof the dataW, in the coordinates that turn the target into the identity matrix.cis the factor of the scatter of the subset. Whenfixedistrue, the centre is zero.
Related
PortfolioOptimisers.ConditionNumberIntensity — Type
struct ConditionNumberIntensity{__T_max_cond} <: AbstractSubsetShrinkageIntensityTakes the smallest shrinkage intensity at which the condition number of the scatter is not above a bound.
Section 2.4 of [112] gives the rule for the shrunk minimum covariance determinant. The condition number is the one of the scatter in the coordinates that turn the target into the identity matrix. A scatter that meets the bound gets no shrinkage. For a subset the rule has a closed form. This library extends the rule to TylerShrinkage, where a bisection over the fits of the shape finds the intensity, at the pilot centre of the fit.
Mathematical definition
\[\begin{align} \rho &= \frac{a}{\kappa - 1 + a}\,, & a &= \max\left(0, \lambda_{\max} - \kappa \lambda_{\min}\right)\,. \end{align}\]
Where:
- $\rho$: The shrinkage intensity.
- $a$: The amount by which the scatter exceeds the bound.
- $\kappa$: The bound of the condition number,
max_cond. - $\lambda_{\min}$, $\lambda_{\max}$: The smallest and the largest eigenvalue of the scatter of the subset.
Fields
max_cond: Bound of the condition number of the scatter,max_cond > 1.
Constructors
ConditionNumberIntensity(; max_cond::Number = 50) -> ConditionNumberIntensityKeywords correspond to the struct's fields.
Validation
max_cond > 1.
Examples
julia> ConditionNumberIntensity()ConditionNumberIntensity max_cond ┴ Int64: 50Related
References
- [112] K. Boudt, P. J. Rousseeuw, S. Vanduffel and T. Verdonck. The minimum regularized covariance determinant estimator. Statistics and Computing 30, 113–128 (2020). Section 2.4, Equation 17.
PortfolioOptimisers.SphericityIntensity — Type
struct SphericityIntensity <: AbstractSubsetShrinkageIntensityTakes the shrinkage intensity of the smallest mean squared error, from a robust estimate of the sphericity of the scatter.
The sphericity $\gamma$ is the mean of the squares of the eigenvalues over the square of their mean. It is one when the scatter is a multiple of the target. [113] estimates it from the spatial signs of the data, so an outlier has the influence of one direction and not of its size. This library takes the signs about the coordinatewise median, and that work takes them about the spatial median.
For MCDShrinkage the intensity is the optimum at the normal model, with the count of the subset. The signs come from every observation, because a subset of the nearest observations is more spherical than the data. For TylerShrinkage it is the optimum of [114] for the shape of Tyler's M-estimator, which holds over the elliptical distributions.
Mathematical definition
\[\begin{align} \hat{\gamma} &= \frac{n}{n - 1} \left(p \, \mathrm{tr}(\mathbf{S}^2) - \frac{p}{n}\right)\,, \\ \rho_{\mathrm{MCD}} &= \frac{(\hat{\gamma} + p)/(h - 1)}{\hat{\gamma} - 1 + (\hat{\gamma} + p)/(h - 1)}\,, \\ \rho_{\mathrm{Tyler}} &= 1 - \frac{n (\hat{\gamma} - 1)}{n (\hat{\gamma} - 1)(1 - 1/n) + (2\hat{\gamma} + p)(p - 1)/(p + 2)}\,. \end{align}\]
Where:
- $\mathbf{S}$: The spatial sign covariance, the mean of the product moments of the unit vectors of the observations.
- $\hat{\gamma}$: The sphericity, clamped into $[1, p]$.
- $n$: The number of observations, or the effective count of the weights.
- $h$: The number of observations of the subset. A fixed centre gives $h$ in place of $h - 1$.
- $p$: The number of assets.
Examples
julia> SphericityIntensity()SphericityIntensity()Related
References
- [113] E. Ollila and E. Raninen. Optimal shrinkage covariance matrix estimation under random sampling from elliptical distributions. IEEE Transactions on Signal Processing 67, 2707–2719 (2019). Equations 23 and 25, and Section IV-A.
- [114] E. Ollila, D. P. Palomar and F. Pascal. Shrinking the eigenvalues of M-estimators of covariance matrix. IEEE Transactions on Signal Processing 69, 256–269 (2021). Corollary 2.
PortfolioOptimisers.OracleIntensity — Type
struct OracleIntensity <: AbstractRobustShrinkageIntensityTakes the oracle intensity of the work that gives the form of the shrunk Tyler shape, with an estimate in place of the unknown scatter.
Each form of TylerShrinkage has its own oracle, the intensity of the smallest mean squared error when the weights of the fixed point read the true scatter.
TraceNormalisedShrinkage: Equation 13 of [115], with the normalised sample covariance of its Equation 14.PenalisedShrinkage: Theorem 4 of [116] in the real case, with the Tyler shape when the sample gives one. Otherwise, the pilot is the penalised shape at the middle of the interval of the intensities at which it exists. That work leaves the choice of that pilot open.
Mathematical definition
\[\begin{align} \rho_{\mathrm{trace}} &= \frac{p^2 + (1 - 2/p) \, \mathrm{tr}(\mathbf{R}^2)}{p^2 - np - 2n + (n + 1 + 2(n - 1)/p) \, \mathrm{tr}(\mathbf{R}^2)}\,, \\ \rho_{\mathrm{penalised}} &= \frac{p - 2 + p \, \mathrm{tr}(\mathbf{V})}{p - 2 + p \, \mathrm{tr}(\mathbf{V}) + n (p + 2) (\mathrm{tr}(\mathbf{V}^{-2})/p - 1)}\,. \end{align}\]
Where:
- $\mathbf{R}$: $p$ times the spatial sign covariance of the data.
- $\mathbf{V}$: The pilot shape, with $\mathrm{tr}(\mathbf{V}^{-1}) = p$.
- $n$: The number of observations, or the effective count of the weights.
- $p$: The number of assets.
The rule clamps the intensity into $[0, 1]$.
Examples
julia> OracleIntensity()OracleIntensity()Related
References
- [115] Y. Chen, A. Wiesel and A. O. Hero. Robust shrinkage estimation of high-dimensional covariance matrices. IEEE Transactions on Signal Processing 59, 4097–4107 (2011). Theorem 2, Equations 13 and 14.
- [116] E. Ollila and D. E. Tyler. Regularized M-estimators of scatter matrix. IEEE Transactions on Signal Processing 62, 6059–6070 (2014). Section V-A, Theorem 4.
PortfolioOptimisers.AsymptoticIntensity — Type
struct AsymptoticIntensity <: AbstractRobustShrinkageIntensityTakes the intensity of the smallest mean squared error when the numbers of observations and of assets grow together.
Proposition 2 of [117] gives an equation in the intensity for each form of TylerShrinkage, and shows that both forms then reach the same error. The rule finds the smallest intensity that reaches the value of the equation by a bisection over the fits of the shape, at the pilot centre of the fit.
Mathematical definition
\[\begin{align} \frac{\rho \, a(\rho)}{1 - \rho + \rho \, a(\rho)} &= r\,, & a(\rho) &= \frac{1}{n} \sum_{t=1}^{n} \frac{\boldsymbol{x}_t^\intercal \mathbf{V}(\rho)^{-1} \boldsymbol{x}_t}{\lVert \boldsymbol{x}_t \rVert^2}\,, \\ \frac{\rho}{\mathrm{tr}(\mathbf{V}(\rho))/p} &= r\,, & r &= \frac{p/n}{\mathrm{tr}(\mathbf{R}^2)/p - 1}\,. \end{align}\]
Where:
- $\mathbf{V}(\rho)$: The shape at the intensity $\rho$. The first equation holds for
TraceNormalisedShrinkage, and the second forPenalisedShrinkage. - $\mathbf{R}$: $p$ times the spatial sign covariance of the data.
- $n$: The number of observations, or the effective count of the weights.
- $p$: The number of assets.
A value $r$ of one or more gives the intensity one.
Examples
julia> AsymptoticIntensity()AsymptoticIntensity()Related
References
- [117] R. Couillet and M. McKay. Large dimensional analysis and optimization of robust shrinkage covariance matrix estimators. Journal of Multivariate Analysis 131, 99–120 (2014). Propositions 1 and 2.
PortfolioOptimisers.AbstractTylerShrinkageAlgorithm — Type
abstract type AbstractTylerShrinkageAlgorithm <: AbstractAlgorithmAbstract supertype for the forms of the fixed point of a shrunk Tyler shape.
The two members give the same set of shapes. They read the intensity on different scales. The shape of TraceNormalisedShrinkage at the intensity $\rho$ is the shape of PenalisedShrinkage at the intensity $1 - (1 - \rho)/t$, where $t$ is the mean of the diagonal of the blend before its normalisation.
Interfaces
A subtype implements one method, and a method of each rule of the intensity that it takes:
PortfolioOptimisers.shrink_shape!(alg, V::MatNum, rho::Number) -> MatNum: Blends the stepVof the shape equation with the identity matrix in place.
Related
PortfolioOptimisers.TraceNormalisedShrinkage — Type
struct TraceNormalisedShrinkage <: AbstractTylerShrinkageAlgorithmBlends each step of the shape equation with the target, and scales the blend to a fixed trace.
[115] shows that the iteration has one limit for each intensity in (0, 1), for any number of observations.
Mathematical definition
\[\begin{align} \tilde{\mathbf{V}} &= (1 - \rho) \frac{p}{n} \sum_{t=1}^{n} \frac{\boldsymbol{x}_t \boldsymbol{x}_t^\intercal}{\boldsymbol{x}_t^\intercal \mathbf{V}^{-1} \boldsymbol{x}_t} + \rho \, \mathbf{I}\,, \\ \mathbf{V} &= p \, \tilde{\mathbf{V}} / \mathrm{tr}(\tilde{\mathbf{V}})\,. \end{align}\]
Where:
- $\mathbf{V}$: The shape, in the coordinates that turn the target into the identity matrix.
- $\rho$: The shrinkage intensity.
- $\boldsymbol{x}_t$: The centred observation $t$, in the same coordinates.
- $n$: The number of observations.
- $p$: The number of assets.
Examples
julia> TraceNormalisedShrinkage()TraceNormalisedShrinkage()Related
References
- [115] Y. Chen, A. Wiesel and A. O. Hero. Robust shrinkage estimation of high-dimensional covariance matrices. IEEE Transactions on Signal Processing 59, 4097–4107 (2011). Equations 8 and 9, Theorem 1.
PortfolioOptimisers.PenalisedShrinkage — Type
struct PenalisedShrinkage <: AbstractTylerShrinkageAlgorithmBlends each step of the shape equation with the target, with no normalisation, so the shape is the minimum of a penalised cost.
[116] derives the form from a penalty on the trace of the inverse shape. Its Theorem 3 shows that the shape exists in general position when the intensity is above $1 - n/p$. [118] derives the same form from a Kullback-Leibler penalty.
Mathematical definition
\[\begin{align} \mathbf{V} &= (1 - \rho) \frac{p}{n} \sum_{t=1}^{n} \frac{\boldsymbol{x}_t \boldsymbol{x}_t^\intercal}{\boldsymbol{x}_t^\intercal \mathbf{V}^{-1} \boldsymbol{x}_t} + \rho \, \mathbf{I}\,. \end{align}\]
Where:
- $\mathbf{V}$: The shape, in the coordinates that turn the target into the identity matrix.
- $\rho$: The shrinkage intensity.
- $\boldsymbol{x}_t$: The centred observation $t$, in the same coordinates.
- $n$: The number of observations.
- $p$: The number of assets.
Examples
julia> PenalisedShrinkage()PenalisedShrinkage()Related
References
- [116] E. Ollila and D. E. Tyler. Regularized M-estimators of scatter matrix. IEEE Transactions on Signal Processing 62, 6059–6070 (2014). Section V, Theorem 3.
- [118] Y. Sun, P. Babu and D. P. Palomar. Regularized Tyler's scatter estimator: existence, uniqueness, and algorithms. IEEE Transactions on Signal Processing 62, 5143–5156 (2014). Section III-B, Equation 21.
PortfolioOptimisers.MCDShrinkage — Type
struct MCDShrinkage{__T_tgt, __T_intensity} <: AbstractEstimatorShrinks the scatter of each subset of an MCDCovariance to a target, so the fit exists with fewer observations than assets.
MCDCovariance holds it in the field shr. The fit is then the minimum regularised covariance determinant of [112]: the subset whose shrunk scatter has the smallest determinant. The target does not change in the search.
The target tgt is a covariance matrix in the units of the data. A rule of CovarianceShrinkageTarget reads a robust pilot: the robust variances of the assets on the diagonal, and the sine transform of the Kendall correlations off it. The default DiagonalTarget is the diagonal of the robust variances, the identity target of [112] on its standardised data. ConstantCorrelationTarget is its equicorrelation target.
From the same starts and the same target, the fit agrees with the function CovMrcd of the R package rrcov, version 1.7-7. Two parts differ. That package takes another rank correlation for its equicorrelation target, see mcd_pilot. With fewer observations than assets, its starts read an arbitrary basis of the null space of each correlation estimate, and the starts of this library do not, see regular_directions.
Fields
tgt: Shrinkage target. A rule ofCovarianceShrinkageTarget, or a fixed positive definite matrix in the units of the data.
intensity: Shrinkage intensity, the weight of the target. A number in[0, 1], or a rule that finds it from the data.
Constructors
MCDShrinkage(; tgt::CovarianceShrinkageTarget = DiagonalTarget(), intensity::Union{Number, AbstractSubsetShrinkageIntensity} = ConditionNumberIntensity()) -> MCDShrinkageKeywords correspond to the struct's fields.
Validation
- A matrix
tgtis square, finite, symmetric and positive definite, asassert_shrinkage_targetstates. - A number
intensityis in[0, 1].
View parameters
port_opt_view slices a matrix tgt on both axes, and keeps a target rule as it is.
Examples
julia> MCDShrinkage(; intensity = 0.2)MCDShrinkage tgt ┼ DiagonalTarget() intensity ┴ Float64: 0.2Related
References
- [112] K. Boudt, P. J. Rousseeuw, S. Vanduffel and T. Verdonck. The minimum regularized covariance determinant estimator. Statistics and Computing 30, 113–128 (2020). Sections 2.2 and 2.4.
PortfolioOptimisers.TylerShrinkage — Type
struct TylerShrinkage{__T_alg, __T_tgt, __T_intensity} <: AbstractEstimatorShrinks the shape of a TylerCovariance to a target, so the fit exists with fewer observations than assets.
TylerCovariance holds it in the field shr. The form alg states the fixed point, and intensity the weight of the target in it. The number, or the rule, reads the scale of that form, see AbstractTylerShrinkageAlgorithm.
The target tgt is a covariance matrix in the units of the data, and its scale has no effect. A rule of CovarianceShrinkageTarget reads a robust pilot: the squares of the median absolute deviations of the assets on the diagonal, and the correlations of the spatial sign covariance off it. The default DiagonalTarget does not depend on the units of the assets. ScaledIdentityTarget gives the target of [115] and of [116], which has one variance for each asset.
Fields
alg: Form of the fixed point of the shrunk shape, a subtype ofAbstractTylerShrinkageAlgorithm. It states the scale on whichintensityis read.
tgt: Shrinkage target. A rule ofCovarianceShrinkageTarget, or a fixed positive definite matrix in the units of the data.
intensity: Shrinkage intensity, the weight of the target. A number in[0, 1], or a rule that finds it from the data.
Constructors
TylerShrinkage(; alg::AbstractTylerShrinkageAlgorithm = TraceNormalisedShrinkage(), tgt::CovarianceShrinkageTarget = DiagonalTarget(), intensity::Union{Number, AbstractRobustShrinkageIntensity} = OracleIntensity()) -> TylerShrinkageKeywords correspond to the struct's fields.
Validation
- A matrix
tgtis square, finite, symmetric and positive definite, asassert_shrinkage_targetstates. - A number
intensityis in[0, 1].
View parameters
port_opt_view slices a matrix tgt on both axes, and keeps a target rule as it is.
Examples
julia> TylerShrinkage()TylerShrinkage alg ┼ TraceNormalisedShrinkage() tgt ┼ DiagonalTarget() intensity ┴ OracleIntensity()Related
TylerCovarianceTraceNormalisedShrinkagePenalisedShrinkageOracleIntensityAsymptoticIntensitySphericityIntensityConditionNumberIntensityCovarianceShrinkageTargetMCDShrinkage
References
- [115] Y. Chen, A. Wiesel and A. O. Hero. Robust shrinkage estimation of high-dimensional covariance matrices. IEEE Transactions on Signal Processing 59, 4097–4107 (2011). Section III.
- [116] E. Ollila and D. E. Tyler. Regularized M-estimators of scatter matrix. IEEE Transactions on Signal Processing 62, 6059–6070 (2014). Section V.
PortfolioOptimisers.port_opt_view — Method
port_opt_view(shr::Union{MCDShrinkage{<:MatNum}, TylerShrinkage{<:Any, <:MatNum}}, i, args...)Restricts the fixed target of a robust shrinkage to the assets i.
A fixed target is an asset-by-asset matrix, so the method slices it on both axes. shrinkage_target builds the target of a rule from the pilot of the data, so a shrinkage with a rule needs no slice, and this method does not take it.
Arguments
shr: The shrinkage, with a matrix intgt.i: Indices of the selected assets.args...: Not read.
Returns
shr::Union{MCDShrinkage, TylerShrinkage}: The shrinkage restricted to the assetsi.
Related
References
- [112]
- K. Boudt, P. J. Rousseeuw, S. Vanduffel and T. Verdonck. The minimum regularized covariance determinant estimator. Statistics and Computing 30, 113–128 (2020).
- [113]
- E. Ollila and E. Raninen. Optimal shrinkage covariance matrix estimation under random sampling from elliptical distributions. IEEE Transactions on Signal Processing 67, 2707–2719 (2019).
- [114]
- E. Ollila, D. P. Palomar and F. Pascal. Shrinking the eigenvalues of M-estimators of covariance matrix. IEEE Transactions on Signal Processing 69, 256–269 (2021).
- [115]
- Y. Chen, A. Wiesel and A. O. Hero. Robust shrinkage estimation of high-dimensional covariance matrices. IEEE Transactions on Signal Processing 59, 4097–4107 (2011).
- [116]
- E. Ollila and D. E. Tyler. Regularized M-estimators of scatter matrix. IEEE Transactions on Signal Processing 62, 6059–6070 (2014).
- [117]
- R. Couillet and M. McKay. Large dimensional analysis and optimization of robust shrinkage covariance matrix estimators. Journal of Multivariate Analysis 131, 99–120 (2014).
- [118]
- Y. Sun, P. Babu and D. P. Palomar. Regularized Tyler's scatter estimator: existence, uniqueness, and algorithms. IEEE Transactions on Signal Processing 62, 5143–5156 (2014).