Kurtosis

PortfolioOptimisers.Kurtosis — Type
struct Kurtosis{__T_settings, __T_kt, __T_N, __T_alg, __T_mtx_sqrt} <: RiskMeasure

Measures the fourth central moment of the portfolio returns, or its square root, from the cokurtosis matrix kt.

The moment is the quadratic form of $\boldsymbol{w} \otimes \boldsymbol{w}$ in $\mathbf{K}$. It is not divided by the square of the variance, so it is not the kurtosis coefficient, and it is not an excess kurtosis. alg selects the quantity that the measure reports: SOCRiskExpr reports $\sqrt{m_4}$, and each of the QuadSecondMomentFormulations reports $m_4$. The functor and the model read the same matrix, so expected_risk gives the value that a bound of the measure holds.

set_risk_constraints! states the model, and neither model is exact. When N is nothing, the model is problem 13 of [66], which replaces $\boldsymbol{w} \boldsymbol{w}^\intercal$ with a lifted matrix and drops the condition that the lift has rank one. When N is an integer, the model is the sum of squared quadratic forms of [195], and a larger N is more accurate and more expensive. The library calls the first model the exact formulation and the second the approximate formulation, because only the second truncates the cokurtosis. The ## Relaxation of each method states the gap.

Warning

With an integer N, the model bounds the approximate moment of cokurtosis_spectrum, which lies at or below the moment of the matrix. The functor reads the whole matrix, so it reports the full moment, and the value at the solved weights can lie above the bound of the model.

Info

The matrix states the moment, so the centre, the observation weights and the tail of the moment belong to the estimator that makes the matrix. A semi-moment needs a lower semi-cokurtosis, such as kt = Cokurtosis(; alg = SemiMoment()), and a weighted moment needs a weighted cokurtosis, such as kt = Cokurtosis(; w = w). A lower semi-cokurtosis gives the heuristic of Section 3.1 of [66]. It clips the deviations of each asset, not the deviations of the portfolio, so its moment is not the semi-moment of the portfolio returns. The measures that compute a fourth moment from the returns are HighOrderMoment with FourthMoment, which gives $m_4$, and LowOrderMoment with EvenMoment at p = 2, which gives $\sqrt{m_4}$. Each takes observation weights, a Moment Target and a SemiMoment of its own.

Mathematical definition

\[\begin{align} \mathrm{Kurt}(\boldsymbol{w}) &= \begin{cases} \sqrt{m_4(\boldsymbol{w})} & \text{under } \texttt{SOCRiskExpr}\,, \\ m_4(\boldsymbol{w}) & \text{under } \texttt{QuadRiskExpr}\,,\ \texttt{SquaredSOCRiskExpr}\,,\ \texttt{RSOCRiskExpr}\,. \end{cases} \end{align}\]

Where:

  • $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.
  • $\mathbf{K}$: Cokurtosis matrix of the risk measure, $N^2 \times N^2$. It is the measure's own kt when the measure states one, and the prior's otherwise.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.

$m_4$ is the observation mean of the fourth power of the centred portfolio returns when $\mathbf{K}$ is the sample cokurtosis about the per-asset centres. That is Equation 4 of [66].

Fields

  • settings: Risk measure settings.
  • kt: Optional cokurtosis matrix assets^2 × assets^2. Also admits a Deferred Quantity — a cokurtosis estimator or a prior estimator that computes the matrix against the optimisation's own prior, at factory time (see KtSlot and resolve_deferred_quantities). A cokurtosis estimator supplies mu as well, from its own me, so that the tensor and the centre it was taken about come out of one object. If nothing, the prior supplies it.
  • N: Optional number of eigenvalues per asset for the approximate cokurtosis formulation.
  • alg: Risk measure optimisation formulation algorithm.
  • mtx_sqrt: Square-root algorithm of the projected co-kurtosis matrix $\mathbf{S}_2 \mathbf{K} \mathbf{S}_2^\intercal$ that the exact formulation reads, or nothing for the plain Cholesky factor, which raises a LinearAlgebra.PosDefException on a matrix that is not positive definite. A sample co-kurtosis of $T$ observations has rank at most $T$, so the projected matrix is singular when $N(N+1)/2 > T$ and no matrix processing repairs it. The default takes the square root of the eigendecomposition of such a matrix. matrix_square_root states each algorithm. The approximate formulation reads no square root.

Constructors

Kurtosis(;    settings::RiskMeasureSettings = RiskMeasureSettings(),    kt::Option{<:KtSlot} = nothing,    N::Option{<:Integer} = nothing,    alg::SecondMomentFormulation = SOCRiskExpr(),    mtx_sqrt::Option{<:AbstractMatrixSquareRootAlgorithm} = EigenFallbackSquareRoot(),) -> Kurtosis

Keywords correspond to the struct's fields.

Validation

  • If kt is a matrix: !isempty(kt) and size(kt, 1) == size(kt, 2).
  • If N is not nothing: must be positive.
Info

kt also admits a CokurtosisEstimator or an AbstractPriorEstimator, which resolve_deferred_quantities resolves against the prior of the optimisation. The measure carries one deferrable slot, so it takes no pe.

Functor

(r::Kurtosis)(w::VecNum)

Computes $\sqrt{m_4(\boldsymbol{w})}$ or $m_4(\boldsymbol{w})$ from the matrix r.kt, with portfolio_fourth_moment. The functor reads kt as it stands, so a measure whose kt is nothing or a Deferred Quantity needs factory with a HighOrderPrior result first.

Arguments

  • w: Portfolio weights vector assets × 1.

Examples

julia> Kurtosis()Kurtosis  settings ┼ RiskMeasureSettings           │   scale ┼ Float64: 1.0           │      ub ┼ nothing           │     rke ┴ Bool: true        kt ┼ nothing         N ┼ nothing       alg ┼ SOCRiskExpr()  mtx_sqrt ┴ EigenFallbackSquareRoot()julia> X = [0.02 -0.01; -0.01 0.03; 0.03 -0.02; -0.04 0.01; 0.01 0.02];julia> w = [0.6, 0.4];julia> Kurtosis(; kt = cokurtosis(Cokurtosis(), X))(w)0.00025455401627160726julia> LowOrderMoment(; alg = EvenMoment())(w, X)0.00025455401627159604

The sample cokurtosis about the mean of each asset gives the root of the fourth moment of the portfolio returns about their mean, so the two values agree.

Related

References

  • [66] D. Cajas. Convex Optimization of Portfolio Kurtosis. Available at SSRN 4202967 (2022). Section 2, Equation 4, and Section 3.1, Problem 13.
  • [195] D. Cajas. Approximation of Portfolio Kurtosis through Sum of Squared Quadratic Forms. Available at SSRN 4472793 (2023).
source
PortfolioOptimisers.factory — Method
factory(
    r::Kurtosis,
    pr::HighOrderPrior,
    args...;
    kwargs...
) -> Kurtosis{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, _A, _B, <:SecondMomentFormulation} where {__T_scale, __T_ub, __T_rke, _A, _B}

Create an instance of Kurtosis that holds its cokurtosis matrix, from the measure or from the HighOrderPrior result pr.

Algorithm

  1. Resolve a Deferred Quantity in kt with resolve_deferred_quantities, giving r.
  2. Select kt with nothing_scalar_array_selector. A measure that states a matrix keeps it, and a measure whose kt is nothing takes pr.kt.
  3. Rebuild r with kt, with rebuild_struct. The settings, N, alg and mtx_sqrt of r do not change.

Related

source
PortfolioOptimisers.factory — Method
factory(
    r::Kurtosis,
    pr::LowOrderPrior,
    args...;
    kwargs...
) -> Kurtosis

Resolve a Deferred Quantity in the kt slot of Kurtosis r against a LowOrderPrior result, and otherwise return r unchanged.

A LowOrderPrior holds no cokurtosis matrix, so the method has no matrix to take from pr. A cokurtosis estimator in kt needs only the returns of the result, so it resolves here too. The functor and the model need a matrix. A value-level entry point refuses a measure whose kt is nothing, and so does set_risk_constraints!.

Related

source
PortfolioOptimisers.port_opt_view — Method
port_opt_view(r::Kurtosis, i, args...) -> Kurtosis

Return a view of Kurtosis r sliced to asset indices i.

The view of a stated matrix agrees with the cokurtosis that a refit on the assets i gives. A Deferred Quantity and nothing pass through unsliced, and a Deferred Quantity resolves on the subset.

Algorithm

  1. Return r unchanged when kt is not a matrix.
  2. Compute idx, the rows and columns of kt that belong to the pairs of assets in i, with fourth_moment_index_generator. The number of assets is the square root of the size of kt.
  3. Rebuild r with the view of kt at idx, with rebuild_struct. The other fields of r do not change.

Related

source

References

[66]
D. Cajas. Convex Optimization of Portfolio Kurtosis. Available at SSRN 4202967 (2022).
[195]
D. Cajas. Approximation of Portfolio Kurtosis through Sum of Squared Quadratic Forms. Available at SSRN 4472793 (2023).