Tyler shrinkage: private API
PortfolioOptimisers.observation_weight_vector — Function
observation_weight_vector(X::MatNum, w::Option{<:StatsBase.AbstractWeights}) -> VectorReturns the weight of each observation of X as a vector, a vector of ones when w is nothing.
Arguments
X: The data,observations × assets.w: The observation weights, ornothing.
Returns
wt::Vector: The weight of each observation.
Related
PortfolioOptimisers.ShapeShrinkage — Type
struct ShapeShrinkage{__T_alg, __T_rho}Holds the form and the intensity of the shrinkage of one Tyler shape.
Fields
alg: Form of the fixed point of the shrunk shape, a subtype ofAbstractTylerShrinkageAlgorithm. It states the scale on whichintensityis read.
rho: Shrinkage intensity of the fit, the weight of the target.
Constructors
ShapeShrinkage( alg::AbstractTylerShrinkageAlgorithm, rho::Number) -> ShapeShrinkageRelated
PortfolioOptimisers.tyler_shape — Function
tyler_shape(reg::Option{<:ShapeShrinkage}, W::MatNum,
w::Option{<:StatsBase.AbstractWeights}) -> MatrixReturns the Tyler shape of the centred data W, with the centre fixed at zero.
The rules of the intensity read it.
Arguments
reg: The shrinkage, ornothing.W: The centred data.w: The observation weights, ornothing.
Returns
V::Matrix: The shape.
Related
PortfolioOptimisers.tyler_intensity_bound — Function
tyler_intensity_bound(W::MatNum, w::Option{<:StatsBase.AbstractWeights}) -> NumberReturns the intensity above which the shape of PenalisedShrinkage exists.
In general position a subspace of dimension $r$ holds at most $r$ observations. Theorem 3 of [116] then needs $(1 - \rho) p$ times the largest share of the weight of one observation below one. With equal weights the bound is $1 - n/p$. A negative bound means that the shape exists with no shrinkage. With n == p the bound is zero, and the shape does not exist with no shrinkage.
Arguments
W: The centred data.w: The observation weights, ornothing.
Returns
lo::Number: The bound, below one.
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.
PortfolioOptimisers.assert_tyler_intensity — Function
assert_tyler_intensity(alg::TraceNormalisedShrinkage, rho::Number, lo::Number)
assert_tyler_intensity(alg::PenalisedShrinkage, rho::Number, lo::Number)Refuses a shrinkage intensity at which the shape does not exist.
Arguments
alg: The form of the shrinkage.rho: The intensity.lo: The bound oftyler_intensity_bound.
Validation
TraceNormalisedShrinkage:rho > 0, orlois negative.PenalisedShrinkage:rho > lo.
Otherwise, the function raises a DomainError.
Returns
nothing.
Related
PortfolioOptimisers.smallest_intensity — Function
smallest_intensity(reaches, lo::Number) -> NumberReturns the smallest intensity in (max(lo, 0), 1] at which reaches is true, up to the width $2^{-10}$ of the last interval.
The function bisects the interval ten times. reaches(1) must be true, and the function does not call it there. The returned intensity is an end of an interval at which reaches is true.
Arguments
reaches: A function of the intensity that returns aBool.lo: The lower end of the interval. A negative value stands for zero.
Returns
rho::Number: The intensity.
Related
PortfolioOptimisers.penalised_intensity — Function
penalised_intensity(weight::Number, W::MatNum, w::Option{<:StatsBase.AbstractWeights}) -> NumberReturns the intensity of PenalisedShrinkage at which the target has a given weight in the shape of trace p.
The shape has no fixed trace, so the weight of the target in it is the intensity over the mean of its diagonal.
Arguments
weight: The weight of the target.W: The centred data.w: The observation weights, ornothing.
Returns
rho::Number: The intensity, one whenweightis one or more.
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). Proposition 2.
PortfolioOptimisers.asymptotic_weight — Function
asymptotic_weight(W::MatNum, w::Option{<:StatsBase.AbstractWeights}) -> NumberReturns the weight of the target that AsymptoticIntensity gives to a Tyler shape.
Arguments
W: The centred data, in the coordinates that turn the target into the identity matrix.w: The observation weights, ornothing.
Returns
weight::Number: The weight, positive. It can be above one.
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). Proposition 2.
PortfolioOptimisers.tyler_fit — Function
tyler_fit(shr::Nothing, ve::Option{<:StatsBase.CovarianceEstimator}, X::MatNum,
w::Option{<:StatsBase.AbstractWeights}, centre::Option{<:VecNum}; kwargs...)
tyler_fit(shr::TylerShrinkage, ve::Option{<:StatsBase.CovarianceEstimator}, X::MatNum,
w::Option{<:StatsBase.AbstractWeights}, centre::Option{<:VecNum}; kwargs...)Returns the location, the covariance and the shrinkage intensity of a TylerCovariance.
Algorithm
The nothing method refuses a sample with too few observations with assert_robust_rows, solves the shape and the location with tyler_fixed_point, and scales the shape with tyler_scale. It returns nothing in place of the intensity.
The TylerShrinkage method does these steps:
- Refuse fewer than two observations of positive weight. Take the pilot centre: the coordinatewise weighted median, or
centre. Take the robust scale of each centred column withquantile_scale, and its square as the robust variance. An asset with no robust scale has the variance zero. - Build the pilot covariance from these variances and from the correlations of the
spatial_sign_scatterof the scaled data. Build the target withrobust_target. - Multiply the centred data by the inverse of the symmetric root of the target, so that the target is the identity matrix.
- Find the intensity with
tyler_intensity, and refuse it withassert_tyler_intensitywhen the shape does not exist. - Solve the shape and the location in these coordinates with
tyler_fixed_point, and map both back. - Scale the shape with
tyler_scaleand the robust variances.
Arguments
shr: The shrinkage, ornothing.ve: The variance estimator of the scale, ornothing.X: The data matrix,observations × assets.w: The observation weights, ornothing.centre: The fixed centre, ornothing.kwargs...: More keyword arguments forve.
Returns
(mu, sigma, rho): The location, the covariance, and the intensity.
Related
References
- [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).