Entropy pooling Prior (c)

PortfolioOptimisers.EntropyPoolingPrior — Type
struct EntropyPoolingPrior{__T_pe, __T_mu_views, __T_var_views, __T_cvar_views, __T_evar_views, __T_rlvar_views, __T_sigma_views, __T_sk_views, __T_kt_views, __T_cov_views, __T_rho_views, __T_sets, __T_opt, __T_diagnose, __T_w, __T_alg, __T_cache, __T_x_src} <: AbstractLowOrderPriorEstimator_AF

Reweights the observations of a prior so that its moments and its tails meet a set of views.

EntropyPoolingPrior is a low order prior estimator. It calculates the mean and the covariance of the asset returns with entropy pooling. It takes views on the mean, the variance, the covariance, the correlation, the skewness and the kurtosis. It also takes views on the value at risk, the conditional and entropic value at risk views of [1], and the relativistic value at risk views of [2].

The tail views are the difference from MeucciEntropyPoolingPrior. That estimator finds a CVaR view with the recursive algorithm of Meucci et al. [159], which solves the whole entropy pooling problem again for each candidate value at risk. That route takes only equality views. This estimator writes each tail view as constraints of the one entropy pooling problem, so one solve meets every view. It takes the operators ==, >= and <=, views on the entropic and the relativistic value at risk, and views over several assets of every measure.

A positive combination of measures is convex, and its formulation is exact. A relative view, with coefficients of both signs, uses the integer formulation or a sequential convex formulation. [1] states the views on one asset, and the relative CVaR view on two assets. The views on several assets of the other measures, the upper-bound and equality views of the relativistic value at risk, and the sequential convex formulation are the library's own.

The posterior is the entropy pooling of [157]. H1_EntropyPooling and H2_EntropyPooling are the two sequential heuristics of [158]. H0_EntropyPooling, one solve, is the name that the library gives the original formulation. Vorobets [158] defines no H0.

The comparison operators that a view accepts depend on the moment that it constrains. var_views takes == and >=. Every other view family takes ==, >= and <=. An unsupported operator raises a Meta.ParseError that names the operators that the view accepts.

A skewness, kurtosis or correlation view divides by the variance of an asset. A staged algorithm holds that variance at its value from the stage before. Both read the variance from the prior that pe fits. This variance is the diagonal of its sigma, minus the residual variance of a factor model. So the covariance estimator of pe sets the variance that the rows hold.

The rows state the uncorrected moment of the scenarios, $\sum_{t} p_{t} (x_{t,\,i} - \mu_{i})^{2}$. The default covariance estimator is corrected. So under H1_EntropyPooling or H2_EntropyPooling, a skewness or kurtosis view increases the variance of the scenarios by the correction factor of the stage before. The view also standardises by the corrected variance. To hold the uncorrected variance of the scenarios, and to standardise by it, give pe an uncorrected covariance estimator:

ce = GeneralCovariance(; ce = StatsBase.SimpleCovariance(; corrected = false))pe = EmpiricalPrior(; ce = PortfolioOptimisersCovariance(; ce = Covariance(; ce = ce)))

The posterior sigma is then uncorrected too. H0_EntropyPooling has no stage before, and it reads the variance of the prior in the same way.

A prior(...) reference in a skewness or kurtosis view reads the sample statistic of the scenarios under the observation weights of the prior of the stage, as a value at risk reference does. The statistic standardises by its own variance estimator, not by the variance that the row reads.

A tail view needs auxiliary variables, so the estimator writes it in the JuMP model, not as rows that multiply the posterior probabilities. This has three effects on the solver:

  • opt must be a JuMPEntropyPooling when cvar_views is set. It must also be one when an evar_views or rlvar_views entry is not a lower bound under GridTailView. The grid formulation of a lower bound is the only tail formulation that is linear in the posterior probabilities alone.
  • A view that needs a binary variable needs a solver for mixed-integer exponential cone programmes. Every IntegerConditionalValueatRiskView view needs a binary variable, and so does an upper bound or an equality under GridTailView.
  • ConicRelativisticValueatRiskView, and the dual side of a relativistic value-at-risk view under SequentialTailView, write power cones. So their solver must also take the power cone, together with the exponential cone of the objective.

The alg field of a view group selects the formulation. One formulation applies to every view of the group, and a vector gives one formulation for each view. With nothing, ep_cvar_formulation, ep_evar_formulation and ep_rlvar_formulation select the formulation of each view, and their tables state the rules.

A significance level is part of the statistic. The conditional value at risk at 1 % and at 10 % are two different numbers of the same series. So the level is a field of the view group, not of the estimator. var_views, cvar_views, evar_views and rlvar_views each take one ValueatRiskView, ConditionalValueatRiskView, EntropicValueatRiskView or RelativisticValueatRiskView, or a vector of them. Each group holds the alpha of its equations, and a prior(...) reference in a group resolves to the prior value at the level of that group. A RelativisticValueatRiskView also holds a kappa, because the deformation parameter is also part of the statistic.

A tail view group also holds alg, the formulation. For an EntropicValueatRiskView or a RelativisticValueatRiskView, the grid formulation holds the grid of dual variables and the big-M multiplier. So a GridTailView in one group gives that group its own pct, K and M. ValueatRiskView has no such field. A value at risk view is linear in the posterior probabilities, so it has no formulation to select.

Warning

The OptimEntropyPooling route does not detect an infeasible view set. The dual of an infeasible set is unbounded, so the minimiser does not stop at a finite point. The posterior puts almost all of its mass on one observation, and Optim reports the solve as converged. A view far outside the feasible set makes the dual overflow instead. The moment estimators then get weights that are not finite, and they raise an ArgumentError that names Infs or NaNs. entropy_pooling states the mechanism.

Read the result, not the flag. On such a result, ens is a small number against the number of observations, and one weight is near one. kld is large, and the posterior statistic of the view is far from its target. The JuMPEntropyPooling route does not have this problem, because the solver reports an infeasible model. But its error names no view.

To refuse such a view set before the solve, give diagnose a solver of linear programmes. ep_diagnose_views then decides with one linear programme for each stage whether the views can hold together, and its error names the view fields.

Algorithm

The constructor derives the prior probabilities and validates every other field.

  1. When w is nothing, derive nothing. At solve time, prior uses the w of the wrapped result, or the uniform weights 1/T, one for each observation, when that result has none.
  2. When w is not nothing, normalise it to sum to one. The normalised weights are the prior probabilities that the pooling starts from. The caller's w does not change, because new weights of the same kind hold the normalised values, through scenario_probabilities. The kind fixes the bias correction of the posterior covariance. ScenarioProbabilities states the rule.

Fields

  • pe: Prior estimator.
  • mu_views: Mean views, or nothing for no mean view.
  • var_views: Value at risk views, as one view group or a vector of groups, or nothing for no value at risk view.
  • cvar_views: Conditional value at risk views, as one view group or a vector of groups, or nothing for no conditional value at risk view.
  • evar_views: Entropic value at risk views, as one view group or a vector of groups, or nothing for no entropic value at risk view.
  • rlvar_views: Relativistic value at risk views, as one view group or a vector of groups, or nothing for no relativistic value at risk view.
  • sigma_views: Variance views, or nothing for no variance view.
  • sk_views: Skewness views, or nothing for no skewness view.
  • kt_views: Kurtosis views, or nothing for no kurtosis view.
  • cov_views: Covariance views, or nothing for no covariance view.
  • rho_views: Correlation views, or nothing for no correlation view.
  • sets: Sets used to map estimator values to assets.
  • opt: Optimiser of each entropy pooling solve.
  • diagnose: Solver or vector of solvers of the feasibility programme that ep_diagnose_views solves before the solve of each stage, or nothing to skip the check. The programme refuses a set of views that no reweighting of the scenarios meets together, with an error that names the view fields. It costs one more solve for each stage, so the default is nothing.
  • w: Prior observation probability weights, on the observations that the wrapped estimator returns. A wrapped estimator that drops rows returns fewer observations than it gets. If nothing, the fit uses the w of the wrapped result, or the uniform weights when that result has none. The posterior probabilities take the kind of these weights, StatsBase.AnalyticWeights or StatsBase.ProbabilityWeights, and the kind fixes the bias correction of the posterior covariance. Without a w from the caller, the kind is the kind of the w of the wrapped result when it is one of the two, and StatsBase.AnalyticWeights otherwise. ScenarioProbabilities states the rule.
  • alg: Entropy pooling algorithm, which applies the views in one solve or in stages.
  • cache: Optional partial-fit state. It is nothing until partial_fit! writes one. When the caller gives no data matrix, the batch verb of the estimator reads it. Each propagation channel does one thing with it. factory keeps it unchanged, because a factory call resolves the configuration, not the sample. port_opt_view copies the entries of the selected assets into a new state, so the viewed estimator holds the state of those assets alone. obs_weights_view removes it, because a state has no slice on the observation axis. Only a type with an observation-weights field has that channel. A type with no such field falls through to the identity method, so it keeps its state. A family whose state has no exact asset slice removes it on both axes and names the reason.
  • x_src: The source of the returns that the prior fits on, nothing or an AbstractReturnsSource. nothing and DataSource read the asset returns rd.X. ExcessSource reads the returns in excess of the benchmark, rd.X - rd.B, the Excess Frame, and refuses returns data with no benchmark. nothing means that the caller stated no source, so an optimiser that holds a reader of the Excess Frame warns about a prior at nothing, and not about a prior at DataSource(). A prior reads no prior, so it refuses PriorSource. A prior inside another estimator, such as the pe of a FactorPrior, keeps nothing, and the outer estimator states the source.

Constructors

EntropyPoolingPrior(;    pe::AbstractLowOrderPriorEstimator_A_F_AF = EmpiricalPrior(),    mu_views::Option{<:LinearConstraintEstimator} = nothing,    var_views::Option{<:VV_VecVV} = nothing,    cvar_views::Option{<:CVV_VecCVV} = nothing,    evar_views::Option{<:EVV_VecEVV} = nothing,    rlvar_views::Option{<:RVV_VecRVV} = nothing,    sigma_views::Option{<:LinearConstraintEstimator} = nothing,    sk_views::Option{<:LinearConstraintEstimator} = nothing,    kt_views::Option{<:LinearConstraintEstimator} = nothing,    cov_views::Option{<:LinearConstraintEstimator} = nothing,    rho_views::Option{<:LinearConstraintEstimator} = nothing,    sets::Option{<:UniverseSets} = nothing,    opt::NonCVaREP = OptimEntropyPooling(),    diagnose::Option{<:Slv_VecSlv} = nothing,    w::Option{<:ScenarioProbabilities} = nothing,    alg::AbstractEntropyPoolingAlgorithm = H1_EntropyPooling(),    cache::Option{<:AbstractPartialFitState} = nothing,    x_src::Option{<:AbstractReturnsSource} = nothing) -> EntropyPoolingPrior

Keywords correspond to the struct's fields.

Validation

  • If a view field is not nothing, sets must not be nothing.
  • If cvar_views is not nothing, opt must be a JuMPEntropyPooling.
  • If a view field is a vector, it must not be empty.
  • If diagnose is a vector, it must not be empty.
  • If w is not nothing, it must not be empty. At solve time, its length must equal the number of observations of the wrapped result.
  • assert_scenario_refit checks that the refit under the posterior weights can state the model of pe. It refuses an OpinionPoolingPrior whose pe1 is inside a factor prior or a Black-Litterman prior of pe.
  • x_src must be nothing, DataSource() or ExcessSource(). assert_returns_source checks it.
  • The x_src of pe must be nothing, because this prior selects the returns that it reads. assert_inner_reader checks it.

Propagated parameters

factory passes its arguments on to these @fprop fields:

  • pe: Recursively updated through factory.
  • w: Replaced with the incoming ObsWeights.
  • cache: Carried unchanged through factory.

View parameters

port_opt_view takes the view of these @vprop fields at the selected indices:

Observation weight parameters

obs_weights_view indexes these fields to the selected observations:

Examples

julia> EntropyPoolingPrior(;                           sets = UniverseSets(; xkey = "nx",                                               dict = Dict("nx" => ["A", "B", "C"])),                           mu_views = LinearConstraintEstimator(;                                                                val = ["A == 0.03",                                                                       "B + C == 0.04"]))EntropyPoolingPrior           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              │        x_src ┴ nothing     mu_views ┼ LinearConstraintEstimator              │   val ┼ Vector{String}: ["A == 0.03", "B + C == 0.04"]              │   key ┴ nothing    var_views ┼ nothing   cvar_views ┼ nothing   evar_views ┼ nothing  rlvar_views ┼ nothing  sigma_views ┼ nothing     sk_views ┼ nothing     kt_views ┼ nothing    cov_views ┼ nothing    rho_views ┼ nothing         sets ┼ UniverseSets              │     xkey ┼ String: "nx"              │    uxkey ┼ String: "ux"              │    tfkey ┼ String: "nf"              │   utfkey ┼ String: "uf"              │    cfkey ┼ String: "ncf"              │   ucfkey ┼ String: "ucf"              │    nikey ┼ String: "ni"              │     dict ┴ Dict{String, Vector{String}}: Dict("nx" => ["A", "B", "C"])          opt ┼ OptimEntropyPooling              │     args ┼ Tuple{}: ()              │   kwargs ┼ @NamedTuple{}: NamedTuple()              │      sc1 ┼ Int64: 1              │      sc2 ┼ Float64: 1000.0              │      alg ┼ ExpEntropyPooling()              │      err ┴ nothing     diagnose ┼ nothing            w ┼ nothing          alg ┼ H1_EntropyPooling()        x_src ┴ nothing

The incremental fit

This prior has no exact incremental recursion, and it takes the online step by a refit from a sample buffer. Online seeds cache, and partial_fit! adds each observation to it with no change. The prior method with one argument then runs the batch verb of this estimator over the rows that the buffer kept. The result is the batch fit over those rows, and a max_history on the wrapper sets the window of the whole fit.

cache goes through the three propagation channels as every partial-fit state does. factory carries it with no change, and port_opt_view cuts it to the selected assets. obs_weights_view drops it, because a state has no cut on the observation axis. The show method does not print cache, because a buffer that changes at each step is not part of the configuration.

Related

References

  • [157] A. Meucci. Fully flexible views: theory and practice. Risk 21, 97–102 (2008). Section 4, Equations 25 to 28, and Appendix A.2 and A.3.
  • [158] A. Vorobets. Sequential entropy pooling heuristics. Available at SSRN 3936392 (2021). Section 3, Algorithms 1 and 2.
  • [1] D. Cajas. Entropy Pooling with CVaR and EVaR Views. Available at SSRN 7120258 (2026). Section 2.2, Equations 3 to 6, and Section 2.3, Equations 7 to 11.
  • [2] D. Cajas. Entropy Pooling with Relativistic Value at Risk Views. Available at SSRN 7329718 (2026). Section 2, Equations 1 to 5, and Section 3.2, Equation 7.
  • [159] A. Meucci, D. Ardia and S. Keel. Fully flexible extreme views. The Journal of Risk 14, 39–49 (2011).
source
PortfolioOptimisers.prior — Function
prior(pe::EntropyPoolingPrior, X::MatNum, F::Option{<:MatNum} = nothing,
      pnl::Option{<:AssetPanel} = nothing; dims::Int = 1, strict::Bool = false,
      kwargs...)

Compute the entropy pooling prior moments of the asset returns, with moment views and tail views.

prior orients the data along dims and calls ep_prior, which dispatches on the entropy pooling algorithm pe.alg. H0_EntropyPooling applies every view in one optimisation. StagedEP, the union of H1_EntropyPooling and H2_EntropyPooling, applies the views in stages, from the lower moments to the higher moments.

Algorithm

  1. Orient X and F to observations by assets with dims_oriented, so every step below reads one observation in each row.
  2. When pe.sets is set, check that the length of its asset universe is equal to the number of columns of X, with assert_ep_views_axis.
  3. Dispatch on pe.alg through ep_prior, and return the LowOrderPrior that it makes.

Arguments

  • pe: Entropy pooling prior estimator.
  • X: Asset returns matrix, with its observations along dims.
  • F: Optional factor returns matrix, with its observations along dims.
  • pnl: Optional AssetPanel, the panel that the returns data 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 the computation runs.
  • strict: If true, raise an error for an asset that the universe does not hold. If false, warn.
  • kwargs...: More keyword arguments, which go to the wrapped prior estimator.

Validation

  • dims in (1, 2).
  • If pe.sets is not nothing, length(pe.sets.dict[pe.sets.xkey]) == size(X, 2). Raises a DimensionMismatch.

Returns

  • pr::LowOrderPrior: Prior result that holds the asset returns, the posterior mean and covariance, the posterior probability weights, the effective number of scenarios, the Kullback-Leibler divergence and the factor block of the last refit.

Related

source

References

[1]
D. Cajas. Entropy Pooling with CVaR and EVaR Views. Available at SSRN 7120258 (2026).
[2]
D. Cajas. Entropy Pooling with Relativistic Value at Risk Views. Available at SSRN 7329718 (2026).
[157]
A. Meucci. Fully flexible views: theory and practice. Risk 21, 97–102 (2008).
[158]
A. Vorobets. Sequential entropy pooling heuristics. Available at SSRN 3936392 (2021).
[159]
A. Meucci, D. Ardia and S. Keel. Fully flexible extreme views. The Journal of Risk 14, 39–49 (2011).