Meucci entropy pooling Prior: private API
Types
PortfolioOptimisers.VecMeucciEP — Type
const VecMeucciEP = AbstractVector{<:MeucciEntropyPoolingPrior}Groups the vector forms of MeucciEntropyPoolingPrior that a method can dispatch on.
A caller that pools opinions holds many estimators, and a method that takes such a collection needs one type in its signature. The opinion pooling of the library uses the wider VecEP, which also admits EntropyPoolingPrior. VecMeucciEP is the narrower name for a method that takes only the recursive CVaR route.
Related
MeucciEntropyPoolingPrior: the element type of the vector.VecEP: the wider group in the signature ofOpinionPoolingPrior, which admits both entropy pooling estimators.
PortfolioOptimisers.CvarViewSearch — Type
struct CvarViewSearch{__T_X, __T_B, __T_alphas, __T_d_opt, __T_edge}The search data of the conditional value at risk views of a Meucci entropy pooling estimator.
This type is an implementation detail and is not intended for direct use. ep_cvar_views_setup makes it. ep_cvar_views_solve! reads it.
Fields
X:X: The loss columns of the assets that the searched views name.
B:B: The target of each searched view.
alphas:alphas: The significance level of each searched view.
d_opt:d_opt: The optimiser of the search, ornothingwhen no view needs a search.
edge:edge: The(lhs, rhs)block of the views whose target is the worst loss of their asset on the support, ornothingwhen no view has such a target. Each row states-sum(p[W]) <= -alpha, whereWholds the scenarios of that loss.
Related
Functions
PortfolioOptimisers.ep_cvar_views_setup — Function
ep_cvar_views_setup(cvar_views::Nothing, args...; kwargs...)Return nothing when the estimator has no conditional value at risk view.
Arguments
cvar_views::Nothing: Shows that the estimator has no CVaR view.args...: More positional arguments, which the method does not read.kwargs...: More keyword arguments, which the method does not read.
Returns
nothing: There is no search to prepare.ep_cvar_views_solve!dispatches on this value.
Related
ep_cvar_views_setup(cvar_views::CVV_VecCVV, pr::AbstractPriorResult,
sets::UniverseSets, w::ScenarioProbabilities,
ds_opt::Option{<:ConditionalValueatRiskEntropyPooling},
dm_opt::Option{<:OptimEntropyPooling}; strict::Bool = false,
ledger::Option{<:AbstractVector} = nothing) ->
Option{<:CvarViewSearch}Resolve the conditional value at risk views once, into the data of one search.
ep_cvar_views_setup parses and checks the CVaR view groups, and it resolves every prior(...) reference against pr under w. It puts the groups into one loss matrix, one target vector and one level vector. It also selects the search that the targets need. ep_cvar_views_solve! reads this result and adds nothing to it.
The staged route of ep_prior searches up to three times, once for each stage, and each stage must read the same reference value. So ep_prior calls this function once, before the first solve. The call reads the first fit of the wrapped estimator and the prior probabilities of that fit. A later stage holds a refit pr whose weights are the posterior of the stage before. A reference resolved there gives a different target at each stage, and the view that the caller wrote changes. One call also keeps the parse out of the search, so the search does not parse again at each stage.
Mathematical definition
The conditional value at risk of a loss is never larger than the worst loss $L_{w}$ on the support. It equals that loss when, and only when, the posterior puts at least $\alpha$ on the scenarios of that loss. So a view at that target is one linear row:
\[\begin{align} \mathrm{CVaR}_{\alpha}(X) = L_{w} \iff \sum_{t \in W} p_{t} \geq \alpha\,, \qquad W = \left\{t : q_{t} > 0,\; -x_{t,\,i} = L_{w}\right\}. \end{align}\]
When the prior mass $\sum_{t \in W} q_{t}$ is at least $\alpha$, the prior meets the row, and the row adds no divergence. The search of ep_cvar_views_solve! cannot write such a view. Its row at every candidate value at risk below $L_{w}$ forces $\sum_{t \in W} p_{t} = \alpha$, so its residual is zero only up to rounding.
Where:
- $\boldsymbol{p}$: $T \times 1$ posterior probabilities of the observations, summing to one. They are the unknown of the entropy pooling problem.
- $\boldsymbol{q}$: $T \times 1$ prior probabilities of the observations, summing to one.
- $x_{t,\,i}$: Return of asset $i$ at observation $t$.
- $\alpha$: Significance level (left tail probability), $\alpha \in (0, 1)$.
- $L_{w}$: Worst loss of asset $i$ on the support of the prior.
- $W$: Scenarios of the support at the loss $L_{w}$.
Algorithm
- Loop over the view groups of
cvar_views. One view group iterates as a collection of one element, so one loop reads both forms. - For each view group, check that its
algisnothing, and read its significance level intoalpha. Parse its equations, and accept only==. - Replace every group name by the assets of the group. Replace every
prior(...)reference by the prior conditional value at risk atalphaunderw, throughreplace_prior_views. - Turn the parsed views into the equality block
lcs. Understrict = false, every row of the group can drop, andlcsis thennothing. The group then states no view, and the loop goes to the next group. - Check that each row of
lcsnames one asset, and that each target is not negative. - For each row of the block, add the asset that it names to
cols, its target toB, its level toalphasand its text toeqns. All the groups go into one search, because each level is only the divisor of the positive part of its own view. - Read the worst realisation of every named asset on the support of
wintomin_X. Raise an error when a target is larger than it. - Write each view whose target equals
min_Xas one row of the blockedge. The row is-sum(p[W]) <= -alpha, whereWholds the scenarios of the support at that loss. Keep the other views for the search. - Select the search
d_optfrom the number of kept views. No kept view takesnothing. One kept view takesds_opt, or a defaultConditionalValueatRiskEntropyPooling. More than one kept view takesdm_opt, or a defaultOptimEntropyPoolingoverOptim.Fminbox. - Return
nothingwhen no group states a view, so the stage uses the plain solve. Otherwise, return the loss columnsX, the targetsBand the levelsalphasof the kept views, the searchd_optand the blockedge.
Arguments
cvar_views: One CVaR view group, or a vector of groups.pr: Prior result that theprior(...)references read. It is the first fit of the wrapped estimator, not a refit of a later stage.sets: Universe sets that map the asset names to indices.w: Observation weights of the fit ofpr. Theprior(...)references resolve under these weights.ds_opt: Search for one CVaR view, ornothingfor the default.dm_opt: Optimiser for more than one CVaR view, ornothingfor the default.strict: Iftrue, raise an error for an asset that the universe does not hold. Iffalse, warn.ledger: The Departure Ledger of the entry of the fit, ornothingwhen no caller collects the drops.replace_group_by_assetsandget_linear_constraintsfill it.
Validation
- No view group declares a view formulation. A group whose
algis notnothingraises anArgumentError, because this route writes no constraint formulation. - Every view names one asset. A view over more than one asset raises an
ArgumentError. - Every target is not negative. A negative target raises a
DomainError. - Every target is at most the worst realisation of its asset over the scenarios at a positive weight of
w. The CVaR equals that loss when the posterior puts at least the level of the view on the scenarios of that loss, and a posterior that is positive on every scenario does this. A larger target raises aDomainError. The message names every view that is too large, and the largest target that its asset accepts.ep_assert_reachable_viewraises the same error type for one view, so onecatchreads both.
Returns
nothing: No group states a view, becausestrictisfalseand every row of every group dropped.cvv::CvarViewSearch: The search data, which holds the loss columnsX, the targetsBand the levelsalphasof the searched views, the searchd_opt, and the blockedgeof the views at the worst loss.
Related
CvarViewSearchep_cvar_views_solve!: runs the search that this function prepares.replace_prior_views: resolves theprior(...)reference of a target.get_pr_value: reads the prior conditional value at risk that the reference resolves to.ConditionalValueatRiskEntropyPoolingOptimEntropyPoolingMeucciEntropyPoolingPrior
References
- [159] A. Meucci, D. Ardia and S. Keel. Fully flexible extreme views. The Journal of Risk 14, 39–49 (2011). Section 3, Equations 3.1 to 3.5.
PortfolioOptimisers.ep_cvar_views_solve! — Function
ep_cvar_views_solve!(cvv::Nothing, epc::AbstractDict,
w::ScenarioProbabilities,
opt::AbstractEntropyPoolingOptimiser)Solve the entropy pooling problem when the estimator has no CVaR view.
ep_cvar_views_setup prepares no search when the estimator has no conditional value at risk view. Then this method solves the entropy pooling problem once, with the prior weights, the constraint dictionary and the optimiser that it gets. Both routes of ep_prior call it, so their code is the same with and without a CVaR view.
Algorithm
- Call
entropy_poolingwith the prior weightsw, the constraint dictionaryepcand the optimiseropt. The result is the posterior probability weightspw. - Return
pw. With no conditional value at risk view, there is no value at risk to search for. So the solve of the stage is the one call of step 1.
Arguments
cvv: Shows thatep_cvar_views_setupprepared no search.epc: Dictionary of entropy pooling constraints, which maps each key to an(lhs, rhs)pair.w: Prior probability weights.opt: Entropy pooling optimiser.
Returns
pw::ScenarioProbabilities: Posterior probability weights that meet the constraints, in the kind ofw.
Related
ep_cvar_views_solve!(cvv::CvarViewSearch, epc::AbstractDict,
w::ScenarioProbabilities,
opt::AbstractEntropyPoolingOptimiser)Solve the entropy pooling problem with conditional value at risk (CVaR) views.
ep_cvar_views_solve! reads the targets, the levels, the search and the rows that ep_cvar_views_setup resolved. A view whose target is the worst loss of its asset on the support is a linear row, and every solve holds it. For the other views, it finds the posterior probability weights with a root search for one CVaR view, and with an optimisation for more than one. With no other view, it solves once. It parses nothing and resolves nothing, because the staged route calls it once for each stage, and every stage must read the same targets.
The search is over the value at risk levels etas, one for each searched view. A candidate is in [lo, B], where lo is the lowest loss of its asset on the support. A target is not negative, but the value at risk is below zero when the posterior puts less than alpha on the losses above zero. This search is a continuous relaxation of the recursive algorithm, which searches over discrete tail sizes. It gets the same target, and it also takes more than one view.
The bracket for one view stops a small distance inside B, at B * (1 - sqrt(eps)). At B, the constraint needs a posterior tail contribution of exactly zero. No posterior with all its weights above zero has such a contribution, so the problem at B is degenerate and its dual is unbounded. Roots evaluates the two ends of a bracket before it searches, so without the shrink each search for one view solves that problem once. The root is between about a third and two thirds of B, so the shrunk bracket holds it. The bracket starts at zero when the residual at zero is positive. Otherwise the root is at or below zero, and the bracket is [lo, 0]. When every loss of the asset on the support is above zero, lo is above zero, and the bracket starts at lo.
Mathematical definition
The conditional value at risk of asset $i$ is the value of the Rockafellar-Uryasev programme, and the minimiser of that programme is the value at risk. A view that sets it to $\bar{c}$ is a pair of conditions on the posterior. The first condition is linear in $\boldsymbol{p}$ at a fixed $\eta$, and the second condition fixes $\eta$:
\[\begin{align} \mathrm{CVaR}_{\alpha}(X) &= \underset{\eta}{\min}\; \left\{ \eta + \frac{1}{\alpha} \sum_{t=1}^{T} p_{t} \left(-x_{t,\,i} - \eta\right)^{+} \right\}\,, \\ \frac{1}{\alpha} \sum_{t=1}^{T} p_{t} \left(-x_{t,\,i} - \eta\right)^{+} &= \bar{c} - \eta\,, \\ \sum_{t=1}^{T} p_{t} \mathbb{1}\left\{-x_{t,\,i} > \eta\right\} &= \alpha\,. \end{align}\]
The second line is linear in $\boldsymbol{p}$, so one entropy pooling solve meets it at each candidate $\eta$. The third line holds only when that $\eta$ is the value at risk of the posterior of the solve. So the two lines have one common fixed point, and the posterior meets the view only at that point.
Where:
- $\mathrm{CVaR}_{\alpha}(X)$: Conditional value at risk of the loss series $\boldsymbol{x}$ at level $\alpha$.
- $\bar{c}$: Target conditional value at risk of the view.
- $\boldsymbol{p}$: $T \times 1$ posterior probabilities of the observations, summing to one. They are the unknown of the entropy pooling problem.
- $x_{t,\,i}$: Return of asset $i$ at observation $t$.
- $\alpha$: Significance level (left tail probability), $\alpha \in (0, 1)$.
- $T$: Number of observations.
- $\eta$: Value at risk of asset $i$ at level $\alpha$. It is the minimiser of the first line, and the variable of the outer search.
- $(\cdot)^{+}$: Positive part, $\max(\cdot,\, 0)$.
Algorithm
- Read the loss columns
X, the targetsB, the levelsalphas, the searchd_optand the blockedgefromcvv. - Delete the key
:cvar_ineqfromepc, and writeedgeunder it whenedgeis notnothing. The key holds the rows of the views at the worst loss, the inequality ofep_cvar_views_setup. When no view needs a search, solveepconce withentropy_pooling, and return the result. - Define
func(etas). At the candidateetas, it writes the second line above intoepcunder the key:cvar_eq. It solves the whole constraint set withentropy_poolingintowi, and returnswiand the residual of the third line. For one view, the residual is the posterior tail mass minusalpha. For more than one view, it is thenorm_errorover the views of the posterior conditional value at risk minus the target. - Search for the value at risk
res. For one view, calculate the residual offuncatz = max(0, lo). When it is positive,Roots.find_zerofinds the root of the residual over[z, B[1] * (1 - sqrt(eps))]. Otherwise it finds the root over[lo, z]. The search reuses the residual atz, and solves no inner problem there again. For more than one view,Optim.optimizeminimises the residual over the box[lo, B]from the start0.5 * (max(lo, 0) + B), which is0.5 * Bwhenlois at or below zero. After the start, a trial point at which the inner solve fails, or a trial point outside the box, gets the residualInf, and the line search rejects that point. - Call
func(res)one more time, and return the posterior probability weights that it calculates.
Arguments
cvv: Search data fromep_cvar_views_setup.epc: Dictionary of entropy pooling constraints, which maps each key to an(lhs, rhs)pair.w: Prior probability weights that the stage projects.opt: Optimiser of each inner entropy pooling solve.
Validation
- Every candidate value at risk is in
[lo, B]. A candidate outside the box raises aDomainError. With more than one view, the search rejects a trial point outside the box after the start, so that point does not raise. - The search must succeed. When
Roots.find_zeroorOptim.optimizeraises an error, this method raises anErrorExceptionthat holds it. An innerentropy_poolingsolve that fails at one point of the search for one view is such an error. With more than one view, the search rejects a trial point after the start at which the inner solve fails, so that failure does not raise. A failed inner solve at the start of the box raises. WhenOptim.convergedreports thatOptim.optimizefailed, this method raises anErrorException. A failed inner solve at the last call, at the minimiser, raises its own error. - The method does not detect an infeasible view set. The residual of this search is the posterior tail mass minus
alpha. A posterior with almost all of its mass on one observation has a small residual, but it can miss the view by a large amount. The warning ofMeucciEntropyPoolingPriorstates how to find such a result. - The method does not detect a missed feasible view. The search reads its own residual, not how closely the inner
entropy_poolingsolve meets the constraint of the view. With more than one view,Optim.convergedaccepts a solve that stopped on the step inxand not on stationarity. The warning ofMeucciEntropyPoolingPriorstates the mechanism, the measured sizes, and how to read the result.
Returns
pw::ScenarioProbabilities: Posterior probability weights that meet the CVaR views, in the kind ofw.
Related
ep_cvar_views_setup: resolves the targets that this search reads.ConditionalValueatRiskEntropyPoolingOptimEntropyPooling: its stopping rule sets how closely each inner solve meets the constraint that this search solves again. Its tip states the size of the miss.MeucciEntropyPoolingPriorentropy_poolingnorm_error: scores the residual of a search over more than one view.ConditionalValueatRisk: reads the posterior statistic that residual scores.
References
- [159] A. Meucci, D. Ardia and S. Keel. Fully flexible extreme views. The Journal of Risk 14, 39–49 (2011). Section 3, Equations 3.1 to 3.6.
PortfolioOptimisers.ep_prior — Function
ep_prior(alg::StagedEP, pe::MeucciEntropyPoolingPrior, X::MatNum,
F::Option{<:MatNum}, pnl::Option{<:AssetPanel} = nothing;
strict::Bool = false, kwargs...)Compute the entropy pooling prior moments of the asset returns, with the views applied in stages.
ep_prior calculates the mean and the covariance of the asset returns with entropy pooling, under the staged algorithms H1_EntropyPooling and H2_EntropyPooling. It takes views on the mean, the value at risk, the conditional value at risk, the variance, the covariance, the skewness, the kurtosis and the correlation. Each stage adds the views of one group of moments, solves, and refits the wrapped estimator under the new weights. A later stage holds the moments of the earlier stages fixed, so a view on a higher moment does not move a lower moment.
Each stage refits the wrapped estimator after its solve, and the next stage parses its views against that refit. So a prior(...) reference in a later stage resolves against the posterior of the stage before, not against the prior of the estimator. Under a mu_views or cvar_views view, a sigma_views target prior(A)*1.3 asks for 1.3 times the variance that stage one leaves, not 1.3 times the empirical variance. When the reference must be the empirical value, write the target as a number.
Mathematical definition
The staged posterior is a chain of Kullback-Leibler projections, not one projection. Stage $k$ holds the constraint set $\mathcal{C}_{k}$, which has the rows of stage $k$ and of every stage before it. It projects a reference $\boldsymbol{r}^{(k)}$ that the algorithm tag fixes:
\[\begin{align} \boldsymbol{p}^{(k)} &= \underset{\boldsymbol{p} \in \mathcal{C}_{k}}{\arg\min} \sum_{t=1}^{T} p_{t} \ln\!\frac{p_{t}}{r_{t}^{(k)}}\,, \\ \mathcal{C}_{k} &= \left\{ \boldsymbol{p} : \mathbf{A}_{k} \boldsymbol{p} = \boldsymbol{B}_{k},\; \boldsymbol{p} \geq \boldsymbol{0},\; \boldsymbol{1}^\intercal \boldsymbol{p} = 1 \right\}\,, \\ \mathcal{C}_{1} &\supseteq \mathcal{C}_{2} \supseteq \mathcal{C}_{3}\,, \\ \boldsymbol{r}^{(k)} &= \begin{cases} \boldsymbol{q} & \text{under } \texttt{H1\_EntropyPooling} \\ \boldsymbol{p}^{(k-1)} & \text{under } \texttt{H2\_EntropyPooling} \end{cases}\,, \\ \boldsymbol{p}^{*} &= \boldsymbol{p}^{(K)}\,. \end{align}\]
The first stage holds the mean and value at risk views. The second stage holds the variance and covariance views, and the third stage holds the correlation, skewness and kurtosis views. The sets nest, so the posterior of the last stage meets every view. The two references differ only in the start point of the chain. $\texttt{H1\_EntropyPooling}$ gives the projection of the prior onto the whole view set, and $\texttt{H2\_EntropyPooling}$ gives the projection of each stage onto the next. A conditional value at risk view is not a row of $\mathbf{A}_{k}$. It enters every stage as the fixed point of ep_cvar_views_solve!, whose section states it.
Where:
- $\boldsymbol{p}$: $T \times 1$ posterior probabilities of the observations, summing to one. They are the unknown of the entropy pooling problem.
- $\boldsymbol{q}$: $T \times 1$ prior probabilities of the observations, summing to one.
- $T$: Number of observations.
- $\boldsymbol{p}^{(k)}$: Posterior probabilities of stage $k$. $\boldsymbol{p}^{*}$ is the posterior of the last stage $K$.
- $\boldsymbol{r}^{(k)}$: Reference probabilities that stage $k$ projects.
- $\mathcal{C}_{k}$: Constraint set of stage $k$, which holds the rows of every stage up to stage $k$.
- $\mathbf{A}_{k}$, $\boldsymbol{B}_{k}$: Rows and right-hand side of $\mathcal{C}_{k}$.
The posterior moments are the sample statistics under the weights $\boldsymbol{p}^{*}$.
Algorithm
- Fit the wrapped prior estimator with
ep_wrapped_prior. The result isprand the prior probabilitiesw0on its rows. The fit sets the observation axis.Tissize(pr.X, 1), which is smaller thansize(X, 1)when a nested prior drops rows. The probabilities arepe.wwhen the caller gives one,pr.wwhen the fit returns one, and the uniform1/Totherwise.prior_probability_factoryputs thepe.wof the caller on the rows that each weighted field of the wrapped estimator reads, and the fit ofpruses it. Before that fit,scenario_countreadsTwith only the steps that drop rows, so most wrapped priors need no fit for it. When the fit underpe.wreturns its ownpr.w, a nested prior solved its views frompe.w. Thenw0ispr.w, the posterior of the nested prior. - Pin each choice of
pe.peunder aPinnedChoiceat this fit withpin_prior_choice, so every refit reads the choice that the views read. Every refit goes throughscenario_prior, which holds the model of this fit, with its regression and its residual block. So the refit reads the scenarios that the views read. - Get the Investable Mask of the fit and the universe of the views with
investable_views. Every view row uses only the investable columns, and the mask is the same at each stage. - Make the empty constraint dictionary
epc, the matrixfixedof the pinned moments, and the Departure Ledger. Resolve thecvar_viewsagainst that fit one time, throughep_cvar_views_setupintocvv. Every stage searches the same targets, so aprior(...)reference gives one number for the whole chain. - Stage one, the mean and the value at risk. Write the
mu_viewsandvar_viewsrows intoepc. Whenepcholds a row orcvvholds a search, solve fromw0throughep_cvar_views_solve!intow1, and refitprunderw1. - Stage two, the variance and the covariance. Write the
sigma_viewsandcov_viewsrows intoepc. Pin the mean of every asset that those rows read withfix_mu!, so the stage cannot move a moment that an earlier stage set. Under the same test, solve intow1, and refitprunderw1. - Stage three, the correlation, the skewness and the kurtosis. Write the
sk_views,kt_viewsandrho_viewsrows intoepc. Pin the mean and the variance of every asset that those rows read withfix_mu!andfix_sigma!. Under the same test, solve intow1, and refitprunderw1. - Steps 6 and 7 solve from
w0underH1_EntropyPooling, and from thew1of the stage before underH2_EntropyPooling. - Report the departed assets and the views that they removed, with
announce_ep_departures. - Calculate the effective number of scenarios
ens, the exponential of the entropy ofw1. Calculatekld, the Kullback-Leibler divergence ofw1fromw0. - Return a
LowOrderPriorthat holds the moments of the last refit,w1,ensandkld. The factor blockfprcomes from that refit with no change.
Arguments
alg: Staged entropy pooling algorithm, whichpriorreads frompe.alg.pe: Entropy pooling prior estimator.X: Asset returns matrix, with one observation in each row, aspriororients it.F: Optional factor returns matrix, with one observation in each row, aspriororients it.pnl: OptionalAssetPanel, 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.strict: Iftrue, raise an error for an asset that the universe does not hold. Iffalse, warn.kwargs...: More keyword arguments, which go to the wrapped prior estimator.
Validation
- If a view field is not
nothing,pe.setsmust not benothing. - If the caller gives prior weights
pe.w,length(pe.w) == size(pr.X, 1)must hold, wheresize(pr.X, 1)is the number of observations that the wrapped estimator returns. A different length raises aDimensionMismatch. The message names that number, the number of observations that the estimator got, and the rule. - Every view equation has a comparison operator that its family accepts. An unsupported operator raises a
Meta.ParseErrorthat names the operators of that family.
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
PortfolioOptimisers.ep_prior — Function
ep_prior(alg::H0_EntropyPooling, pe::MeucciEntropyPoolingPrior, X::MatNum,
F::Option{<:MatNum}, pnl::Option{<:AssetPanel} = nothing;
strict::Bool = false, kwargs...)Compute the entropy pooling prior moments of the asset returns, with every view applied in one solve.
ep_prior calculates the mean and the covariance of the asset returns with entropy pooling, under the H0_EntropyPooling algorithm. It applies every view in one optimisation. This route solves the entropy pooling problem one time. But a view on a higher moment can move a lower moment, because no stage holds the lower moments fixed.
Mathematical definition
The single-shot posterior is one Kullback-Leibler projection of the prior onto the intersection of the constraint sets of all the views. It is the staged chain of ep_prior with one stage:
\[\begin{align} \boldsymbol{p}^{*} &= \underset{\boldsymbol{p} \in \mathcal{C}}{\arg\min} \sum_{t=1}^{T} p_{t} \ln\!\frac{p_{t}}{q_{t}}\,, \\ \mathcal{C} &= \mathcal{C}_{1} \cap \mathcal{C}_{2} \cap \mathcal{C}_{3}\,. \end{align}\]
One reference and one feasible set hold every view, so no stage can pin a moment. A view on a higher moment can move a lower moment of the same asset. That is the only difference from the staged chain, whose sets $\mathcal{C}_{k}$ this set $\mathcal{C}$ intersects. A conditional value at risk view is not a row of $\mathcal{C}$. It enters as the fixed point of ep_cvar_views_solve!, whose section states it.
Where:
- $\boldsymbol{p}$: $T \times 1$ posterior probabilities of the observations, summing to one. They are the unknown of the entropy pooling problem.
- $\boldsymbol{q}$: $T \times 1$ prior probabilities of the observations, summing to one.
- $T$: Number of observations.
- $\boldsymbol{p}^{*}$: Posterior probabilities of the one solve.
- $\mathcal{C}$, $\mathcal{C}_{k}$: Feasible set of the one solve, and the stage sets that it intersects.
The posterior moments are the sample statistics under the weights $\boldsymbol{p}^{*}$.
Algorithm
- Fit the wrapped prior estimator with
ep_wrapped_prior. The result isprand the prior probabilitiesw0on its rows. The fit sets the observation axis.Tissize(pr.X, 1), which is smaller thansize(X, 1)when a nested prior drops rows. The probabilities arepe.wwhen the caller gives one,pr.wwhen the fit returns one, and the uniform1/Totherwise.prior_probability_factoryputs thepe.wof the caller on the rows that each weighted field of the wrapped estimator reads, and the fit ofpruses it. Before that fit,scenario_countreadsTwith only the steps that drop rows, so most wrapped priors need no fit for it. When the fit underpe.wreturns its ownpr.w, a nested prior solved its views frompe.w. Thenw0ispr.w, the posterior of the nested prior. - Pin each choice of
pe.peunder aPinnedChoiceat this fit withpin_prior_choice, so every refit reads the choice that the views read. Every refit goes throughscenario_prior, which holds the model of this fit, with its regression and its residual block. So the refit reads the scenarios that the views read. - Get the Investable Mask of the fit and the universe of the views with
investable_views. Every view row uses only the investable columns. - Make the empty constraint dictionary
epcand the Departure Ledger. Resolve thecvar_viewsagainst that fit one time, throughep_cvar_views_setupintocvv. - Write the
mu_viewsandvar_viewsrows intoepc. - Write the
sigma_viewsandcov_viewsrows intoepc. This route pins no moment, so it does not callfix_mu!orfix_sigma!. - Write the
sk_views,kt_viewsandrho_viewsrows intoepc. - Report the departed assets and the views that they removed, with
announce_ep_departures. - When
epcholds a row orcvvholds a search, solve the whole set one time throughep_cvar_views_solve!intow1, and refitprunderw1. Understrict = false, every row of every family can drop, and the view set then states no view. Thenw1isw0,kldis zero, and no refit runs. - Calculate the effective number of scenarios
ens, the exponential of the entropy ofw1. Calculatekld, the Kullback-Leibler divergence ofw1fromw0. - Return a
LowOrderPriorthat holds the moments of the refit,w1,ensandkld. The factor blockfprcomes from that refit with no change.
Arguments
alg: Single-shot entropy pooling algorithm, whichpriorreads frompe.alg.pe: Entropy pooling prior estimator.X: Asset returns matrix, with one observation in each row, aspriororients it.F: Optional factor returns matrix, with one observation in each row, aspriororients it.pnl: OptionalAssetPanel, 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.strict: Iftrue, raise an error for an asset that the universe does not hold. Iffalse, warn.kwargs...: More keyword arguments, which go to the wrapped prior estimator.
Validation
- If a view field is not
nothing,pe.setsmust not benothing. - If the caller gives prior weights
pe.w,length(pe.w) == size(pr.X, 1)must hold, wheresize(pr.X, 1)is the number of observations that the wrapped estimator returns. A different length raises aDimensionMismatch. The message names that number, the number of observations that the estimator got, and the rule. - Every view equation has a comparison operator that its family accepts. An unsupported operator raises a
Meta.ParseErrorthat names the operators of that family.
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 refit.
Related
PortfolioOptimisers.show_fields — Method
show_fields(
_::MeucciEntropyPoolingPrior
) -> NTuple{17, Symbol}
Give every field of a MeucciEntropyPoolingPrior to print, except cache.
The state in cache changes at each step of an incremental fit, and it is not part of the configuration. Each site that prints the estimator also prints this state, unless this method leaves it out. Set set_show_nothing_fields!(:MeucciEntropyPoolingPrior, true) to print it.
Arguments
::MeucciEntropyPoolingPrior: Prior estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:pe, :mu_views, :var_views, :cvar_views, :sigma_views, :sk_views, :kt_views, :cov_views, :rho_views, :sets, :ds_opt, :dm_opt, :opt, :diagnose, :w, :alg, :x_src).
Related
References
- [159]
- A. Meucci, D. Ardia and S. Keel. Fully flexible extreme views. The Journal of Risk 14, 39–49 (2011).