Kurtosis
PortfolioOptimisers.Kurtosis — Type
struct Kurtosis{__T_settings, __T_kt, __T_N, __T_alg, __T_mtx_sqrt} <: RiskMeasureMeasures 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.
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.
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
ktwhen 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 matrixassets^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, atfactorytime (seeKtSlotandresolve_deferred_quantities). A cokurtosis estimator suppliesmuas well, from its ownme, so that the tensor and the centre it was taken about come out of one object. Ifnothing, 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, ornothingfor the plain Cholesky factor, which raises aLinearAlgebra.PosDefExceptionon 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_rootstates 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(),) -> KurtosisKeywords correspond to the struct's fields.
Validation
- If
ktis a matrix:!isempty(kt)andsize(kt, 1) == size(kt, 2). - If
Nis notnothing: must be positive.
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 vectorassets × 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.00025455401627159604The 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
RiskMeasureRiskMeasureSettingsHighOrderPriorLowOrderPriorSOCRiskExprQuadSecondMomentFormulationsNegativeSkewnessHighOrderMoment: the fourth moment of the returns, withFourthMoment.EvenMoment: the root of the fourth moment of the returns, atp = 2.resolve_deferred_quantitiesexpected_riskportfolio_fourth_momentset_risk_constraints!: states both models and their relaxations.
References
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
- Resolve a Deferred Quantity in
ktwithresolve_deferred_quantities, givingr. - Select
ktwithnothing_scalar_array_selector. A measure that states a matrix keeps it, and a measure whosektisnothingtakespr.kt. - Rebuild
rwithkt, withrebuild_struct. Thesettings,N,algandmtx_sqrtofrdo not change.
Related
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
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
- Return
runchanged whenktis not a matrix. - Compute
idx, the rows and columns ofktthat belong to the pairs of assets ini, withfourth_moment_index_generator. The number of assets is the square root of the size ofkt. - Rebuild
rwith the view ofktatidx, withrebuild_struct. The other fields ofrdo not change.
Related
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).