Compact Uncertainty Sets: private API
PortfolioOptimisers.orthonormalise_basis — Function
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
- Return
Qunchanged when it has no column, because a zero-rank basis is already orthonormal and a factorisation of it has no pivot to read. - Take the column-pivoted
LinearAlgebra.qrofQ. The magnitudes of the diagonal of itsRare non-increasing, so they rank the columns by how much each adds to the span. - Count the pivots above
maximum(size(Q)) * eps(real(eltype(Q))) * abs(R[1, 1]), givingr, the numerical rank. The tolerance is the oneLinearAlgebra.rankapplies to a singular value. - Return the first
rcolumns of the orthogonal factor, materialised as aMatrix.
Arguments
Q::MatNum: Basis whose columns span the subspace, not necessarily orthonormal.
Returns
Q::MatNum: Orthonormal basis ofcol(Q), with one column per unit of numerical rank.
Related
PortfolioOptimisers.expand_investable_ucs — Method
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
- Allocate a zero frame of
length(imsk)rows andsize(set.Q, 2)columns, and writeset.Qat the rows the mask keeps, givingQ. - Allocate a zero vector of
length(imsk)entries and writeset.Cat the same rows, givingC. - Build a
CompactCovarianceUncertaintySetfrom the two, carryingkappathrough unchanged andpr.sigmaasval.
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