Cokurtosis: private API

PortfolioOptimisers._cokurtosis — Function
_cokurtosis(X::MatNum, mp::AbstractMatrixProcessingEstimator, w::Option{<:ObsWeights}) -> MatNum

Builds the square cokurtosis matrix of a deviation matrix.

_cokurtosis returns the $N^{2} \times N^{2}$ matrix. The matrix processing estimator repairs it in place before the return.

Mathematical definition

The pairwise expansion of the deviation matrix has the rows:

\[\begin{align} \mathbf{Z}_{t,\cdot} &= (\boldsymbol{1}^\intercal \otimes \boldsymbol{y}_t^\intercal) \odot (\boldsymbol{y}_t^\intercal \otimes \boldsymbol{1}^\intercal)\,. \end{align}\]

The $N^{2} \times N^{2}$ square cokurtosis matrix is:

Unweighted:

\[\begin{align} \hat{\mathbf{K}} &= \frac{1}{T} \mathbf{Z}^\intercal \mathbf{Z}\,. \end{align}\]

Weighted:

\[\begin{align} \hat{\mathbf{K}} &= \frac{1}{\sum_{t=1}^{T} w_t} (\boldsymbol{w} \odot \mathbf{Z})^\intercal \mathbf{Z}\,. \end{align}\]

Where:

  • $\hat{\mathbf{K}}$: The $N^{2} \times N^{2}$ square cokurtosis matrix. Its entry $\hat{\mathbf{K}}_{(i-1)N+j,\,(k-1)N+l}$ is the fourth comoment of the deviations of the assets $i$, $j$, $k$ and $l$, so the matrix is symmetric. This is $\mathbf{\Sigma}_{4}$ of Section 2 of [66], which Appendix A of that work computes with the formula above. It is not $\mathbf{M}_{4}$ of Section 2.3 of [64], which is $N \times N^{3}$, and the library never builds $\mathbf{M}_{4}$. The weighted form is an addition of this library.
  • $\mathbf{Y}$: $T \times N$ deviation matrix. FullMoment takes the centred returns, and SemiMoment clips every positive entry of them to zero.
  • $\boldsymbol{y}_t$: $N \times 1$ deviation vector of observation $t$, the $t$-th row of $\mathbf{Y}$. Its $i$-th entry is $y_{t,\,i}$.
  • $\mathbf{Z}$: $T \times N^{2}$ pairwise expansion of $\mathbf{Y}$, whose $t$-th row is $\mathbf{Z}_{t,\cdot}$ and whose entry $\mathbf{Z}_{t,\,(i-1)N+j}$ is the product $y_{t,\,i} \, y_{t,\,j}$.
  • $\boldsymbol{w}$: $T \times 1$ observation weights vector.
  • $w_{t}$: Observation weight of observation $t$.
  • $T$: Number of observations.
  • $N$: Number of assets.
  • $\boldsymbol{1}$: The $N \times 1$ vector of ones.
  • $\otimes$: The Kronecker product.
  • $\odot$: The element-wise product. When the operands differ in shape, it broadcasts along the row axis.

Algorithm

  1. Build o, the $1 \times N$ row of ones.
  2. Build z, the pairwise expansion kron(o, X) ⊙ kron(X, o). Its column (i - 1) * N + j is the element-wise product of the columns i and j of X.
  3. Without weights, form ckurt as transpose(z) * z / T.
  4. With weights, form ckurt as transpose(w .* z) * z / sum(w). The weights multiply the left factor alone, so each summand carries one weight and not four.
  5. Run matrix_processing! on ckurt in place, and return it. With weights, run sample_matrix_processing! with the count of the weights from observation_weight_count, so that the denoising step reads the effective number of observations and not size(X, 1).

Arguments

  • X: The deviation matrix (observations × assets). The caller centres it.
  • mp: The matrix processing estimator.
  • w: The optional observation weights. The unweighted method takes nothing through its args....

Returns

  • ckurt::MatNum: Square cokurtosis matrix assets² x assets². mp processes it in place.

Related

References

  • [66] D. Cajas. Convex Optimization of Portfolio Kurtosis. Available at SSRN 4202967 (2022). Section 2, Equation 4, and Appendix A.
  • [64] E. Jondeau and M. Rockinger. Optimal portfolio allocation under higher moments. Notes d'Études et de Recherche 108, Banque de France (2004). Section 2.3.
source

References

[64]
E. Jondeau and M. Rockinger. Optimal portfolio allocation under higher moments. Notes d'Études et de Recherche 108 (Banque de France, 2004).
[66]
D. Cajas. Convex Optimization of Portfolio Kurtosis. Available at SSRN 4202967 (2022).