S rho
PortfolioOptimisers.AbstractSRho — Type
abstract type AbstractSRho <: AbstractAlgorithmAbstract supertype for the rho functions of an S estimator of location and scatter.
An S estimator of [124] finds the location and the scatter of determinant one whose distances have the smallest M-scale. The rho function gives the M-scale, see m_scale. It is bounded, so an observation far from the centre adds a fixed amount to the equation of the scale, and it cannot move the estimate much. The weight of an observation in the fit is the derivative of the rho function, see srho_weight. BisquareRho and RockeRho are its subtypes.
Each method reads the squared distance $t = d^2 / s$ of an observation, where $s$ is the M-scale of the squared distances.
Interfaces
To implement a new rho function, subtype AbstractSRho, keep each parameter in a field, implement the first three methods, and implement the fourth when the M-scale is not consistent at the normal model:
PortfolioOptimisers.s_tuning(rho, bdp::Number, n::Integer, p::Integer) -> Tuple{Number, Number}: Returns the tuning constantkof the rho function and the right sidebof the equation of the M-scale, for the breakdown pointbdpofnobservations ofpassets.PortfolioOptimisers.srho(rho, t::Number, k::Number) -> Number: Returns the rho function at the squared distancet, a number from zero to one.PortfolioOptimisers.srho_weight(rho, t::Number, k::Number) -> Number: Returns the weight of an observation at the squared distancet, a number from zero to one.PortfolioOptimisers.s_consistency(rho, d2::VecNum, p::Integer) -> Number: Returns the factor that makes the covariance consistent at the normal model, from the squared distancesd2in the metric of the scale times the shape. The fallback returns one, the factor of a rho whose tuning constant makes the M-scale consistent.
Related
References
- [124] P. L. Davies. Asymptotic behaviour of S-estimates of multivariate location parameters and dispersion matrices. The Annals of Statistics 15, 1269–1292 (1987). Not read. See
SCovariance.
PortfolioOptimisers.BisquareRho — Type
struct BisquareRho <: AbstractSRhoThe bisquare rho function of Tukey, the rho function of the S estimator of SCovariance.
The function rises from zero at the centre to one at the squared distance $c^2$, and stays at one beyond it. So an observation beyond $c^2$ has the weight zero. The constant $c^2$ makes the M-scale consistent at the normal model for the breakdown point bdp, see bisquare_constant. It is $3.4529^2$ for three assets at bdp = 0.5, the value of the R package rrcov, version 1.7-7.
Mathematical definition
\[\begin{align} \rho(t) &= \begin{cases} 1 - \left(1 - t / c^2\right)^3 & t \le c^2\,, \\ 1 & t > c^2\,, \end{cases} & w(t) &= \begin{cases} \left(1 - t / c^2\right)^2 & t \le c^2\,, \\ 0 & t > c^2\,. \end{cases} \end{align}\]
Where:
- $t$: The squared distance of an observation, divided by the M-scale.
- $c^2$: The tuning constant.
- $w$: The weight of the observation, the derivative of $\rho$ divided by its value at the centre.
Examples
julia> BisquareRho()BisquareRho()Related
References
- [125] R. A. Maronna, R. D. Martin, V. J. Yohai and M. Salibián-Barrera. Robust Statistics: Theory and Methods (with R). Second edition. Wiley (2019). Not read. The tuning constants agree with the R package
rrcov, version 1.7-7.
PortfolioOptimisers.RockeRho — Type
struct RockeRho{__T_arp} <: AbstractSRhoThe rho function of Rocke, a translated bisquare whose weights fall on both sides of the typical distance.
With many assets, the squared distances of a normal sample are near their mean $p$, and few observations are near the centre. The bisquare rho of a high breakdown point then gives a low efficiency, or rejects too few outliers. The rho of [126] is zero below $1 - \gamma$ and one above $1 + \gamma$, where $t = d^2/s$ is centred at one. Its width $\gamma$ comes from the asymptotic rejection probability arp, the share of the observations of a normal sample that get the weight zero. The right side of the M-scale is $\mathrm{bdp} \, (1 - p/n)$, see s_tuning. The parity with rrcov below holds at the default bdp = 0.5, and another bdp has no reference value. The M-scale is the root of a monotone equation, which m_scale brackets and bisects. The scale is not consistent at the normal model, so the fit multiplies the covariance by the median of the squared distances over the median of the $\chi^2_p$ distribution, see s_consistency.
The R package rrcov, version 1.7-7, with method = "rocke", gives the same estimate where its iterations reach the minimum. On five of six parity samples, the two agree to 1e-3, and the M-scale of this fit is the smaller one. On the sixth, 40 observations of 6 assets, rrcov stops at a local minimum whose M-scale is 1.7 % larger than the one that DetS finds.
Mathematical definition
\[\begin{align} \rho(t) &= \begin{cases} 0 & t < 1 - \gamma\,, \\ \frac{1}{2} + \frac{t - 1}{4 \gamma} \left(3 - \left(\frac{t - 1}{\gamma}\right)^2\right) & \lvert t - 1 \rvert \le \gamma\,, \\ 1 & t > 1 + \gamma\,, \end{cases} & w(t) &= \begin{cases} 1 - \left(\frac{t - 1}{\gamma}\right)^2 & \lvert t - 1 \rvert \le \gamma\,, \\ 0 & \text{otherwise}\,, \end{cases} \\ \gamma &= \min\left(\frac{\chi^2_{p, 1 - \mathrm{arp}}}{p} - 1, 1\right)\,. \end{align}\]
Where:
- $t$: The squared distance of an observation, divided by the M-scale.
- $w$: The weight of the observation, the derivative of $\rho$ divided by its largest value.
- $\chi^2_{p, 1 - \mathrm{arp}}$: The quantile $1 - \mathrm{arp}$ of the $\chi^2_p$ distribution.
Fields
arp: Asymptotic rejection probability of the Rocke rho, the share of the observations of a normal sample that get the weight zero,0 < arp < 1.
Constructors
RockeRho(; arp::Number = 0.1) -> RockeRhoKeywords correspond to the struct's fields.
Validation
0 < arp < 1.- At the fit,
arp < 1 - cdf(Chisq(p), p), so that the width is positive, sees_tuning.
Examples
julia> RockeRho()RockeRho arp ┴ Float64: 0.1Related
References
- [126] D. M. Rocke. Robustness properties of S-estimators of multivariate location and shape in high dimension. The Annals of Statistics 24, 1327–1345 (1996). Not read. The width, the right side and the consistency factor agree with the R package
rrcov, version 1.7-7. - [125] R. A. Maronna, R. D. Martin, V. J. Yohai and M. Salibián-Barrera. Robust Statistics: Theory and Methods (with R). Second edition. Wiley (2019). Not read.
PortfolioOptimisers.s_tuning — Function
s_tuning(rho::BisquareRho, bdp::Number, n::Integer, p::Integer) -> Tuple{Number, Number}
s_tuning(rho::RockeRho, bdp::Number, n::Integer, p::Integer) -> Tuple{Number, Number}Returns the tuning constant of the rho function and the right side of the equation of the M-scale.
The bisquare rho takes the constant $c^2$ of bisquare_constant, and the right side is bdp. Neither depends on the number of observations. The Rocke rho takes the width $\gamma$ of RockeRho, and the right side $\mathrm{bdp} \, (1 - p/n)$. At bdp = 1/2 that is the right side of the largest breakdown point that $n$ observations of $p$ assets permit.
The width $\gamma$ is positive only when arp is below $1 - F_{\chi^2_p}(p)$, which is about 0.32 at $p = 1$ and rises towards one half as $p$ grows. Otherwise, the method raises a DomainError, because every observation would get the weight zero.
Arguments
rho: The rho function.bdp: The breakdown point.n: The number of observations.p: The number of assets.
Returns
(k, b): The tuning constant and the right side.
Related
PortfolioOptimisers.srho — Function
srho(rho::BisquareRho, t::Number, c2::Number) -> Number
srho(rho::RockeRho, t::Number, g::Number) -> NumberReturns the rho function at the squared distance t, see BisquareRho and RockeRho.
Arguments
rho: The rho function.t: The squared distance, divided by the M-scale.c2,g: The tuning constant $c^2$ of the bisquare rho, or the width $\gamma$ of the Rocke rho.
Returns
r::Number: The value, from zero to one.
Related
PortfolioOptimisers.srho_weight — Function
srho_weight(rho::BisquareRho, t::Number, c2::Number) -> Number
srho_weight(rho::RockeRho, t::Number, g::Number) -> NumberReturns the weight of an observation at the squared distance t, see BisquareRho and RockeRho.
Arguments
rho: The rho function.t: The squared distance, divided by the M-scale.c2,g: The tuning constant $c^2$ of the bisquare rho, or the width $\gamma$ of the Rocke rho.
Returns
w::Number: The weight, from zero to one. The bisquare weight is one at the centre and zero beyond $c^2$. The Rocke weight is one at $t = 1$ and zero outside $1 \pm \gamma$.
Related
PortfolioOptimisers.s_consistency — Function
s_consistency(rho::AbstractSRho, d2::VecNum, p::Integer) -> Number
s_consistency(rho::RockeRho, d2::VecNum, p::Integer) -> NumberReturns the factor that makes the covariance of an S fit consistent at the normal model.
The fallback returns one. It is the factor of a rho whose tuning constant already makes the M-scale consistent, such as BisquareRho, and of a rho of a user that defines no method. The Rocke rho is centred at the typical distance, so its factor is the median of the squared distances over the median of the $\chi^2_p$ distribution, as for TylerCovariance.
Arguments
rho: The rho function.d2: The squared distance of each observation, in the metric of the scale times the shape.p: The number of assets.
Returns
f::Number: The factor of the covariance.
Related
PortfolioOptimisers.AbstractEfficiencyTarget — Type
abstract type AbstractEfficiencyTarget <: AbstractAlgorithmAbstract supertype for the parts of an M-estimate whose efficiency at the normal model tunes the constant of BisquareReweighting.
The bisquare M-step has one constant, so it fixes the efficiency of one part. ShapeEfficiency and LocationEfficiency are its subtypes. At one constant, the efficiency of the location is the higher of the two, so the constant of the shape at 95 % is the larger one.
Interfaces
To implement a new target, subtype AbstractEfficiencyTarget, and implement one method:
PortfolioOptimisers.bisquare_efficiency(target, p::Integer, c2::Number) -> Number: Returns the asymptotic efficiency of that part of a bisquare M-estimate with the constantc2, forpassets. It rises withc2.
Related
PortfolioOptimisers.ShapeEfficiency — Type
struct ShapeEfficiency <: AbstractEfficiencyTargetTunes the bisquare M-step to the efficiency of the shape, the default of BisquareReweighting and of CovMMest of the R package rrcov, version 1.7-7. A covariance is a shape and a scale, and the scale of an MM estimate comes from its S estimate, so this target sets the efficiency of the covariance.
Examples
julia> ShapeEfficiency()ShapeEfficiency()Related
PortfolioOptimisers.LocationEfficiency — Type
struct LocationEfficiency <: AbstractEfficiencyTargetTunes the bisquare M-step to the efficiency of the location, as CovMMest of the R package rrcov, version 1.7-7, does with eff.shape = FALSE. The constant is smaller than the one of ShapeEfficiency at the same efficiency, so the step rejects outliers sooner and the shape has a lower efficiency.
Examples
julia> LocationEfficiency()LocationEfficiency()Related
PortfolioOptimisers.bisquare_efficiency — Function
bisquare_efficiency(target::ShapeEfficiency, p::Integer, c2::Number) -> Number
bisquare_efficiency(target::LocationEfficiency, p::Integer, c2::Number) -> NumberReturns the asymptotic efficiency of a part of a bisquare M-estimate of location and scatter at the normal model, relative to the sample mean and the sample covariance.
[127] states the asymptotic variance $\sigma_1$ of the shape and the asymptotic variance $\sigma_\mu$ of the location of an M-estimator. The formulas below write them for the bisquare function in the squared distance $t$. The efficiency is $1 / \sigma_1$ or $1 / \sigma_\mu$. It rises from zero to one as $c^2$ rises. At 95 % and three assets, the constant of the shape is $6.0963^2$ and the one of the location is $5.4902^2$, the values of the R package rrcov, version 1.7-7. For one asset, the constant of the location is $4.685^2$, the classical constant of the bisquare M-estimator of location.
Mathematical definition
\[\begin{align} \sigma_1 &= \frac{p (p + 2) \, \mathbb{E}\left[t^2 (1 - t/c^2)^4 \mathbb{1}\{t \le c^2\}\right]}{\mathbb{E}\left[t (1 - t/c^2) \left((p + 2) - (p + 6) t / c^2\right) \mathbb{1}\{t \le c^2\}\right]^2}\,, \\ \sigma_\mu &= \frac{\mathbb{E}\left[t (1 - t/c^2)^4 \mathbb{1}\{t \le c^2\}\right] / p}{\mathbb{E}\left[\left(1 - (2 + 4/p) t / c^2 + (1 + 4/p) t^2 / c^4\right) \mathbb{1}\{t \le c^2\}\right]^2}\,. \end{align}\]
Where:
- $t$: A variable of the $\chi^2_p$ distribution.
Arguments
target: The part of the estimate.p: The number of assets.c2: The tuning constant $c^2$.
Returns
eff::Number: The efficiency, from zero to one.
Related
References
- [127] M. Salibián-Barrera, S. Van Aelst and G. Willems. Principal components analysis based on multivariate MM estimators with fast and robust bootstrap. Journal of the American Statistical Association 101, 1198–1211 (2006). Not read. The formulas agree with the R package
rrcov, version 1.7-7.
References
- [124]
- P. L. Davies. Asymptotic behaviour of S-estimates of multivariate location parameters and dispersion matrices. The Annals of Statistics 15, 1269–1292 (1987).
- [125]
- R. A. Maronna, R. D. Martin, V. J. Yohai and M. Salibián-Barrera. Robust Statistics: Theory and Methods (with R). Second Edition (Wiley, 2019).
- [126]
- D. M. Rocke. Robustness properties of S-estimators of multivariate location and shape in high dimension. The Annals of Statistics 24, 1327–1345 (1996).
- [127]
- M. Salibián-Barrera, S. Van Aelst and G. Willems. Principal components analysis based on multivariate MM estimators with fast and robust bootstrap. Journal of the American Statistical Association 101, 1198–1211 (2006).