High Order Prior

PortfolioOptimisers.HighOrderPriorEstimatorType
struct HighOrderPriorEstimator{__T_pe, __T_kte, __T_ske} <: AbstractHighOrderPriorEstimator

High order prior estimator for asset returns.

HighOrderPriorEstimator is a composite estimator that computes high order moments (coskewness and cokurtosis) for asset returns, in addition to low order moments (mean and covariance). It combines a low order prior estimator, a cokurtosis estimator, and a coskewness estimator to produce a HighOrderPrior result containing all relevant moments for advanced portfolio analytics.

Fields

  • pe: Prior estimator.
  • kte: Cokurtosis estimator.
  • ske: Coskewness estimator.

Constructors

HighOrderPriorEstimator(;    pe::Onl{<:AbstractLowOrderPriorEstimator_A_F_AF} = EmpiricalPrior(),    kte::Option{<:CokurtosisEstimator} = Cokurtosis(;        alg = FullMoment()    ),    ske::Option{<:CoskewnessEstimator} = Coskewness(;        alg = FullMoment()    )) -> HighOrderPriorEstimator

Keywords correspond to the struct's fields.

Propagated parameters

When factory is called on this type, the following @fprop-tagged fields are automatically propagated:

  • pe: Recursively updated via factory.
  • kte: Recursively updated via factory.
  • ske: Recursively updated via factory.

View parameters

When port_opt_view is called on this type, the following @vprop-tagged fields are automatically subset to the selected indices:

Examples

julia> HighOrderPriorEstimator()HighOrderPriorEstimator   pe ┼ EmpiricalPrior      │           ce ┼ PortfolioOptimisersCovariance      │              │   ce ┼ Covariance      │              │      │    me ┼ SimpleExpectedReturns      │              │      │       │   w ┴ nothing      │              │      │    ce ┼ GeneralCovariance      │              │      │       │   ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)      │              │      │       │    w ┴ nothing      │              │      │   alg ┼ FullMoment()      │              │      │     w ┴ nothing      │              │   mp ┼ MatrixProcessing      │              │      │     pdm ┼ Posdef      │              │      │         │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton      │              │      │         │   kwargs ┴ @NamedTuple{}: NamedTuple()      │              │      │      dn ┼ nothing      │              │      │      dt ┼ nothing      │              │      │     alg ┼ nothing      │              │      │   order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)      │           me ┼ SimpleExpectedReturns      │              │   w ┴ nothing      │      horizon ┼ nothing      │   fill_limit ┴ nothing  kte ┼ Cokurtosis      │      me ┼ SimpleExpectedReturns      │         │   w ┴ nothing      │      mp ┼ MatrixProcessing      │         │     pdm ┼ Posdef      │         │         │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton      │         │         │   kwargs ┴ @NamedTuple{}: NamedTuple()      │         │      dn ┼ nothing      │         │      dt ┼ nothing      │         │     alg ┼ nothing      │         │   order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)      │     alg ┼ FullMoment()      │       w ┼ nothing      │   cache ┴ nothing  ske ┼ Coskewness      │      me ┼ SimpleExpectedReturns      │         │   w ┴ nothing      │      mp ┼ MatrixProcessing      │         │     pdm ┼ Posdef      │         │         │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton      │         │         │   kwargs ┴ @NamedTuple{}: NamedTuple()      │         │      dn ┼ nothing      │         │      dt ┼ nothing      │         │     alg ┼ nothing      │         │   order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)      │     alg ┼ FullMoment()      │       w ┼ nothing      │   cache ┴ nothing

Related

References

  • [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 3.1.4, Equations 3.6 and 3.7.
  • [30] D. Cajas. Convex Optimization of Portfolio Kurtosis. Available at SSRN 4202967 (2022).
source
PortfolioOptimisers.priorFunction
prior(pe::HighOrderPriorEstimator, X::MatNum, F::Option{<:MatNum} = nothing, pnl::Option{<:AssetPanel} = nothing; dims::Int = 1, kwargs...)

Compute high order prior moments for asset returns using a composite estimator.

prior estimates the mean, covariance, coskewness, and cokurtosis of asset returns using the specified high order prior estimator. It first computes low order moments (mean and covariance) using the embedded prior estimator, then computes coskewness and cokurtosis tensors using the provided coskewness and cokurtosis estimators. Optionally, factor returns F can be provided for factor-based estimation. The result is returned as a HighOrderPrior object.

Mathematical definition

In addition to the first and second moments, the high order estimator computes the coskewness matrix $\mathbf{M}_3$ and the square cokurtosis matrix $\mathbf{\Sigma}_4$:

\[\begin{align} \mathbf{W} &= (\mathbf{Z} \otimes \boldsymbol{1}_N^\intercal) \odot (\boldsymbol{1}_N^\intercal \otimes \mathbf{Z})\,, \\ \mathbf{M}_3 &= \frac{1}{T} \mathbf{Z}^\intercal \mathbf{W}\,, \\ \mathbf{\Sigma}_4 &= \frac{1}{T} \mathbf{W}^\intercal \mathbf{W}\,. \end{align}\]

Where:

  • $\mathbf{Z}$: $T \times N$ matrix of returns with each column's mean removed.
  • $\mathbf{W}$: $T \times N^2$ matrix of pairwise products of the centred returns.
  • $\mathbf{M}_3$: $N \times N^2$ coskewness matrix, sk.
  • $\mathbf{\Sigma}_4$: $N^2 \times N^2$ square cokurtosis matrix, kt.
  • $\boldsymbol{1}_N$: $N \times 1$ vector of ones.
  • $T$: Number of observations.
  • $\otimes$: Kronecker product.
  • $\odot$: Hadamard product.

$\mathbf{\Sigma}_4$ is the square form and is $N^2 \times N^2$. It is not the $N \times N^3$ cokurtosis matrix $\mathbf{M}_4$ of the same source, which the library never builds.

pe.kte computes kt and pe.ske computes sk, so a non-default alg — a semi-comoment, an exponentially weighted one — replaces the displays above rather than refining them. V is the negative spectral coskewness of sk, and either estimator set to nothing drops its moment from the result.

Algorithm

  1. Orient X and F to observations × variables with dims_oriented.
  2. Compute the low order block pr with pe.pe, passing F through.
  3. Compute the square cokurtosis kt with pe.kte. A nothing estimator gives a nothing moment.
  4. Compute the coskewness sk and its negative spectral form V with pe.ske. A nothing estimator gives nothing for both.
  5. Build the structure matrices at the asset count size(pr.X, 2) with dup_elim_sum_matrices. Take all three when steps 3 and 4 both produced a moment, take L2 and S2 alone when step 3 produced one and step 4 did not, and take none otherwise. D2 serves sk and the pair L2, S2 serves kt, which is why the second case leaves D2 as nothing.
  6. Assemble the HighOrderPrior through its keyword constructor, carrying pe.ske.mp as skmp when step 4 produced an sk. Every @argcheck of the constructor runs on the shapes steps 3 to 5 produced.

Arguments

  • pe: High order prior estimator.
  • X: Asset returns matrix (observations × assets).
  • F: Optional factor returns matrix (observations × factors).
  • pnl: Optional AssetPanel, the panel the carrier held. A wrapping prior forwards it unchanged, so that it can compose an estimator that is fitted on a panel. An estimator that reads no panel ignores it.
  • dims: Dimension along which to perform the computation.
  • kwargs...: Additional keyword arguments passed to underlying estimators.

Validation

  • dims in (1, 2).

Returns

  • pr::HighOrderPrior: Result object containing asset returns, mean vector, covariance matrix, coskewness tensor, cokurtosis tensor, and related quantities.

Related

source

References

[5]
D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
[30]
D. Cajas. Convex Optimization of Portfolio Kurtosis. Available at SSRN 4202967 (2022).