Orthogonal Uncertainty Sets: private API
PortfolioOptimisers.orthogonal_factor_span — Function
orthogonal_factor_span(
ue::OrthogonalUncertaintySet,
pr::AbstractPriorResult
) -> Tuple{Any, Any, Any}
Weighted factor span of the prior's loadings block, the geometry both sets are built from.
Algorithm
- Refuse when
pr.rrisnothing. The set reads the loadings off the prior result, and a prior that fitted no factor model carries none. - Read
B, the effective loadingsrr.L. The field reads back asrr.Mwhen no Factor Family was re-based, and a re-based model is already reduced to a full-rank basis. - Count
nnf, the rows ofBthat hold an entry that is not finite, and refuse when it is not zero. A singular value decomposition of such a row gives a LAPACK error, not a span. TheNaNrows that a point-in-time Asset Panel writes outside the Investable Mask never reach this step, because the optimiser's builders pass the prior reduced to that mask, and the standalone verbs reduce to it first throughinvestable_ucs_reduction. A non-finite row here therefore belongs to an asset that the prior calls investable, whosemuand variance are finite and whose loadings are not, and the message says so. - Read
w, the cross-sectional weights, throughorthogonality_weights, and takew_sqrt, their element-wise square root, or keepnothing. - Scale the rows of
Bbyw_sqrt, givingBw. - Take
F, the thinLinearAlgebra.svdofBw, with the singular valuess. - Count
r, the singular values abovemaximum(size(Bw)) * eps * s[1]. The tolerance reads the larger dimension, so it is wider than the default ofLinearAlgebra.rank, which reads the smaller one. - Return
rr,w_sqrtand the firstrleft singular vectors ofF.
Step 7 counts the rank after the re-basis that step 2 reads, because the selected universe can still leave the exposures numerically dependent, and a dependent direction that survives widens the span that the penalty spares.
Arguments
ue: Orthogonal uncertainty set estimator.pr: Prior result the optimisation is solving on.
Validation
!isnothing(pr.rr), else anIsNothingErrornaming the field and the estimator that returned no block.all(isfinite, rr.L), else anIsNonFiniteErrorcounting the assets whose loadings are not finite. Every such asset is inside the Investable Mask ofpr, because the verbs that call this fit reduce to the mask first.
Returns
rr::AbstractLoadingsRegressionResult: The loadings block the span came from.w_sqrt::Option{<:VecNum}: Element-wise square root of the metric, ornothingon anothingmetric.Q::MatNum: Orthonormal basis of the weighted factor span, $N \times r_{\mathbf{B}}$.
Related
PortfolioOptimisers.orthogonal_mu_set — Function
orthogonal_mu_set(
ue::OrthogonalUncertaintySet,
pr::AbstractPriorResult,
rr::AbstractLoadingsRegressionResult,
w_sqrt::Union{Nothing, AbstractVector{<:Union{Number, AbstractJuMPScalar}}},
Q::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}}
) -> Union{NormBallUncertaintySet{var"#s185", <:AbstractMatrix{var"#s166"}, Int64, MuUncertaintySetClass, Nothing} where {var"#s185"<:Number, var"#s166"<:Union{Number, AbstractJuMPScalar}}, NormBallUncertaintySet{var"#s185", var"#s1851", Int64, MuUncertaintySetClass, <:AbstractArray{var"#s166", N}} where {var"#s185"<:Number, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1851"<:AbstractMatrix{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}, N}}
Builds the mean NormBallUncertaintySet on the Orthogonal Subspace, from a span already taken.
Algorithm
- Form
P, the orthogonal projectorI - Q * Q'. - Form
A, the rows ofPdivided byw_sqrt, orPitself whenw_sqrtisnothing.Ais the projector read back in the asset coordinates. - Take
E, the symmetric eigendecomposition ofA' * A. - Select
keep, the indices of the trailingN - size(Q, 2)eigenvectors ofE. The count is exact:Qis orthonormal, soPhas rankN - size(Q, 2), the metric scaling is an invertible diagonal, andLinearAlgebra.eigenon aSymmetricorders the eigenvalues from small to large. An eigenvalue tolerance can sit so close to the eigenvalue it must cut that the cut changes with the reduction order of the machine and states a subspace one dimension too wide. Step 7 oforthogonal_factor_spanstill reads a tolerance, because the rank of the loadings is a property of the data and not of a projector. - Orthonormalise
Atimes the selected eigenvectors with a reducedLinearAlgebra.qr, givingG, and readr, the dimension of the Orthogonal Subspace, as its column count. An emptykeepgives aGwith no column. - When
ris0, return the set with a radius of zero, a map of one zero column, andpr.muas its centre. The zero radius leaves the nominal mean. - Take
lambda, the scaling, throughorthogonal_scaling. - Form
L, the product ofGand the square root oflambdathatmatrix_square_roottakes underue.mtx_sqrt. The set of order2reads onlyL * L', which isG * lambda * G'for every algorithm. An indefinitelambdaraises aLinearAlgebra.PosDefException, because a loadings block that a caller builds by hand can give one. - Size the radius with
k_norm_ballatrdegrees of freedom, and return the set of order2withpr.muas its centre. A set fitted on one prior and passed to another optimisation therefore carries the centre that its geometry was calibrated on.
Arguments
ue: Orthogonal uncertainty set estimator.pr: Prior result the span came from.rr: Loadings block the span came from.w_sqrt: Element-wise square root of the metric, ornothing.Q: Orthonormal basis of the weighted factor span.
Returns
ucs::NormBallUncertaintySet: Mean set on the Orthogonal Subspace, of order2.
Related
PortfolioOptimisers.orthogonal_sigma_set — Function
orthogonal_sigma_set(
ue::OrthogonalUncertaintySet,
pr::AbstractPriorResult,
rr::AbstractLoadingsRegressionResult,
w_sqrt::Union{Nothing, AbstractVector{<:Union{Number, AbstractJuMPScalar}}},
Q::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}}
) -> Union{CompactCovarianceUncertaintySet{var"#s185", var"#s1851", var"#s1852", <:AbstractMatrix{var"#s166"}, Nothing} where {var"#s185"<:Number, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1851"<:AbstractVector{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1852"<:AbstractMatrix{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}}, CompactCovarianceUncertaintySet{var"#s185", var"#s1851", var"#s1852", var"#s1853", <:AbstractMatrix{var"#s166"}} where {var"#s185"<:Number, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1851"<:AbstractVector{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1852"<:AbstractMatrix{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1853"<:AbstractMatrix{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}}}
orthogonal_sigma_set(
ue::OrthogonalUncertaintySet,
pr::AbstractPriorResult,
rr::AbstractLoadingsRegressionResult,
w_sqrt::Union{Nothing, AbstractVector{<:Union{Number, AbstractJuMPScalar}}},
Q::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
rd
) -> Union{CompactCovarianceUncertaintySet{var"#s185", var"#s1851", var"#s1852", <:AbstractMatrix{var"#s166"}, Nothing} where {var"#s185"<:Number, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1851"<:AbstractVector{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1852"<:AbstractMatrix{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}}, CompactCovarianceUncertaintySet{var"#s185", var"#s1851", var"#s1852", var"#s1853", <:AbstractMatrix{var"#s166"}} where {var"#s185"<:Number, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1851"<:AbstractVector{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1852"<:AbstractMatrix{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s1853"<:AbstractMatrix{var"#s166"}, var"#s166"<:Union{Number, AbstractJuMPScalar}}}
Builds the covariance CompactCovarianceUncertaintySet on the Orthogonal Subspace, from a span already taken.
Algorithm
- Form
C, the diagonal metric square root, as the element-wise inverse ofw_sqrt, or as a vector of ones whenw_sqrtisnothing. - Settle
kappa, the radius, withk_compact. A stated number passes through unchanged. A rule ofAbstractCompactRadiusAlgorithmreceives the confidence level, the metric, the prior result, the loadings block,C,Qandrd. - Return the set with
Qas the basis it spares andpr.sigmaas the nominal covariance. A span of rank zero gives a basis with no column, which the type admits, and the penalty then reaches every direction.
The set penalises the complement of the span, the same subspace that the mean set lives in, so one decomposition serves both axes and the estimator computes it once.
Arguments
ue: Orthogonal uncertainty set estimator.pr: Prior result the span came from.rr: Loadings block the span came from.w_sqrt: Element-wise square root of the metric, ornothing.Q: Orthonormal basis of the weighted factor span.rd: Returns data the set was fitted beside, ornothing. Only aVarianceFractionholding an optimiser reads it.
Returns
ucs::CompactCovarianceUncertaintySet: Covariance set that spares the weighted factor span.
Related