Compact Uncertainty Sets
PortfolioOptimisers.CompactCovarianceUncertaintySet — Type
struct CompactCovarianceUncertaintySet{__T_kappa, __T_C, __T_Q, __T_R, __T_val} <: AbstractUncertaintySetResultHolds a worst-case variance penalty as a radius, a diagonal metric square root and a basis of the directions that the penalty spares.
The set adds variance on every direction outside the span of its basis, and it adds none inside the span. So a portfolio in the span pays no penalty. The consumer adds one quadratic term and one free variable for each column of the basis. It does not add the dense $N \times N$ matrix of the same worst case, so the model holds no lifted semidefinite block and stays a second-order cone programme. This is the reason for the name compact.
A fitted set has a basis with orthonormal columns over its $N$ rows, and no row in R. A row slice of the basis does not have orthonormal columns. So port_opt_view keeps the slice, and puts a factor of the rows that it drops into R. The view then keeps the penalty of the full set exactly.
The set is a construction of this library. OrthogonalUncertaintySet fits it, and cites the works that it extends.
Mathematical definition
\[\begin{align} \underset{\mathbf{\Sigma} \in U^{\text{cpt}}_{\mathbf{\Sigma}}}{\max} \boldsymbol{w}^{\intercal} \mathbf{\Sigma} \boldsymbol{w} &= \boldsymbol{w}^{\intercal} \hat{\mathbf{\Sigma}} \boldsymbol{w} + \kappa \underset{\boldsymbol{z}}{\min} \left( \lVert \mathbf{C} \boldsymbol{w} - \mathbf{Q} \boldsymbol{z} \rVert_{2}^{2} + \lVert \mathbf{R} \boldsymbol{z} \rVert_{2}^{2} \right) \\ U^{\text{cpt}}_{\mathbf{\Sigma}} &= \left\{ \mathbf{\Sigma} \succeq 0 \, \vert \, \mathbf{\Sigma} \preceq \hat{\mathbf{\Sigma}} + \kappa \mathbf{C}^{\intercal} (\mathbf{I} - \mathbf{Q}\mathbf{Q}^{\intercal}) \mathbf{C} \right\}\,. \end{align}\]
Where:
- $U^{\text{cpt}}_{\mathbf{\Sigma}}$: Compact uncertainty set for the covariance matrix.
- $\mathbf{\Sigma}$: Uncertain covariance.
- $\hat{\mathbf{\Sigma}}$: Estimated covariance matrix.
- $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
- $\kappa \geq 0$: Radius of the compact covariance set, the multiplier of its penalty.
- $\mathbf{C}$: Diagonal metric square root of the covariance set.
- $\mathbf{Q}$: Basis of the subspace that the penalty spares, $N \times r$.
- $\mathbf{R}$: Factor of the rows of the basis that a view dropped, $m \times r$, with $m = 0$ on a fitted set. The stacked matrix $[\mathbf{Q}; \mathbf{R}]$ has orthonormal columns, so $\mathbf{R}^{\intercal}\mathbf{R} = \mathbf{I} - \mathbf{Q}^{\intercal}\mathbf{Q}$.
- $\boldsymbol{z}$: Coefficient vector of the inner problem, $r \times 1$.
The two lines state one worst case. The inner problem is a least-squares problem over the columns of $[\mathbf{Q}; \mathbf{R}]$, with the target $[\mathbf{C}\boldsymbol{w}; \mathbf{0}]$. These columns are orthonormal, so the value of the inner problem is $\boldsymbol{w}^{\intercal}\mathbf{C}^{\intercal} (\mathbf{I} - \mathbf{Q}\mathbf{Q}^{\intercal}) \mathbf{C}\boldsymbol{w}$. Because $\mathbf{Q}^{\intercal}\mathbf{Q} \preceq \mathbf{I}$, the matrix $\mathbf{I} - \mathbf{Q}\mathbf{Q}^{\intercal}$ is positive semidefinite. So the bound on the second line is a member of the set, and it gives the maximum on the first line.
On a fitted set, $\mathbf{R}$ has no row and $\mathbf{I} - \mathbf{Q}\mathbf{Q}^{\intercal}$ is a projector. The value is then $\lVert (\mathbf{I} - \mathbf{Q}\mathbf{Q}^{\intercal})\mathbf{C}\boldsymbol{w} \rVert_{2}^{2}$. The inner problem has a value for every $\mathbf{Q}$ and $\mathbf{R}$, but it agrees with the closed form only when the stacked columns are orthonormal. A weight vector with $\mathbf{C}\boldsymbol{w} = \mathbf{Q}\boldsymbol{z}$ and $\mathbf{R}\boldsymbol{z} = \mathbf{0}$ pays no penalty. When $r = 0$, the penalty is $\kappa \lVert \mathbf{C}\boldsymbol{w} \rVert_{2}^{2}$.
Fields
kappa: Radius $\kappa \geq 0$, the multiplier of the quadratic penalty. A radius of0removes the penalty and leaves the nominal variance. A set is a Result, so the radius is always a number. When thekappaof anOrthogonalUncertaintySetholds anAbstractCompactRadiusAlgorithm, the estimator resolves it to a number before it builds the set.
C: Diagonal of the metric square root $\mathbf{C}$, a vector of length $N$. The set holds the diagonal and not the matrix.
Q: Basis $\mathbf{Q}$ of the subspace that the penalty spares, $N \times r$. On a fitted set the columns are orthonormal. A rank of0is permitted, and the penalty is then $\kappa \lVert \mathbf{C}\boldsymbol{w} \rVert_{2}^{2}$.
R: Factor $\mathbf{R}$ of the rows of the basis that a view dropped, $m \times r$, with $\mathbf{R}^{\intercal}\mathbf{R} = \mathbf{I} - \mathbf{Q}^{\intercal}\mathbf{Q}$. A fitted set has no row here. A view fills it. Then the penalty of the view on a portfolio is the penalty of the full set on the same portfolio, with zero weight outside the view.
val: Quantity that the set is a neighbourhood of. It is a vector on the mean axis and a covariance matrix on the covariance axis.nothinglets the consumer use its own quantity. A value has priority over the field of the returns estimator and over the prior.
Constructors
CompactCovarianceUncertaintySet(; kappa::Number, C::VecNum, Q::MatNum, R::MatNum = zeros(eltype(Q), 0, size(Q, 2)), val::Option{<:MatNum} = nothing) -> CompactCovarianceUncertaintySetKeywords correspond to the struct's fields.
Validation
!(kappa isa Bool), else anArgumentError.isfinite(kappa)andkappa >= 0.!isempty(C),all(isfinite, C)andall(x -> x >= 0, C).all(isfinite, Q).size(Q, 1) == length(C).all(isfinite, R)andsize(R, 2) == size(Q, 2).- If
valis provided:size(val, 1) == size(val, 2) == length(C).
Examples
julia> CompactCovarianceUncertaintySet(; kappa = 2.0, C = [1.0, 1.0], Q = reshape([1.0, 0.0], 2, 1))CompactCovarianceUncertaintySet kappa ┼ Float64: 2.0 C ┼ Vector{Float64}: [1.0, 1.0] Q ┼ 2×1 Matrix{Float64} R ┼ 0×1 Matrix{Float64} val ┴ nothingRelated
PortfolioOptimisers.port_opt_view — Method
port_opt_view(
risk_ucs::CompactCovarianceUncertaintySet,
i,
args...
) -> 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}}}
Return a view of a CompactCovarianceUncertaintySet restricted to the asset indices i, as the projection of the set onto the selected assets and not as a refit.
A portfolio of the selected assets is a portfolio of the full universe with zero weight on the other assets. Its worst-case variance under the set is $\boldsymbol{w}_{i}^{\intercal} \hat{\mathbf{\Sigma}}_{ii} \boldsymbol{w}_{i} + \kappa \boldsymbol{w}_{i}^{\intercal} \mathbf{C}_{i} (\mathbf{I} - \mathbf{Q}_{i}\mathbf{Q}_{i}^{\intercal}) \mathbf{C}_{i} \boldsymbol{w}_{i}$. The view states that value. So the worst case of a cluster portfolio does not depend on whether the caller views the set first.
The sliced rows $\mathbf{Q}_{i}$ do not have orthonormal columns, because $\mathbf{Q}_{i}^{\intercal}\mathbf{Q}_{i} = \mathbf{I} - \mathbf{Q}_{-i}^{\intercal}\mathbf{Q}_{-i}$. The view keeps them, and puts a triangular factor of the dropped rows $\mathbf{Q}_{-i}$ into R. Then $[\mathbf{Q}_{i}; \mathbf{R}]$ has orthonormal columns, and the inner problem of the set gives the value above.
A slice with new orthonormal columns gives $\mathbf{C}_{i} (\mathbf{I} - \mathbf{P}_{i}) \mathbf{C}_{i}$ instead, where $\mathbf{P}_{i}$ is the projector onto $\operatorname{col}(\mathbf{Q}_{i})$. That is the set of a fit on the selected assets alone, and it spares portfolios that the full set does not spare. A caller who wants that set fits the estimator on the viewed prior.
The radius passes through unchanged. The projection of a set keeps its radius, so the radius stays exact. A set is a Result, so it holds the radius as a number and holds no rule to run again.
Algorithm
- Mark the rows of the basis that
idrops and that are not zero. A zero row adds nothing to the Gram matrix. The rows outside an Investable Mask are zero, so the view at the mask of a set thatexpand_investable_ucswrote recovers the fitted set exactly. - Stack the marked rows of
risk_ucs.Qonrisk_ucs.R, the factor of the rows that an earlier view dropped. When no row is marked, keeprisk_ucs.RasR. Otherwise take the triangular factor of theLinearAlgebra.qrof the stack asR. The Gram matrix ofRis the Gram matrix of the stack, so a view of a view stays exact. - Take
view(risk_ucs.C, i)andview(risk_ucs.Q, i, :), the diagonal of the metric square root and the rows of the basis at the selected assets. - Take
nothing_scalar_array_view(risk_ucs.val, i), the nominal covariance restricted to the same assets on both axes. Anothingpasses through unchanged. - Build a
CompactCovarianceUncertaintySetfrom the four, withkappaunchanged.
Arguments
risk_ucs: Compact covariance uncertainty set.i: Indices of the assets that the view keeps.args...: Additional positional arguments (ignored).
Returns
risk_ucs::CompactCovarianceUncertaintySet: The set restricted toi.
Related
PortfolioOptimisers.mu_ucs — Method
mu_ucs(uc::CompactCovarianceUncertaintySet, args...; kwargs...)Always throw. CompactCovarianceUncertaintySet is a set for the covariance only.
The method refuses and runs no procedure, so it has no # Algorithm section. It replaces the passthrough method that every other Result reaches. That method gives the set to the consumer of the mean, which cannot read a covariance set.
Arguments
uc: Compact covariance uncertainty set.args...: Additional positional arguments (ignored).kwargs...: Additional keyword arguments (ignored).
Validation
- The method always throws an
ArgumentError. The set bounds a covariance matrix through a quadratic penalty on the weights, and the library defines no mean analogue for it. The message names the sets to use for the mean,BoxUncertaintySet,EllipsoidalUncertaintySetandL1UncertaintySet.
Returns
- Never returns.
Related