Kurtosis Constraints: private API
PortfolioOptimisers.get_chol_or_Gkt_pm — Function
get_chol_or_Gkt_pm(model::Model, pr::HighOrderPrior) -> Any
get_chol_or_Gkt_pm(
model::Model,
pr::HighOrderPrior,
mtx_sqrt::Union{Nothing, AbstractMatrixSquareRootAlgorithm}
) -> Any
Return the factor of the prior's projected cokurtosis matrix, and register it in the model on the first call.
The factor is the transpose of the square root of $\mathbf{S}_2 \mathbf{K} \mathbf{S}_2^\intercal$ under mtx_sqrt, which matrix_square_root takes. Gkt is a shared entry, so every exact Kurtosis of the model that reads the prior's matrix reads one factor, and a later call returns it without a second factorisation. The first measure sets the algorithm. On a positive definite matrix every algorithm gives the Cholesky factor.
JuMP formulation
Expressions
Gkt: $\mathbf{G}_{kt}$, registered on the first call.
Where:
- $\mathbf{G}_{kt}$: Factor of the projected cokurtosis matrix, $N(N+1)/2 \times N(N+1)/2$, with $\mathbf{G}_{kt}^\intercal \mathbf{G}_{kt} = \mathbf{S}_2 \mathbf{K} \mathbf{S}_2^\intercal$. It is the transpose of the square root that
matrix_square_roottakes under themtx_sqrtof the measure. - $\mathbf{S}_2$: Summation matrix, $N(N+1)/2 \times N^2$, which
dup_elim_sum_matricesbuilds. For a symmetric $\mathbf{A}$, $\mathbf{S}_2 \mathrm{vec}(\mathbf{A})$ holds each entry on and below the diagonal of $\mathbf{A}$, times the number of times it occurs in $\mathbf{A}$. - $\mathbf{K}$: The prior's cokurtosis matrix,
pr.kt.
Arguments
model::JuMP.Model: The JuMP optimisation model.pr::HighOrderPrior: The prior result. The function reads itsktand itsS2.mtx_sqrt: Square-root algorithm of the projected matrix, ornothingfor the plain Cholesky factor.
Validation
- The projected matrix has a square root under
mtx_sqrt, asmatrix_square_rootstates. Raises aLinearAlgebra.PosDefException.
Returns
Gkt::AbstractMatrix: The factor $\mathbf{G}_{kt}$.
Related
PortfolioOptimisers.cokurtosis_spectrum — Function
cokurtosis_spectrum(
kt::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
N::Integer
) -> Tuple{Any, Any}
Return the eigenvalues and the eigenvectors of the block vectorisation of the cokurtosis matrix kt, with each eigenvalue clamped at zero.
Row $p + (q - 1) N$ of the block vectorisation holds the vectorisation of block $(p, q)$ of $\mathbf{K}$. An entry of a cokurtosis matrix is a fourth comoment, which does not change when its four indices are permuted. So the block vectorisation of a cokurtosis matrix equals the matrix, and it is symmetric. The function reads it as Symmetric, so the decomposition is real.
Mathematical definition
\[\begin{align} \mathrm{vec}_{N,N}(\mathbf{K}) &= \sum_{i=1}^{N^2} \lambda_i \boldsymbol{q}_i \boldsymbol{q}_i^\intercal\,, \\ \mathbf{K} &= \sum_{i=1}^{N^2} \mathbf{B}_i \otimes \mathbf{B}_i\,, \\ m_4(\boldsymbol{w}) &= \sum_{i=1}^{N^2} \left(\boldsymbol{w}^\intercal \mathbf{B}_i \boldsymbol{w}\right)^2\,. \end{align}\]
Where:
- $\mathrm{vec}_{N,N}(\mathbf{K})$: Block vectorisation of $\mathbf{K}$ in blocks of $N \times N$,
block_vec_pq. - $\lambda_i$, $\boldsymbol{q}_i$: Eigenvalue $i$ and its unit eigenvector.
- $\mathbf{B}_i$: $N \times N$ matrix of eigenpair $i$ of the block vectorisation of $\mathbf{K}$, the reshaped $\sqrt{\lambda_i}\, \boldsymbol{q}_i$.
cokurtosis_spectrumgives the eigenvalue $\lambda_i$, clamped at zero, and the unit eigenvector $\boldsymbol{q}_i$. The index $i$ counts down from the largest eigenvalue. - $\mathbf{K}$: The cokurtosis matrix
kt, $N^2 \times N^2$. - $m_4(\boldsymbol{w}) = (\boldsymbol{w} \otimes \boldsymbol{w})^\intercal \mathbf{K} (\boldsymbol{w} \otimes \boldsymbol{w})$: Fourth central moment of the portfolio returns, with $\otimes$ the Kronecker product.
- $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
The second and third rows hold when no eigenvalue is negative. A cokurtosis matrix is positive semidefinite, so the clamp moves a rounding error only. The rank of $\mathbf{K}$ is at most $N(N+1)/2$, because each column is the vectorisation of a symmetric matrix. So at most $N(N+1)/2$ eigenvalues are not zero.
Algorithm
- Build
A, the block vectorisation ofkt, withblock_vec_pq. - Decompose the
Symmetricview ofAwithLinearAlgebra.eigen, givingvalsin ascending order andvecs. - Clamp each entry of
valsat zero.
Arguments
kt::MatNum: The cokurtosis matrix, $N^2 \times N^2$.N::Integer: The number of assets.
Validation
- Both sizes of
ktare integer multiples ofN.block_vec_pqraises aDomainErrorotherwise.
Returns
(vals, vecs): The clamped eigenvalues in ascending order, and the unit eigenvectors in the columns ofvecs.
Related
References
- [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 7.2.5.2, Equations 7.108 to 7.110. The original source of this formulation was not found. The formulation follows this work and is not checked against the original.
- [195] D. Cajas. Approximation of Portfolio Kurtosis through Sum of Squared Quadratic Forms. Available at SSRN 4472793 (2023).
PortfolioOptimisers.get_kt_Akt_pm — Function
get_kt_Akt_pm(
model::Model,
pr::HighOrderPrior
) -> Tuple{Any, Any}
Return the spectrum of the prior's cokurtosis matrix, and register it in the model on the first call.
cokurtosis_spectrum computes the spectrum. vals_Akt and vecs_Akt are shared entries, so every approximate Kurtosis of the model that reads the prior's matrix reads one decomposition, and a later call returns it without a second decomposition.
JuMP formulation
Expressions
vals_Akt: The clamped eigenvalues in ascending order, registered on the first call.vecs_Akt: The unit eigenvectors, registered on the first call.
Arguments
model::JuMP.Model: The JuMP optimisation model.pr::HighOrderPrior: The prior result. The function reads itskt, and the number of assets from itsmu.
Returns
(vals_Akt, vecs_Akt): The clamped eigenvalues, and the unit eigenvectors in the columns ofvecs_Akt.
Related
PortfolioOptimisers.set_kurtosis_risk! — Function
set_kurtosis_risk!(
model::Model,
r::Kurtosis{<:Any, <:Any, <:Any, <:SOCRiskExpr},
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
sqrt_kurtosis_risk::AbstractJuMPScalar,
,
i;
prefix
) -> AbstractJuMPScalar
Bound the epigraph of the square root of the kurtosis, and add the risk expression of the formulation that r.alg selects.
Both formulations of set_risk_constraints! for Kurtosis end with this call. The bound acts on $g$ under every formulation. Under SOCRiskExpr the risk expression is $g$, in the units of the square root of the fourth moment, and settings.ub is in the same units. Under the other three the risk expression is in the units of the fourth moment, and the bound row reads the square root of settings.ub. set_risk_upper_bound! adds the bound row, and set_risk_expression! adds the risk expression to risk_vec.
JuMP formulation
Variables
kurtosis_risk_: read, $g$.x_kurt_: read underQuadRiskExprandRSOCRiskExpr, $\boldsymbol{x}_{kt}$.tkurtosis_risk_: created underRSOCRiskExpr, the scalar $t$.
Expressions
sq_kurtosis_risk_: $g^2$, underSquaredSOCRiskExpr.qd_kurtosis_risk_: $\lVert \boldsymbol{x}_{kt} \rVert_2^2$, underQuadRiskExpr.
Constraints
ckurtosis_rsoc_: underRSOCRiskExpr, $\left(s_c t,\, s_c / 2,\, s_c \boldsymbol{x}_{kt}\right)$ lies in the rotated second-order cone, which is $t \geq \lVert \boldsymbol{x}_{kt} \rVert_2^2$.
Each name carries the index i of the measure, and the namespace prefix.
Where:
- $g$: Epigraph variable of the square root of the kurtosis, $g \geq \lVert \boldsymbol{x}_{kt} \rVert_{2}$.
- $\boldsymbol{x}_{kt}$: Vector whose squared norm is the kurtosis expression. The exact formulation states $\mathbf{G}_{kt} \mathbf{L}_2 \mathrm{vec}(\mathbf{W})$, and the approximate formulation states entry $j$ as $\mathrm{Tr}(\mathbf{B}_j \mathbf{W})$.
- $t$: Epigraph variable of the squared norm of $\boldsymbol{x}_{kt}$.
- $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.
Relaxation
The encoding is not exact: the entries below bound the quantity instead of reproducing it, and the bound is tight only under the condition stated here.
- Under
SquaredSOCRiskExprsq_kurtosis_risk_lies at or above $\lVert \boldsymbol{x}_{kt} \rVert_2^2$, because $g$ lies at or above $\lVert \boldsymbol{x}_{kt} \rVert_2$. UnderRSOCRiskExpr$t$ lies at or above $\lVert \boldsymbol{x}_{kt} \rVert_2^2$. Both are tight when the objective minimises the risk. - Under
QuadRiskExprqd_kurtosis_risk_is exact in $\boldsymbol{x}_{kt}$, and $g$ serves the bound alone. - A bound on $g$ is exact in $\boldsymbol{x}_{kt}$.
The relation of $\lVert \boldsymbol{x}_{kt} \rVert_2^2$ to the fourth moment of the weights is a property of the formulation, and each method of set_risk_constraints! states it.
Arguments
model::JuMP.Model: The JuMP optimisation model.r::Kurtosis: The measure, read foralgandsettings.opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.sqrt_kurtosis_risk::JuMP.AbstractJuMPScalar: $g$.x_kurt: $\boldsymbol{x}_{kt}$. The methods forSOCRiskExprandSquaredSOCRiskExprdo not read it.i: Constraint index for unique variable and constraint naming.
Keyword arguments
prefix::Symbol: Model State namespace of the build (default: empty, i.e. the bare key).
Returns
risk: The risk expression. It is $g$ underSOCRiskExpr,sq_kurtosis_risk_underSquaredSOCRiskExpr,qd_kurtosis_risk_underQuadRiskExpr, and $t$ underRSOCRiskExpr.
Related
References
- [12]
- D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
- [195]
- D. Cajas. Approximation of Portfolio Kurtosis through Sum of Squared Quadratic Forms. Available at SSRN 4472793 (2023).