DetMCD starts: private API
PortfolioOptimisers.detmcd_directions — Function
detmcd_directions(Z::MatNum) -> NTuple{6, Matrix}Returns the eigenvectors of the six robust estimates of the correlation of the standardised data that DetMCD reads.
Section 3.2 of [119] gives the six estimates, and the code of the R package robustbase, version 0.99-7, computes them as this method does.
- The correlation of
tanh.(Z). - The Spearman correlation of
Z, the correlation of the ranks. A tie takes the mean rank. - The correlation of the normal scores of
Z. The score of rank $r$ of $n$ is $\Phi^{-1}((r - 1/3)/(n + 1/3))$. - The spatial sign covariance: the product moment of the rows of
Zdivided by their norms. A row with a norm belowepskeeps its values. - The covariance of the $\lceil n/2 \rceil$ rows of
Zwith the smallest norms, the first step of BACON. - The raw orthogonalised Gnanadesikan–Kettenring scatter of
ogk_scatter.
With fewer observations than assets, an estimate can be singular. The eigenvectors of its zero eigenvalues are then an arbitrary basis, which the linear algebra library chooses. So the method returns the eigenvectors whose eigenvalue is not zero, with regular_directions.
Arguments
Z: The standardised data,observations × assets.
Returns
P::NTuple{6, Matrix}: The eigenvectors of each estimate, one per column.
Related
References
- [119] M. Hubert, P. J. Rousseeuw and T. Verdonck. A deterministic algorithm for robust location and scatter. Journal of Computational and Graphical Statistics 21, 618–637 (2012). Section 3.2.
PortfolioOptimisers.regular_directions — Function
regular_directions(A::MatNum) -> MatrixReturns the eigenvectors of a symmetric matrix whose eigenvalue is larger in absolute value than p * eps times the largest one, where p is the number of rows.
The estimate of ogk_scatter can have a negative eigenvalue. Its eigenvector is a direction of the estimate, so the function keeps it.
Arguments
A: The symmetric matrix.
Returns
P::Matrix: The eigenvectors, one per column. The matrix is square whenAis regular.
Related
PortfolioOptimisers.ogk_scatter — Function
ogk_scatter(Z::MatNum) -> MatrixReturns the raw orthogonalised Gnanadesikan–Kettenring scatter that the sixth start of DetMCD reads. Section 2.2 of [119] states it.
Entry $(i, j)$ off the diagonal is $(Q_n(z_i + z_j)^2 - Q_n(z_i - z_j)^2)/4$, the identity of Gnanadesikan and Kettenring with the robust scale qn_scale. The diagonal is one, because the columns of Z are standardised.
Arguments
Z: The standardised data,observations × assets.
Returns
U::Matrix: The symmetric scatter matrix.
Related
References
- [119] M. Hubert, P. J. Rousseeuw and T. Verdonck. A deterministic algorithm for robust location and scatter. Journal of Computational and Graphical Statistics 21, 618–637 (2012). Sections 2.2 and 3.2.
PortfolioOptimisers.detmcd_initset — Function
detmcd_initset(Z::MatNum, P::MatNum, h::Integer, fixed::Bool) -> Vector{Int}Returns the start subset of DetMCD that one set of directions P gives.
Section 3.1 of [119] states the steps. The eigenvalues of a robust correlation estimate can be far from the truth, so the method takes a robust scale of the data along each direction in place of them.
Algorithm
- Project the data on the directions,
Y = Z * P. Take the robust scale $\lambda_k$ of each column ofYabout its median withrobust_column_scale. - Take the centre as the coordinatewise median of the data in the sphered coordinates $\mathbf{P} \mathrm{Diag}(\lambda)^{-1} \mathbf{P}^\intercal$, mapped back. When
fixedistrue, the centre is zero. - Compute the distance of each observation from the centre in the metric $\mathbf{P} \mathrm{Diag}(\lambda)^2 \mathbf{P}^\intercal$. Add the squared length of the part of the observation that no direction of
Preaches, withoutside_directions. Return thehnearest observations. The first concentration step of the search is the next step of [119].
Arguments
Z: The standardised data.P: The directions, one per column.h: The size of the subset.fixed: Whether the centre is fixed at zero.
Returns
idx::Vector{Int}: The positions of the start subset.
Related
References
- [119] M. Hubert, P. J. Rousseeuw and T. Verdonck. A deterministic algorithm for robust location and scatter. Journal of Computational and Graphical Statistics 21, 618–637 (2012). Section 3.1, Equation 3.
PortfolioOptimisers.outside_directions — Function
outside_directions(Z::MatNum, Y::MatNum, P::MatNum) -> Union{Vector, Number}Returns the squared length of the part of each row of Z that is orthogonal to the columns of P, or zero when P is square.
A singular correlation estimate gives no scale for these directions, so they take the scale one of the standardised data. The result does not depend on a basis of them.
Arguments
Z: The standardised data.Y: The data on the directions,Z * P.P: The directions, one per column.
Returns
q::Union{Vector, Number}: The squared length for each row, or zero.
Related
References
- [119]
- M. Hubert, P. J. Rousseeuw and T. Verdonck. A deterministic algorithm for robust location and scatter. Journal of Computational and Graphical Statistics 21, 618–637 (2012).