S rho: private API
PortfolioOptimisers.m_scale — Function
m_scale(rho::AbstractSRho, t::VecNum, k::Number, b::Number, s::Number) -> Number
m_scale(rho::RockeRho, t::VecNum, g::Number, b::Number, s::Number) -> NumberReturns the M-scale of the squared distances t, the value $s$ at which the mean of $\rho(t_i / s)$ is b.
The mean of $\rho(t_i / s)$ does not increase with $s$, so the root is unique where the mean is not flat.
The general method does the fixed-point step $s \leftarrow s \, \overline{\rho(t/s)} / b$. The step converges to the scale from any positive start when $\rho(t) / t$ does not increase, as for BisquareRho. It stops when the relative change is at most 4 * eps, or after S_MAX_ITER steps. A start near the scale, such as the scale of the last step of the fit, needs few steps.
The Rocke rho rises steeply in a band of width $2 \gamma$, and $\gamma$ falls as the number of assets grows. The fixed-point step then oscillates: from about 20 assets, it stops at no root. So the method for RockeRho halves or doubles the start until the two ends of an interval hold the root, and bisects that interval.
Arguments
rho: The rho function.t: The squared distance of each observation.k: The tuning constant of the rho function.b: The right side of the equation, sees_tuning.s: The start, a positive number.
Returns
s::Number: The M-scale.
Related
PortfolioOptimisers.chisq_truncated_moment — Function
chisq_truncated_moment(p::Integer, c2::Number, a::AbstractVector{<:Number}) -> NumberReturns the expected value of the polynomial $\sum_k a_k t^k$ over $t \le c^2$, where $t$ has the $\chi^2_p$ distribution.
The rho functions and the weights of BisquareRho are polynomials in $t$ up to $c^2$. So their moments at the normal model follow from the moments of the truncated $\chi^2_p$ distribution, with no numerical integration.
Mathematical definition
\[\begin{align} \mathbb{E}\left[t^k \mathbb{1}\{t \le c^2\}\right] &= F_{\chi^2_{p + 2k}}(c^2) \prod_{j=0}^{k-1} (p + 2j)\,. \end{align}\]
Arguments
p: The number of assets, the degrees of freedom.c2: The bound $c^2$.a: The coefficients of the polynomial, from the power zero up.
Returns
m::Number: The expected value.
Related
PortfolioOptimisers.bisquare_constant — Function
bisquare_constant(bdp::Number, p::Integer) -> NumberReturns the tuning constant $c^2$ of BisquareRho at which the expected rho function at the normal model is the breakdown point bdp.
With this constant, the M-scale of the squared distances of a normal sample about its true location, in the metric of its true scatter, tends to one. So the S estimate of the scatter is consistent at the normal model with no more factor. The expected value comes from chisq_truncated_moment, and it falls from one to zero as $c^2$ rises, so a bisection finds the constant. The interval holds it, because the expected value is at least $P(t > c^2)$ and at most $3p/c^2$.
Mathematical definition
\[\begin{align} \mathbb{E}\left[\rho(t)\right] &= \mathbb{E}\left[\left(3 \frac{t}{c^2} - 3 \frac{t^2}{c^4} + \frac{t^3}{c^6}\right) \mathbb{1}\{t \le c^2\}\right] + 1 - F_{\chi^2_p}(c^2) = \mathrm{bdp}\,. \end{align}\]
Arguments
bdp: The breakdown point.p: The number of assets.
Returns
c2::Number: The tuning constant.
Related