Compact Uncertainty Sets: private API

PortfolioOptimisers.orthonormalise_basisFunction
orthonormalise_basis(
    Q::AbstractMatrix{<:Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<:AbstractJuMPScalar}}
) -> Any

Return an orthonormal basis of the column space of Q, dropping the columns a rank-revealing factorisation finds numerically dependent.

Algorithm

  1. Return Q unchanged when it has no column, because a zero-rank basis is already orthonormal and a factorisation of it has no pivot to read.
  2. Take the column-pivoted LinearAlgebra.qr of Q. The magnitudes of the diagonal of its R are non-increasing, so they rank the columns by how much each adds to the span.
  3. Count the pivots above maximum(size(Q)) * eps(real(eltype(Q))) * abs(R[1, 1]), giving r, the numerical rank. The tolerance is the one LinearAlgebra.rank applies to a singular value.
  4. Return the first r columns of the orthogonal factor, materialised as a Matrix.

Arguments

  • Q::MatNum: Basis whose columns span the subspace, not necessarily orthonormal.

Returns

  • Q::MatNum: Orthonormal basis of col(Q), with one column per unit of numerical rank.

Related

source
PortfolioOptimisers.expand_investable_ucsMethod
expand_investable_ucs(
    set::CompactCovarianceUncertaintySet,
    imsk::BitVector,
    pr::AbstractPriorResult
) -> Union{CompactCovarianceUncertaintySet{var"#s185", var"#s1851", <:AbstractMatrix{var"#s137"}, Nothing} where {var"#s185"<:Number, var"#s137"<:(Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<:AbstractJuMPScalar}), var"#s1851"<:AbstractVector{var"#s137"}, var"#s137"<:(Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<:AbstractJuMPScalar})}, CompactCovarianceUncertaintySet{var"#s185", var"#s1851", var"#s1852", <:AbstractMatrix{var"#s137"}} where {var"#s185"<:Number, var"#s137"<:(Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<:AbstractJuMPScalar}), var"#s1851"<:AbstractVector{var"#s137"}, var"#s137"<:(Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<:AbstractJuMPScalar}), var"#s1852"<:AbstractMatrix{var"#s137"}, var"#s137"<:(Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<:AbstractJuMPScalar})}}

Write a CompactCovarianceUncertaintySet fitted on the Investable Mask back onto the full asset universe.

The expansion is the inverse of port_opt_view: a zero row of the basis is dropped by the view without moving the span, and the sliced basis is already orthonormal, so orthonormalise_basis leaves its column space where it is and the view recovers the fitted set. The rows outside the mask carry a zero of C too, so the set states nothing about an asset the prior could not estimate, and the nominal covariance is the full pr.sigma, NaN frame and all, because the set is a neighbourhood of the prior it was calibrated on and that prior lives on the full universe.

Algorithm

  1. Allocate a zero frame of length(imsk) rows and size(set.Q, 2) columns, and write set.Q at the rows the mask keeps, giving Q.
  2. Allocate a zero vector of length(imsk) entries and write set.C at the same rows, giving C.
  3. Build a CompactCovarianceUncertaintySet from the two, carrying kappa through unchanged and pr.sigma as val.

Arguments

  • set: Compact covariance uncertainty set fitted on the reduced prior.
  • imsk: The Investable Mask of the full prior.
  • pr: Prior result.

Returns

  • set::CompactCovarianceUncertaintySet: The set on the full asset universe.

Related

source