Entropy Pooling (c): private API

PortfolioOptimisers.show_fields — Method
show_fields(_::EntropyPoolingPrior) -> NTuple{15, Symbol}

Renders every field of a EntropyPoolingPrior except cache.

The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one. Set set_show_nothing_fields!(:EntropyPoolingPrior, true) to render it.

Arguments

  • ::EntropyPoolingPrior: Prior estimator, read for its type alone.

Returns

  • fields::Tuple: The field names to render, which is (:pe, :mu_views, :var_views, :cvar_views, :evar_views, :rlvar_views, :sigma_views, :sk_views, :kt_views, :cov_views, :rho_views, :sets, :opt, :w, :alg).

Related

source
PortfolioOptimisers.ep_prior — Function
ep_prior(alg::StagedEP, pe::EntropyPoolingPrior, X::MatNum, F::Option{<:MatNum},
         pnl::Option{<:AssetPanel} = nothing; strict::Bool = false, kwargs...)

Compute entropy pooling prior moments with tail views, enforcing the views in stages.

ep_prior accumulates the views of each stage into one constraint set and solves once per stage, so a stage's views hold alongside every view of the stages before it. The mean of an asset a later stage constrains is pinned to the value the earlier stage produced, so a higher moment view does not silently move it.

Algorithm

  1. Fit the wrapped prior estimator, giving pr. The fit states the observation axis: T is size(pr.X, 1), which a nested prior that drops rows makes smaller than size(X, 1).
  2. Read the prior probabilities w0 on that axis with ep_prior_probabilities. They are pe.w where the caller set one, pr.w where the fit answered one, and the uniform 1/T otherwise. A caller's pe.w reaches the wrapped estimator through factory, and pr is refitted under it.
  3. Stage one holds the mean, value at risk, conditional, entropic and relativistic value at risk views. Accumulate them into the constraint dictionary epc and the tail view vector tvs. Where either is non-empty, solve from w0 with entropy_pooling, giving w1, and refit pr at w1.
  4. Stage two holds the variance and covariance views, with the mean of every asset they name pinned by fix_mu!. Where epc or tvs is non-empty, solve from w0 under H1_EntropyPooling, or from the previous w1 under H2_EntropyPooling, and refit pr at the new w1.
  5. Stage three holds the skewness, kurtosis and correlation views, with the mean and the variance of every asset they name pinned by fix_mu! and fix_sigma!. Under the same emptiness test, solve from the same start step 4 takes, and refit pr at the new w1.
  6. Compute ens, the effective number of scenarios of w1, and kld, the divergence of w1 from w0.
  7. Return a LowOrderPrior carrying the refit moments, w1, ens and kld. The feature matrix and the factor block come from pr unchanged.

Every row of every family can drop under strict = false, and a stage then states no view. The emptiness test is on the rows the stages hold, not on the fields the caller set, so such a fit answers the prior: w1 is w0, kld is zero, and no refit runs.

Arguments

  • alg: Staged entropy pooling algorithm.

    • ::H1_EntropyPooling: Each stage re-solves from the original prior weights.
    • ::H2_EntropyPooling: Each stage re-solves from the previous stage's weights.
  • pe: Entropy pooling prior estimator.

  • X: Asset returns matrix, already oriented.

  • F: Optional factor returns matrix, already oriented.

  • 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.

  • strict: If true, throws error for missing assets; otherwise, issue warnings.

  • kwargs...: Additional keyword arguments forwarded to the wrapped prior estimator.

Returns

  • pr::LowOrderPrior: Prior result carrying the posterior probability weights.

Related

source
PortfolioOptimisers.ep_prior — Function
ep_prior(alg::H0_EntropyPooling, pe::EntropyPoolingPrior, X::MatNum,
         F::Option{<:MatNum}, pnl::Option{<:AssetPanel} = nothing;
         strict::Bool = false, kwargs...)

Compute entropy pooling prior moments with tail views, enforcing every view in one optimisation.

ep_prior builds every view constraint against the same prior and solves once. It is faster than the staged algorithms and pins nothing, so a higher moment view is free to move a lower moment.

Algorithm

  1. Fit the wrapped prior estimator, giving pr. The fit states the observation axis: T is size(pr.X, 1), which a nested prior that drops rows makes smaller than size(X, 1).
  2. Read the prior probabilities w0 on that axis with ep_prior_probabilities. They are pe.w where the caller set one, pr.w where the fit answered one, and the uniform 1/T otherwise. A caller's pe.w reaches the wrapped estimator through factory, and pr is refitted under it.
  3. Build every view against that one pr: the mean, value at risk, conditional, entropic and relativistic value at risk, variance, covariance, skewness, kurtosis and correlation views. Each row that is linear in the posterior probabilities reaches the constraint dictionary epc, and each tail view that needs auxiliary variables reaches the tail view vector tvs. No asset's mean or variance is pinned.
  4. Where epc or tvs is non-empty, solve once from w0 with entropy_pooling, giving w1, and refit pr at w1. Every row of every family can drop under strict = false, and the view set then states nothing: w1 is w0, kld is zero, and no refit runs.
  5. Compute ens, the effective number of scenarios of w1, and kld, the divergence of w1 from w0.
  6. Return a LowOrderPrior carrying the refit moments, w1, ens and kld. The feature matrix and the factor block come from pr unchanged.

Arguments

  • alg: Single-shot entropy pooling algorithm.
  • pe: Entropy pooling prior estimator.
  • X: Asset returns matrix, already oriented.
  • F: Optional factor returns matrix, already oriented.
  • 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.
  • strict: If true, throws error for missing assets; otherwise, issue warnings.
  • kwargs...: Additional keyword arguments forwarded to the wrapped prior estimator.

Returns

  • pr::LowOrderPrior: Prior result carrying the posterior probability weights.

Related

source