Tyler covariance
PortfolioOptimisers.TylerCovariance — Type
struct TylerCovariance{__T_me, __T_ve, __T_shr, __T_w, __T_q, __T_cache} <: AbstractRobustCovarianceEstimatorEstimates the covariance of the returns from the shape matrix of Tyler's M-estimator, which resists heavy tails.
The shape $\mathbf{V}$ of [122] solves a fixed-point equation in which each observation has the weight $p / d^2$, where $d^2$ is its squared distance from the centre in the metric of $\mathbf{V}$. So an observation far from the centre has a small weight, and its direction alone enters the shape. The estimator is distribution-free over the elliptical distributions, and it exists when the data are in general position with $n > p$. It does not exist when a subspace of dimension $r$ through the centre holds a share of the observations of $r/p$ or more, for example when half of the returns of one of two assets are zero. The fixed point then does not converge, and the fit warns. A cluster of outliers at one place can hold such a share when $p$ is large, so this estimator and its shrunk form resist heavy tails and scattered outliers, and MCDCovariance resists a cluster. The equation fixes the shape and not the scale.
No copy of [122] or of [123] was found, so the two equations below follow the code of the R package ICSNP, version 1.2-0.
me = nothinggives the joint location of [123]: the spatial median in the coordinates that the shape makes spherical, solved with the shape. A givenme, or ameankeyword, fixes the centre. That is the classical estimator of [122].ve = nothinggives the scale $\mathbf{\Sigma} = \mathbf{V} \, \mathrm{med}(d^2) / \chi^2_{p, 1/2}$, which is robust and consistent at the normal model. A givenvekeeps the correlation of $\mathbf{V}$ and takes the standard deviations fromstd(ve, X), asGerberCovariancedoes.shrshrinks the shape to a target, seeTylerShrinkage. The estimate is then the shrunk Tyler shape of [115] or of [116], and it exists with fewer observations than assets. Withve = nothing, the scale makes the trace of the covariance the sum of the robust variances of the assets, because the median of the distances is far below the one of the $\chi^2_p$ distribution when $p > n$. The cut-off of the outliers does not assume that distribution, seerobust_outliers.wgives the weighted fixed point $\sum_t w_t \boldsymbol{x}_t \boldsymbol{x}_t^\intercal / d_t^2 \, / \sum_t w_t$, a weighted spatial median and a weighted median for the scale. AStatsBase.FrequencyWeightsgives the fit of the data with each observation repeated by its weight. Another weight type gives the weighted median ofStatsBasefor that type, which interpolates between the observations.
StatsAPI.fit returns the location, the covariance, and the squared distance, the weight and the outlier flag of each observation in a RobustCovarianceResult. The weight is $p / d^2$ in the metric of the covariance, and it does not include the observation weight. An observation at the centre has no direction, so it leaves the fixed point and has the weight zero. With a given ve, the covariance has other distances than the shape, so the weight is not the weight of the fixed point. cov returns the covariance of that fit.
A fixed centre that is not robust moves with the outliers, and a variance estimator that is not robust gives the outliers a large weight in the scale. SimpleExpectedReturns and SimpleVariance are such estimators. Use me = nothing or a MedianExpectedReturns or a RobustExpectedReturns, and ve = nothing.
The estimator has no exact update, so an Online wrapper refits it over the rows of its Sample Buffer, see SampleBufferState.
Mathematical definition
\[\begin{align} \mathbf{V} &= \frac{p}{\sum_t w_t} \sum_{t=1}^{T} w_t \frac{(\boldsymbol{x}_t - \boldsymbol{\mu})(\boldsymbol{x}_t - \boldsymbol{\mu})^\intercal}{d_t^2}\,, \qquad d_t^2 = (\boldsymbol{x}_t - \boldsymbol{\mu})^\intercal \mathbf{V}^{-1} (\boldsymbol{x}_t - \boldsymbol{\mu})\,, \\ \boldsymbol{0} &= \sum_{t=1}^{T} w_t \frac{\boldsymbol{x}_t - \boldsymbol{\mu}}{d_t}\,. \end{align}\]
Where:
- $\mathbf{V}$: The shape matrix, normalised to the trace $p$.
- $\boldsymbol{\mu}$: The location. The second equation holds for the joint location alone.
- $w_t$: The observation weight, one when
wisnothing. - $T$: Number of observations.
Fields
me: Optional expected returns estimator that fixes the centre of the robust fit. Ifnothing, the fit estimates its own robust location.
ve: Optional variance estimator of the standard deviations of the covariance. Ifnothing, the scale of the shape matrix is the median of the squared distances in its metric, divided by the median of the $\chi^2_p$ distribution. The scale of a shrunk shape is then the sum of the robust variances of the assets.
shr: Optional shrinkage of the shape, aTylerShrinkage. Ifnothing, the shape is not shrunk.
w: Optional observation weights vectorobservations × 1, or a concrete subtype ofDynamicAbstractWeights. Ifnothing, the computation is unweighted.
q: Probability of the cut-off of the squared distance above which an observation is an outlier,0 < q < 1. Seerobust_outliers.
cache: Optional partial-fit state. It isnothinguntilpartial_fit!writes one. When the caller gives no data matrix, the batch verb of the estimator reads it. Each propagation channel does one thing with it.factorykeeps it unchanged, because a factory call resolves the configuration, not the sample.port_opt_viewcopies the entries of the selected assets into a new state, so the viewed estimator holds the state of those assets alone.obs_weights_viewremoves it, because a state has no slice on the observation axis. Only a type with an observation-weights field has that channel. A type with no such field falls through to the identity method, so it keeps its state. A family whose state has no exact asset slice removes it on both axes and names the reason.
Constructors
TylerCovariance(; me::Option{<:AbstractExpectedReturnsEstimator} = nothing, ve::Option{<:StatsBase.CovarianceEstimator} = nothing, shr::Option{<:TylerShrinkage} = nothing, w::Option{<:ObsWeights} = nothing, q::Number = 0.975, cache::Option{<:AbstractPartialFitState} = nothing) -> TylerCovarianceKeywords correspond to the struct's fields.
Validation
- If
wis notnothing,!isempty(w). 0 < q < 1.
Propagated parameters
factory passes its arguments on to these @fprop fields:
me: Recursively updated throughfactory.ve: Recursively updated throughfactory.w: Replaced with the incomingObsWeights.cache: Carried unchanged throughfactory.
View parameters
port_opt_view takes the view of these @vprop fields at the selected indices:
me: Recursively viewed throughport_opt_view.ve: Recursively viewed throughport_opt_view.shr: Recursively viewed throughport_opt_view.cache: Sliced to the selected assets throughport_opt_view.
Observation weight parameters
obs_weights_view indexes these fields to the selected observations:
w: Indexed to the selected observations throughobs_weights_view.
Examples
julia> TylerCovariance()TylerCovariance me ┼ nothing ve ┼ nothing shr ┼ nothing w ┼ nothing q ┴ Float64: 0.975Related
AbstractRobustCovarianceEstimatorRobustCovarianceResultMCDCovarianceTylerShrinkageRobustExpectedReturns
References
- [122] D. E. Tyler. A distribution-free M-estimator of multivariate scatter. The Annals of Statistics 15, 234–251 (1987).
- [123] T. P. Hettmansperger and R. H. Randles. A practical affine equivariant multivariate median. Biometrika 89, 851–860 (2002).
- [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.
StatsAPI.fit — Method
StatsAPI.fit(ce::TylerCovariance, X::MatNum; dims::Int = 1, mean = nothing, kwargs...)
-> RobustCovarianceResultFits the location and the covariance of TylerCovariance to the data.
Algorithm
- Orient
Xwithdims_oriented, and refuse a gapped sample withassert_finite_sample. - Resolve the observation weights with
get_observation_weights, and refuse a vector of another length. - Take the fixed centre with
robust_centre, ornothingfor the joint location. - Find the location and the covariance with
tyler_fit. - Compute the squared distance of each observation in the metric of the covariance with
squared_distances. The weight of an observation isp / d2, and zero for an observation thataway_from_centreexcludes. - Flag the outliers with
robust_outliers.
Arguments
ce: The Tyler covariance estimator.X: Data matrixobservations × assetsif thedimskeyword does not exist ordims = 1,assets × observationswhendims = 2.dims: Dimension along which the computation runs.mean: Optional precomputed centre of the data. A given centre fixes the location of the fit.kwargs...: More keyword arguments force.meandce.ve.
Validation
dims in (1, 2).all(isfinite, X).- The observation weights have one entry for each observation.
- With
shr = nothing, more thanpobservations of positive weight. Otherwise, the method raises aDomainErrorthat namesn,pand the limit. - With a
shr, two observations of positive weight or more, and an intensity above the one at which the shape exists, seeassert_tyler_intensity.
Returns
res::RobustCovarianceResult: The fit.
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).
- [116]
- E. Ollila and D. E. Tyler. Regularized M-estimators of scatter matrix. IEEE Transactions on Signal Processing 62, 6059–6070 (2014).
- [122]
- D. E. Tyler. A distribution-free M-estimator of multivariate scatter. The Annals of Statistics 15, 234–251 (1987).
- [123]
- T. P. Hettmansperger and R. H. Randles. A practical affine equivariant multivariate median. Biometrika 89, 851–860 (2002).