Tyler covariance

PortfolioOptimisers.TylerCovariance — Type
struct TylerCovariance{__T_me, __T_ve, __T_shr, __T_w, __T_q, __T_cache} <: AbstractRobustCovarianceEstimator

Estimates 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 = nothing gives the joint location of [123]: the spatial median in the coordinates that the shape makes spherical, solved with the shape. A given me, or a mean keyword, fixes the centre. That is the classical estimator of [122].
  • ve = nothing gives 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 given ve keeps the correlation of $\mathbf{V}$ and takes the standard deviations from std(ve, X), as GerberCovariance does.
  • shr shrinks the shape to a target, see TylerShrinkage. The estimate is then the shrunk Tyler shape of [115] or of [116], and it exists with fewer observations than assets. With ve = 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, see robust_outliers.
  • w gives 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. A StatsBase.FrequencyWeights gives the fit of the data with each observation repeated by its weight. Another weight type gives the weighted median of StatsBase for 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.

Warning

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 w is nothing.
  • $T$: Number of observations.

Fields

  • me: Optional expected returns estimator that fixes the centre of the robust fit. If nothing, the fit estimates its own robust location.
  • ve: Optional variance estimator of the standard deviations of the covariance. If nothing, 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, a TylerShrinkage. If nothing, the shape is not shrunk.
  • w: Optional observation weights vector observations × 1, or a concrete subtype of DynamicAbstractWeights. If nothing, the computation is unweighted.
  • q: Probability of the cut-off of the squared distance above which an observation is an outlier, 0 < q < 1. See robust_outliers.
  • cache: Optional partial-fit state. It is nothing until partial_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. factory keeps it unchanged, because a factory call resolves the configuration, not the sample. port_opt_view copies the entries of the selected assets into a new state, so the viewed estimator holds the state of those assets alone. obs_weights_view removes 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) -> TylerCovariance

Keywords correspond to the struct's fields.

Validation

  • If w is not nothing, !isempty(w).
  • 0 < q < 1.

Propagated parameters

factory passes its arguments on to these @fprop fields:

  • me: Recursively updated through factory.
  • ve: Recursively updated through factory.
  • w: Replaced with the incoming ObsWeights.
  • cache: Carried unchanged through factory.

View parameters

port_opt_view takes the view of these @vprop fields at the selected indices:

Observation weight parameters

obs_weights_view indexes these fields to the selected observations:

Examples

julia> TylerCovariance()TylerCovariance   me ┼ nothing   ve ┼ nothing  shr ┼ nothing    w ┼ nothing    q ┴ Float64: 0.975

Related

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.
source
StatsAPI.fit — Method
StatsAPI.fit(ce::TylerCovariance, X::MatNum; dims::Int = 1, mean = nothing, kwargs...)
    -> RobustCovarianceResult

Fits the location and the covariance of TylerCovariance to the data.

Algorithm

  1. Orient X with dims_oriented, and refuse a gapped sample with assert_finite_sample.
  2. Resolve the observation weights with get_observation_weights, and refuse a vector of another length.
  3. Take the fixed centre with robust_centre, or nothing for the joint location.
  4. Find the location and the covariance with tyler_fit.
  5. Compute the squared distance of each observation in the metric of the covariance with squared_distances. The weight of an observation is p / d2, and zero for an observation that away_from_centre excludes.
  6. Flag the outliers with robust_outliers.

Arguments

  • ce: The Tyler covariance estimator.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 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 for ce.me and ce.ve.

Validation

  • dims in (1, 2).
  • all(isfinite, X).
  • The observation weights have one entry for each observation.
  • With shr = nothing, more than p observations of positive weight. Otherwise, the method raises a DomainError that names n, p and the limit.
  • With a shr, two observations of positive weight or more, and an intensity above the one at which the shape exists, see assert_tyler_intensity.

Returns

  • res::RobustCovarianceResult: The fit.

Related

source

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).