Compact Radius Rules

PortfolioOptimisers.ResidualInflation — Type
struct ResidualInflation{__T_q, __T_dof} <: AbstractCompactRadiusAlgorithm

Sizes the compact radius from a chi-squared upper confidence bound on each idiosyncratic variance.

The compact set adds no variance on the directions that the factors span. On the other directions it adds variance in proportion to $\mathbf{D}$, the idiosyncratic variances of the loadings block, and this rule sizes that addition from the estimation error of $\mathbf{D}$. Under the default InverseIdiosyncraticVarianceMetric the radius has no units. Under metric = nothing it has the units of a variance. One formula serves every AbstractOrthogonalityMetric and nothing, so no method dispatches on the metric.

The rule reads the sampling law of each variance off the block, because only the fit knows it. The edof field of the block is the degrees of freedom of each variance, and its ediv field is the divisor. FactorPrior, FactorBlackLittermanPrior and a Cross-Sectional Factor Prior write both beside esigma, per asset, so a stepwise fit that keeps a different number of factors for each asset is priced per asset. A block that records no degrees of freedom is refused unless dof states them. That is a block built by hand, a block from a regression estimator that records no count, or a block whose variance estimator states no count through variance_count. VarianceFraction assumes no sampling law, so it serves such a block.

The level 1 - q is exact for Gaussian residuals whose variance is an unweighted sum of squares. Under observation weights, and under the exponentially weighted variance that a Cross-Sectional Factor Prior uses by default, the counts are Kish's, and the level is an approximation.

The q of the owning OrthogonalUncertaintySet also sizes its mean set. Under the default ChiSqKUncertaintyAlgorithm the mean set inverts a chi-squared distribution at the dimension of the Orthogonal Subspace and reads no sample size, while this rule inverts one at the degrees of freedom of each variance. A smaller q makes both radii larger, so q = nothing reads the owner's q and one level sets both.

Mathematical definition

\[\begin{align} \rho_{i} &= \max\left(\dfrac{m_{i}}{\chi^{2,\,-1}_{\nu_{i}}(q)} - 1,\, 0\right)\,, \\ \kappa &= \left\lVert \mathbf{R}^{1/2}\mathbf{D}^{1/2}\mathbf{W}^{1/2}\mathbf{P} \right\rVert_{2}^{2}\,, \\ \mathbf{P} &= \mathbf{I} - \mathbf{Q}\mathbf{Q}^{\intercal}\,. \end{align}\]

Where:

  • $\rho_{i}$: Relative inflation of asset $i$, the excess of the variance bound over the estimate, as a fraction of the estimate.
  • $\mathbf{R}$: Diagonal matrix of the relative inflations $\rho_{i}$.
  • $\kappa \geq 0$: Radius of the compact covariance set, the multiplier of its penalty.
  • $\nu_{i}$: Degrees of freedom of the idiosyncratic variance of asset $i$, the edof of the block, or dof when the rule states it.
  • $m_{i}$: Divisor of the idiosyncratic variance of asset $i$, the ediv of the block, or $\nu_{i}$ when the block records none.
  • $\chi^{2,\,-1}_{\nu}(q)$: Lower $q$ quantile of the chi-squared distribution with $\nu$ degrees of freedom.
  • $q$: Confidence level of the bound, which holds with probability $1 - q$.
  • $\mathbf{D}$: Diagonal matrix of the idiosyncratic variances of the loadings block.
  • $\mathbf{W}$: Diagonal cross-sectional metric, the identity under metric = nothing.
  • $\mathbf{P}$: Orthogonal projector onto the complement of the weighted factor span.
  • $\mathbf{Q}$: Orthonormal basis of the weighted factor span.
  • $\mathbf{C}$: Diagonal metric square root of the covariance set.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.

Let $\hat{d}_{i}$ be the estimated idiosyncratic variance of asset $i$ and $d_{i}$ its true value. The estimate is a sum of squares divided by $m_{i}$, and $m_{i} \hat{d}_{i} / d_{i}$ follows the chi-squared distribution with $\nu_{i}$ degrees of freedom. Then $d_{i} \leq (1 + \rho_{i})\hat{d}_{i}$ with probability $1 - q$, and $\rho_{i}$ is the smallest inflation with that property. The default variance estimator of FactorPrior divides by $T - 1$, while a time-series fit over $K$ factors leaves $T - K - 1$ degrees of freedom. So $m_{i} > \nu_{i}$, and the inflation is larger than the one that $m_{i} = \nu_{i}$ gives. The floor at zero applies only when a stated dof exceeds the recorded divisor by more than the quantile allows, where no inflation is needed.

When $m_{i} = \nu_{i}$ and $\nu_{i}$ is large, $\rho_{i} \approx z_{1-q} \sqrt{2 / \nu_{i}}$, where $z_{1-q}$ is the $1 - q$ quantile of the standard normal distribution. So the radius falls like the inverse square root of the sample size.

For a portfolio $\boldsymbol{w}$, let $\boldsymbol{v} = \mathbf{P}\mathbf{C}\boldsymbol{w}$. The penalty of the set is $\kappa \lVert \boldsymbol{v} \rVert_{2}^{2}$. Because $\mathbf{C} = \mathbf{W}^{-1/2}$, the inflation of the idiosyncratic variance of $\mathbf{C}^{-1}\boldsymbol{v}$, the part of $\boldsymbol{w}$ that the span does not cover, is $\lVert \mathbf{R}^{1/2}\mathbf{D}^{1/2}\mathbf{W}^{1/2}\boldsymbol{v} \rVert_{2}^{2}$. The $\kappa$ of the definition is the smallest radius whose penalty covers that inflation for every $\boldsymbol{v}$ in the range of $\mathbf{P}$.

Under $\mathbf{W} = \mathbf{D}^{-1}$ the norm is $\lVert \mathbf{R}^{1/2}\mathbf{P} \rVert_{2}^{2}$, which is at most the largest $\rho_{i}$, and equals $\rho$ when every asset has the same inflation $\rho$ and $\mathbf{P} \neq \mathbf{0}$. When the factors span the whole cross-section, $\mathbf{P} = \mathbf{0}$ and $\kappa = 0$, which is also the radius of the mean set for the same span.

Algorithm

The branch of k_compact that this rule selects runs these steps.

  1. Read N, the number of assets, as the row count of Q.
  2. Read d, the idiosyncratic variances of the block, with idiosyncratic_variances.
  3. Settle nu, the degrees of freedom, as alg.dof for every asset when the rule states it, and as the edof of the block otherwise. Refuse a block that records none when the rule states none.
  4. Settle m, the divisors, as the ediv of the block, or as nu when the block records none.
  5. Refuse an entry of nu that is not finite and positive, with a DomainError that names the asset.
  6. Settle qe as alg.q, or as the owner's q when the rule states none.
  7. Form rho, the relative inflation of each asset at qe, floored at zero.
  8. Form P, the projector $\mathbf{P}$.
  9. Scale row i of P by sqrt(rho[i] * d[i]) / C[i], the diagonal entry of $\mathbf{R}^{1/2}\mathbf{D}^{1/2}\mathbf{W}^{1/2}$.
  10. Return the squared operator norm of the scaled matrix.

Fields

  • q: Confidence level of the variance bound (0 < q < 1), or nothing to read the q of the owning estimator. The bound holds with probability 1 - q, so a smaller q gives a larger radius.
  • dof: Degrees of freedom of every idiosyncratic variance, or nothing to read the edof that the fit recorded on the block. A stated count serves every asset, and the divisor is still read off the block when the block records one.

Constructors

ResidualInflation(;    q::Option{<:Number} = nothing,    dof::Option{<:Number} = nothing) -> ResidualInflation

Keywords correspond to the struct's fields. Both default to nothing, so a bare call reads the confidence level of the owner and the degrees of freedom that the fit recorded on the block.

Validation

  • If q is not nothing: 0 < q < 1.
  • If dof is not nothing: isfinite(dof) and dof > 0.

Examples

julia> ResidualInflation()ResidualInflation    q ┼ nothing  dof ┴ nothing
julia> ResidualInflation(; q = 0.01, dof = 240)ResidualInflation    q ┼ Float64: 0.01  dof ┴ Int64: 240

Related

source
PortfolioOptimisers.VarianceFraction — Type
struct VarianceFraction{__T_f, __T_w0} <: AbstractCompactRadiusAlgorithm

Sizes the compact radius so that the penalty at a reference portfolio equals a stated fraction of its nominal variance.

The units of a radius change with the metric, so a bare number is hard to choose. With this rule, f = 0.1 sets a penalty equal to ten percent of the nominal variance of the reference portfolio. The rule assumes no sampling law, so it applies when the degrees of freedom of the idiosyncratic variances are not known.

No guard refuses a reference portfolio inside the factor span. When the penalty of w0 is exactly zero, the radius is not finite and the constructor of CompactCovarianceUncertaintySet refuses it. When round-off leaves a small penalty, the radius is finite and very large, and no threshold separates it from a valid large radius. State a w0 outside the span, or use ResidualInflation, which reads no portfolio.

Mathematical definition

\[\begin{align} \kappa &= f \, \dfrac{\boldsymbol{w}_{0}^{\intercal}\hat{\mathbf{\Sigma}}\boldsymbol{w}_{0}}{\left\lVert \left(\mathbf{I} - \mathbf{Q}\mathbf{Q}^{\intercal}\right)\mathbf{C}\boldsymbol{w}_{0} \right\rVert_{2}^{2}}\,. \end{align}\]

Where:

  • $\kappa \geq 0$: Radius of the compact covariance set, the multiplier of its penalty.
  • $f$: Fraction of the nominal variance that the penalty equals at $\boldsymbol{w}_{0}$.
  • $\boldsymbol{w}_{0}$: Reference portfolio, the equal-weight portfolio when w0 is nothing.
  • $\hat{\mathbf{\Sigma}}$: Estimated covariance matrix.
  • $\mathbf{C}$: Diagonal metric square root of the covariance set.
  • $\mathbf{Q}$: Orthonormal basis of the weighted factor span.
  • $N$: Number of assets.

The denominator is the penalty of $\boldsymbol{w}_{0}$ at $\kappa = 1$. So at the radius $\kappa$ the penalty of $\boldsymbol{w}_{0}$ is $f$ times its nominal variance.

When $\mathbf{C}\boldsymbol{w}_{0}$ is in the column space of $\mathbf{Q}$, the denominator is zero. If $\mathbf{Q}$ has fewer than $N$ columns, other portfolios still pay a penalty, and $\kappa$ is infinite. If $\mathbf{Q}$ has $N$ columns, the penalty is zero on every portfolio and no radius changes the set.

Algorithm

The branch of k_compact that this rule selects runs these steps.

  1. Read N, the number of assets, as the row count of Q.
  2. When Q has N columns, return zero. The span then covers the cross-section and the quotient is $0/0$. The test compares the column count with the row count and has no tolerance, because the columns of Q are orthonormal.
  3. Read w0, the reference portfolio, with compact_reference_weights.
  4. Form Cw, the element-wise product of C and w0.
  5. Return f times the variance of w0 under pr.sigma, divided by the squared norm of Cw less its projection onto the columns of Q.

Fields

  • f: Fraction of the nominal variance that the penalty equals at the reference portfolio, > 0.
  • w0: Reference portfolio at which the fraction is measured. nothing reads the equal-weight portfolio, a vector is the portfolio itself, and an optimiser runs on the returns data of the fit.

Constructors

VarianceFraction(;    f::Number = 0.1,    w0::Union{Nothing, VecNum, NonFiniteAllocationOptimisationEstimator} = nothing) -> VarianceFraction

Keywords correspond to the struct's fields. Both have defaults, so a bare call sets the penalty at a tenth of the nominal variance of the equal-weight portfolio.

Validation

  • isfinite(f) and f > 0.
  • If w0 is a vector: !isempty(w0).

Examples

julia> VarianceFraction()VarianceFraction   f ┼ Float64: 0.1  w0 ┴ nothing
julia> VarianceFraction(; f = 0.25, w0 = [0.5, 0.3, 0.2])VarianceFraction   f ┼ Float64: 0.25  w0 ┴ Vector{Float64}: [0.5, 0.3, 0.2]

Related

source
PortfolioOptimisers.k_compact — Function
k_compact(alg::ResidualInflation, q::Number, metric::Option{<:AbstractOrthogonalityMetric},
          pr::AbstractPriorResult, rr::AbstractLoadingsRegressionResult, C::VecNum,
          Q::MatNum, rd)
k_compact(alg::VarianceFraction, q::Number, metric::Option{<:AbstractOrthogonalityMetric},
          pr::AbstractPriorResult, rr::AbstractLoadingsRegressionResult, C::VecNum,
          Q::MatNum, rd)
k_compact(kappa::Number, args...)

Radius of a CompactCovarianceUncertaintySet, from the prior result and the geometry of the set.

Algorithm

  1. On a Number, return it unchanged. Every caller that states a radius reaches this method.
  2. On a ResidualInflation, run the steps that its docstring lists.
  3. On a VarianceFraction, run the steps that its docstring lists.

Arguments

  • alg: Rule, or the radius itself.
  • q: Confidence level of the owning estimator, read when the rule states none.
  • metric: Cross-sectional metric of the span. It reaches the rules through C, its inverse square root, so no method dispatches on it.
  • pr: Prior result of the fit.
  • rr: Loadings block of the span.
  • C: Diagonal metric square root of the covariance set, $\mathbf{W}^{-1/2}$.
  • Q: Orthonormal basis of the weighted factor span.
  • rd: Returns data of the fit, or nothing.

Validation

Returns

Related

source