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_root takes under the mtx_sqrt of the measure.
  • $\mathbf{S}_2$: Summation matrix, $N(N+1)/2 \times N^2$, which dup_elim_sum_matrices builds. 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 its kt and its S2.
  • mtx_sqrt: Square-root algorithm of the projected matrix, or nothing for the plain Cholesky factor.

Validation

  • The projected matrix has a square root under mtx_sqrt, as matrix_square_root states. Raises a LinearAlgebra.PosDefException.

Returns

  • Gkt::AbstractMatrix: The factor $\mathbf{G}_{kt}$.

Related

source
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_spectrum gives 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

  1. Build A, the block vectorisation of kt, with block_vec_pq.
  2. Decompose the Symmetric view of A with LinearAlgebra.eigen, giving vals in ascending order and vecs.
  3. Clamp each entry of vals at zero.

Arguments

  • kt::MatNum: The cokurtosis matrix, $N^2 \times N^2$.
  • N::Integer: The number of assets.

Validation

  • Both sizes of kt are integer multiples of N. block_vec_pq raises a DomainError otherwise.

Returns

  • (vals, vecs): The clamped eigenvalues in ascending order, and the unit eigenvectors in the columns of vecs.

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).
source
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 its kt, and the number of assets from its mu.

Returns

  • (vals_Akt, vecs_Akt): The clamped eigenvalues, and the unit eigenvectors in the columns of vecs_Akt.

Related

source
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

Expressions

Constraints

  • ckurtosis_rsoc_: under RSOCRiskExpr, $\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 SquaredSOCRiskExpr sq_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$. Under RSOCRiskExpr $t$ lies at or above $\lVert \boldsymbol{x}_{kt} \rVert_2^2$. Both are tight when the objective minimises the risk.
  • Under QuadRiskExpr qd_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 for alg and settings.
  • 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 for SOCRiskExpr and SquaredSOCRiskExpr do 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

Related

source

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).