L1 uncertainty sets
PortfolioOptimisers.L1UncertaintySet — Type
struct L1UncertaintySet{__T_eps, __T_sd, __T_mu} <: AbstractUncertaintySetResult$\ell_1$ uncertainty set on the characteristic vector, a cross-polytope around the estimate.
The set is $\mathcal{S} = \{\hat{\boldsymbol{\mu}} + \boldsymbol{\sigma} \odot \boldsymbol{u} : \lVert \boldsymbol{u} \rVert_1 \leq \epsilon\}$. One error budget covers every asset and both signs. CharacteristicUncertaintySet fits the set, and ArithmeticReturn reads it. The set bounds a characteristic vector, such as the mean, and it has no covariance analogue.
When every $\sigma_i > 0$, the set is $\{\hat{\boldsymbol{\mu}} + \boldsymbol{e} : \lVert \boldsymbol{e} \oslash \boldsymbol{\sigma} \rVert_1 \leq \epsilon\}$, the form of [8]. The form above also admits $\sigma_i = 0$, which fixes the entry $i$ at its estimate. It is the NormBallUncertaintySet with the map $\mathrm{diag}(\boldsymbol{\sigma})$, the order $p = 1$ and the radius $\epsilon$. A zero scale is the zero row of that map, and expand_investable_ucs writes it outside the Investable Mask.
Mathematical definition
The worst case of a linear characteristic over the set is the estimate less a scaled infinity norm. Lemmas 1 and 8 of [8] state it:
\[\underset{\boldsymbol{\mu} \in \mathcal{S}}{\min}\, \boldsymbol{\mu}^{\intercal} \boldsymbol{w} = \hat{\boldsymbol{\mu}}^{\intercal} \boldsymbol{w} - \epsilon \lVert \boldsymbol{\sigma} \odot \boldsymbol{w} \rVert_{\infty}\,.\]
Where:
- $\hat{\boldsymbol{\mu}}$: Estimated characteristic vector.
- $\epsilon$: Radius of the set.
- $\boldsymbol{\sigma}$: Scaling of each asset, the
sdfield. It is $\boldsymbol{1}$ whensdisnothing. - $\boldsymbol{u}$: Scaled estimation error.
- $\odot$, $\oslash$: Element-wise product and division.
The right-hand side is concave in $\boldsymbol{w}$. With an epigraph variable for the infinity norm, the worst case is a set of linear constraints, and the problem needs no conic solver. The equality holds for every $\boldsymbol{\sigma} \geq \boldsymbol{0}$, because the minimum of $\boldsymbol{u}^{\intercal} (\boldsymbol{\sigma} \odot \boldsymbol{w})$ over the $\ell_1$ ball of radius $\epsilon$ is $-\epsilon \lVert \boldsymbol{\sigma} \odot \boldsymbol{w} \rVert_{\infty}$.
Fields
eps: Radius of the $\ell_1$ uncertainty set on the characteristic vector. A larger radius admits more estimation error, and it activates more assets.
sd: Scaling of each asset in the $\ell_1$ uncertainty set, the estimated standard deviations. Withnothing, the set has no scaling, and it gives the same estimation error to every entry of the characteristic vector.
mu: Characteristic vector at the centre of the $\ell_1$ set. Withnothing, the consumer uses its own characteristic vector. A vector here replaces the characteristic of the returns estimator and the mean of the prior.
Constructors
L1UncertaintySet(; eps::Number, sd::Option{<:VecNum} = nothing, mu::Option{<:VecNum} = nothing) -> L1UncertaintySetKeywords correspond to the struct's fields.
Validation
isfinite(eps)andeps >= 0.- If
sdis notnothing:!isempty(sd),all(isfinite, sd)andall(sd .>= 0). A zero scale fixes its entry at the estimate. - If
muis notnothing:!isempty(mu)and!any(isinf, mu). ANaNmarks an asset outside the Investable Mask, as in the centrevalof the other sets. - If
sdandmuare notnothing:length(mu) == length(sd).
Examples
julia> L1UncertaintySet(; eps = 0.1)L1UncertaintySet eps ┼ Float64: 0.1 sd ┼ nothing mu ┴ nothingRelated
SignedL1UncertaintySetCharacteristicUncertaintySet: the estimator that fits this set. It fits a set on the mean only, andsigma_ucsthrows anArgumentErroron it.L1UncertaintySetAlgorithmAbstractUncertaintySetResultmu_ucs: a set that it fits holds, inmu, the characteristic vector that the Radius Calibration read. The consumer then bounds that vector and no other.port_opt_view
References
- [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
PortfolioOptimisers.SignedL1UncertaintySet — Type
struct SignedL1UncertaintySet{__T_ep, __T_en, __T_sd, __T_mu} <: AbstractUncertaintySetResultSigned $\ell_1$ uncertainty set on the characteristic vector, with a separate error budget per sign.
The set is $\mathcal{A}_2 = \{\hat{\boldsymbol{\mu}} + \boldsymbol{\sigma} \odot \boldsymbol{u} : \boldsymbol{1}^{\intercal} [\boldsymbol{u}]_{+} \leq \epsilon_{+},\, -\boldsymbol{1}^{\intercal} [\boldsymbol{u}]_{-} \leq \epsilon_{-}\}$. When every $\sigma_i > 0$, $\boldsymbol{u} = \boldsymbol{e} \oslash \boldsymbol{\sigma}$, and the set is the set of [8]. A zero scale fixes its entry at the estimate, as in L1UncertaintySet, and the worst case below holds for every $\boldsymbol{\sigma} \geq \boldsymbol{0}$. It bounds a characteristic vector, such as the mean, and it has no covariance analogue. [8] uses the set to split the long-short problem into two independent problems, its Equations 27 and 28. Its Remark 12 joins the two solutions only when the two legs have disjoint supports. The worst case below keeps the long-short problem as one problem, so it needs no condition on the supports.
Mathematical definition
\[\underset{\boldsymbol{\mu} \in \mathcal{A}_2}{\min}\, \boldsymbol{\mu}^{\intercal} \boldsymbol{w} = \hat{\boldsymbol{\mu}}^{\intercal} \boldsymbol{w} - \epsilon_{+} \left[\underset{i}{\max}\, (-\sigma_i w_i)\right]_{+} - \epsilon_{-} \left[\underset{i}{\max}\, (\sigma_i w_i)\right]_{+}\,.\]
Where:
- $\epsilon_{+}$, $\epsilon_{-}$: Radii of the positive-error and the negative-error sides, the
epandenfields. - $[\cdot]_{+}$, $[\cdot]_{-}$: Element-wise positive and negative parts.
The worst case is concave. With one epigraph variable for each sign, it is a set of linear constraints.
With $\epsilon_{+} = \epsilon_{-} = \epsilon$, this set is not $\mathcal{S}$. Let $t_{+}$ and $t_{-}$ be the two positive parts above. The joint set has one budget for both signs, and its penalty is $\epsilon \max(t_{+}, t_{-})$. This set has one budget for each sign, and its penalty is $\epsilon_{+} t_{+} + \epsilon_{-} t_{-}$. The two worst cases agree only when all the entries of $\boldsymbol{w}$ have the same sign.
Fields
ep: Radius of the positive-error side of the signed $\ell_1$ uncertainty set.
en: Radius of the negative-error side of the signed $\ell_1$ uncertainty set.
sd: Scaling of each asset in the $\ell_1$ uncertainty set, the estimated standard deviations. Withnothing, the set has no scaling, and it gives the same estimation error to every entry of the characteristic vector.
mu: Characteristic vector at the centre of the $\ell_1$ set. Withnothing, the consumer uses its own characteristic vector. A vector here replaces the characteristic of the returns estimator and the mean of the prior.
Constructors
SignedL1UncertaintySet(; ep::Number, en::Number, sd::Option{<:VecNum} = nothing, mu::Option{<:VecNum} = nothing) -> SignedL1UncertaintySetKeywords correspond to the struct's fields.
Validation
isfinite(ep)andep >= 0.isfinite(en)anden >= 0.- If
sdis notnothing:!isempty(sd),all(isfinite, sd)andall(sd .>= 0). A zero scale fixes its entry at the estimate. - If
muis notnothing:!isempty(mu)and!any(isinf, mu). ANaNmarks an asset outside the Investable Mask, as in the centrevalof the other sets. - If
sdandmuare notnothing:length(mu) == length(sd).
Examples
julia> SignedL1UncertaintySet(; ep = 0.1, en = 0.2)SignedL1UncertaintySet ep ┼ Float64: 0.1 en ┼ Float64: 0.2 sd ┼ nothing mu ┴ nothingRelated
L1UncertaintySet: the joint set. Under a long-only budget all the weights have the same sign, and the two worst cases agree. The joint set is then the simpler choice.SignedL1UncertaintySetAlgorithmCharacteristicUncertaintySet: the estimator that fits this set. It fits a set on the mean only, andsigma_ucsthrows anArgumentErroron it.mu_ucs: a set that it fits holds, inmu, the characteristic vector that the Radius Calibration of the two radii read. The consumer then bounds that vector and no other.AbstractUncertaintySetResultport_opt_view
References
- [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
PortfolioOptimisers.L1UncertaintySetAlgorithm — Type
struct L1UncertaintySetAlgorithm{__T_method, __T_scaled, __T_paired} <: AbstractUncertaintySetAlgorithmShape algorithm that selects the joint $\ell_1$ uncertainty set.
scaled selects one of two sets of [8]. false gives $\mathcal{S}$, Equation 5 of [8], and true gives $\mathcal{A}_1$, its Equation 18. The default is false, because $\mathcal{S}$ is the base set of [8]. Its closed forms give the $1/N$ portfolio and the quintile portfolio. The default of SignedL1UncertaintySetAlgorithm is true, because [8] defines the signed set only in the scaled form.
Fields
method: Radius of the $\ell_1$ uncertainty set. A number is the radius. AnAbstractUncertaintyEpsAlgorithmcomputes the radius from the data.
scaled: Iftrue, the estimated standard deviations scale the uncertainty set.falsegives the same estimation error to every entry of the characteristic vector.truegives a larger estimation error to an asset with a larger variance, and the active weights are then inverse-volatility weights.
paired:paired: Selects the closed form that calibrates the radius whenmethodis anAbstractUncertaintyEpsAlgorithm. The number of assets that a radius activates depends on the signs that the problem lets the weights take. An uncertainty set cannot read the problem, so the caller must state it.falseselects the long-only ladder, for a problem withw >= 0andbgt = 1, as in Corollaries 4 and 11 of [8].trueselects the paired ladder, for a dollar-neutral problem withbgt = 0andsbgt = 1/2. In that problem the assets become active in pairs of one long asset and one short asset, as in Corollary 7. The wrong value gives a wrong radius, but the optimisation stays correct.pairedhas no effect whenmethodis a number.
Constructors
L1UncertaintySetAlgorithm(; method::Num_UcSEps = ActiveAssetsUncertaintyAlgorithm(), scaled::Bool = false, paired::Bool = false) -> L1UncertaintySetAlgorithmKeywords correspond to the struct's fields.
Validation
- If
methodis aNumber:isfinite(method)andmethod >= 0.
Examples
julia> L1UncertaintySetAlgorithm()L1UncertaintySetAlgorithm method ┼ ActiveAssetsUncertaintyAlgorithm │ active ┼ FractionOf │ │ val ┴ Float64: 0.2 scaled ┼ Bool: false paired ┴ Bool: falseRelated
L1UncertaintySetSignedL1UncertaintySetAlgorithmActiveAssetsUncertaintyAlgorithmCharacteristicUncertaintySetAbstractUncertaintySetAlgorithml1_resolve_eps: the function that readsmethodandpairedand returns the radius.
References
- [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
PortfolioOptimisers.SignedL1UncertaintySetAlgorithm — Type
struct SignedL1UncertaintySetAlgorithm{__T_mp, __T_mm, __T_scaled} <: AbstractUncertaintySetAlgorithmShape algorithm that selects the signed $\ell_1$ uncertainty set.
The construction of [8] sets the two ladders, so this algorithm has no paired field. $\epsilon_{-}$ is the radius for the long leg, and its calibration reads the top of the ranking. $\epsilon_{+}$ is the radius for the short leg, and its calibration reads the bottom of the ranking. Corollary 13 of [8] states this. The default of scaled is true, because [8] defines $\mathcal{A}_2$ and states Corollary 13 only in the form scaled by volatility. The default of L1UncertaintySetAlgorithm is false, because its base set has no scaling.
Fields
mp: Radius of the positive-error side of the signed $\ell_1$ uncertainty set. A number is the radius. AnAbstractUncertaintyEpsAlgorithmcomputes the radius from the data.
mm: Radius of the negative-error side of the signed $\ell_1$ uncertainty set. A number is the radius. AnAbstractUncertaintyEpsAlgorithmcomputes the radius from the data.
scaled: Iftrue, the estimated standard deviations scale the uncertainty set.falsegives the same estimation error to every entry of the characteristic vector.truegives a larger estimation error to an asset with a larger variance, and the active weights are then inverse-volatility weights.
Constructors
SignedL1UncertaintySetAlgorithm(; mp::Num_UcSEps = ActiveAssetsUncertaintyAlgorithm(), mm::Num_UcSEps = ActiveAssetsUncertaintyAlgorithm(), scaled::Bool = true) -> SignedL1UncertaintySetAlgorithmKeywords correspond to the struct's fields.
Validation
- If
mpis aNumber:isfinite(mp)andmp >= 0. - If
mmis aNumber:isfinite(mm)andmm >= 0.
Examples
julia> SignedL1UncertaintySetAlgorithm()SignedL1UncertaintySetAlgorithm mp ┼ ActiveAssetsUncertaintyAlgorithm │ active ┼ FractionOf │ │ val ┴ Float64: 0.2 mm ┼ ActiveAssetsUncertaintyAlgorithm │ active ┼ FractionOf │ │ val ┴ Float64: 0.2 scaled ┴ Bool: trueRelated
SignedL1UncertaintySetL1UncertaintySetAlgorithmActiveAssetsUncertaintyAlgorithmCharacteristicUncertaintySetAbstractUncertaintySetAlgorithml1_resolve_eps: the function that readsmpandmmand returns each radius.
References
- [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
PortfolioOptimisers.CharacteristicUncertaintySet — Type
struct CharacteristicUncertaintySet{__T_pe, __T_alg} <: AbstractUncertaintySetEstimatorFits an $\ell_1$ uncertainty set with a calibrated radius on the characteristic vector, for the mean only.
pe gives the characteristic vector $\hat{\boldsymbol{\mu}}$. When the shape algorithm is scaled, it also gives the scaling of each asset, $\hat{\boldsymbol{\sigma}} = \sqrt{\mathrm{diag}(\hat{\mathbf{\Sigma}})}$. The sets are the robust sets of [8] for the best characteristic. The maximum of the worst-case characteristic over one of these sets is a robust optimisation problem. Its exact solutions are the $1/N$ portfolio, the quintile portfolio and the inverse-volatility portfolio, and the radius sets the number of assets held. For this reason the library has no separate quintile optimiser. Use the set in MeanRisk:
MeanRisk(; r = NoRisk(), obj = MaximumReturn(), opt = JuMPOptimiser(; slv = slv, bgt = 1.0, ret = ArithmeticReturn(; ucs = CharacteristicUncertaintySet())))Fields
pe: Prior estimator that the set fits on the returns data, ornothing. Withnothing, the set holds no prior of its own, and it fits on the Prior Result that the caller gives, through the prior-result method of the ucs Triple. Inside an optimiser, that result is the prior that the optimiser solves on, so the set and the objective have the same centre. Withnothing, the returns-data method raises anArgumentError. The default,EmpiricalPrior(), fits an empirical prior on the returns.
alg:alg: Shape algorithm, anL1UncertaintySetAlgorithmor aSignedL1UncertaintySetAlgorithm.
Constructors
CharacteristicUncertaintySet(; pe::Option{<:AbstractLowOrderPriorEstimator} = EmpiricalPrior(), alg::AbstractUncertaintySetAlgorithm = L1UncertaintySetAlgorithm()) -> CharacteristicUncertaintySetKeywords correspond to the struct's fields.
Validation
algmust be anL1UncertaintySetAlgorithmor aSignedL1UncertaintySetAlgorithm.ucsandsigma_ucsalways throw anArgumentErroron this estimator. The $\ell_1$ ball bounds a characteristic vector, and [8] defines no covariance analogue. So neither function has a covariance set to return.
Examples
The estimator calibrates the radius. Three assets with the sample means $0.125$, $0.0625$ and $0.03125$ give the Activation Ladder $[0, 0.0625, 0.125]$. The default active of 0.2 gives a target of one active asset, so the radius is the midpoint of the first and second rungs:
julia> X = [0.1875 0.09375 0.0625 0.0625 0.03125 0.0];julia> mu_ucs(CharacteristicUncertaintySet(), X)L1UncertaintySet eps ┼ Float64: 0.03125 sd ┼ nothing mu ┴ Vector{Float64}: [0.125, 0.0625, 0.03125]Related
L1UncertaintySetSignedL1UncertaintySetL1UncertaintySetAlgorithmSignedL1UncertaintySetAlgorithmActiveAssetsUncertaintyAlgorithmmu_ucs: the only verb of the ucs Triple that returns a set for this estimator.StandardDeviationExpectedReturns: the characteristic does not have to be an expected return. A prior that uses this estimator ranks the assets by volatility, with the highest volatility first. Section VI-C of [8] puts the lowest volatility first, for the Low Volatility factor of its Table III. That ranking needs the negative of the volatility as the characteristic.AbstractUncertaintySetEstimator
References
- [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
PortfolioOptimisers.ActiveAssetsUncertaintyAlgorithm — Type
struct ActiveAssetsUncertaintyAlgorithm{__T_active} <: AbstractUncertaintyEpsAlgorithmCalibrates the radius of an $\ell_1$ uncertainty set to a target number of active assets.
The radius $\epsilon$ of an $\ell_1$ uncertainty set has no natural scale. It is a sum of differences of the characteristic. On daily returns it is of order $10^{-3}$, and on annualised returns it is about $250$ times larger. A caller can state a number of assets to hold more easily than a radius. This algorithm finds the radius that activates that number of assets, from the inverse of the closed forms of [8]. The inverse is exact only for the problem of those closed forms, which has the budget and sign constraints and no other constraint.
Fields
active: Target number of active assets. ACountOfis a number of assets, and aFractionOfis a fraction of the universe, rounded to the nearest asset. A plain number is read throughcount_or_fraction. The value selects the radius that activates this number of assets when the problem has only the budget and sign constraints. It is a Radius Calibration, not a cardinality constraint, and a different constraint can change the number of active assets. Usecardfor a hard cardinality constraint.
Constructors
ActiveAssetsUncertaintyAlgorithm(; active::Real_CountFraction = FractionOf(0.2)) -> ActiveAssetsUncertaintyAlgorithmKeywords correspond to the struct's fields. active is a CountOf of assets or a FractionOf of the universe. A plain number is read through count_or_fraction.
Validation
activepassescount_or_fraction.
A field that takes a CountOf or a FractionOf also takes a plain number, and count_or_fraction reads an Integer as a count and any other real number as a fraction. Julia promotes the elements of a vector literal to one type before the library reads them. So ["opt.ret.ucs.alg.method.active" => [3, 5, 8], "r.alpha" => [0.05, 0.1]] is a Vector{Pair{String, Vector{Float64}}}, and the counts arrive as 3.0, 5.0 and 8.0. The field then reads them as fractions, and the check of FractionOf refuses them. State the grid in the wrappers, such as [CountOf(3), CountOf(5), FractionOf(0.2)]. A wrapper keeps its type in every container.
Examples
julia> ActiveAssetsUncertaintyAlgorithm()ActiveAssetsUncertaintyAlgorithm active ┼ FractionOf │ val ┴ Float64: 0.2julia> ActiveAssetsUncertaintyAlgorithm(; active = CountOf(3)).activeCountOf val ┴ Int64: 3Related
AbstractUncertaintyEpsAlgorithmL1UncertaintySetAlgorithmSignedL1UncertaintySetAlgorithmCharacteristicUncertaintySetl1_resolve_eps: the function that reads this algorithm and returns the radius.JuMPOptimiser: itscardfield sets a hard limit on the number of assets held. A weight bound, a cardinality constraint or a linear constraint can make the number of active assets differ from the target of this algorithm. This algorithm does not check the number.
References
- [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
PortfolioOptimisers.port_opt_view — Method
port_opt_view(
risk_ucs::L1UncertaintySet,
i,
args...
) -> L1UncertaintySet
Return a view of an L1UncertaintySet restricted to the asset indices i.
The radius is one scalar budget for the universe, and the view keeps it unchanged. The view takes the entries of sd and mu at i, in the order of i. The restricted set then indexes the assets in the order that the optimiser gives.
Algorithm
- Take
nothing_scalar_array_view(risk_ucs.sd, i), the scaling of the selected assets. Anothingstaysnothing. - Take
nothing_scalar_array_view(risk_ucs.mu, i), the characteristic vector of the same assets. Anothingstaysnothing. - Build an
L1UncertaintySetfromrisk_ucs.epsand the two views. The step does not rescale the radius, because the radius is the budget for the total error over the assets that the set covers.
Arguments
risk_ucs: $\ell_1$ uncertainty set.i: Index of the cluster or of the assets.args...: More positional arguments, which the method ignores.
Returns
risk_ucs::L1UncertaintySet: The set restricted toi.
Examples
julia> ucs = L1UncertaintySet(; eps = 0.5, sd = [0.1, 0.2, 0.3], mu = [0.05, 0.03, 0.01]);julia> PortfolioOptimisers.port_opt_view(ucs, [1, 3])L1UncertaintySet eps ┼ Float64: 0.5 sd ┼ SubArray{Float64, 1, Vector{Float64}, Tuple{Vector{Int64}}, false}: [0.1, 0.3] mu ┴ SubArray{Float64, 1, Vector{Float64}, Tuple{Vector{Int64}}, false}: [0.05, 0.01]Related
PortfolioOptimisers.port_opt_view — Method
port_opt_view(
risk_ucs::SignedL1UncertaintySet,
i,
args...
) -> SignedL1UncertaintySet
Return a view of a SignedL1UncertaintySet restricted to the asset indices i.
The two radii are scalar budgets for the universe, and the view keeps them unchanged. The view takes the entries of sd and mu at i, in the order of i. The restricted set then indexes the assets in the order that the optimiser gives.
Algorithm
- Take
nothing_scalar_array_view(risk_ucs.sd, i), the scaling of the selected assets. Anothingstaysnothing. - Take
nothing_scalar_array_view(risk_ucs.mu, i), the characteristic vector of the same assets. Anothingstaysnothing. - Rebuild the set from the two views with
rebuild_struct.risk_ucs.epandrisk_ucs.endo not change. The step rescales neither radius, because each radius is the budget for the total error of its sign over the assets that the set covers.
Arguments
risk_ucs: Signed $\ell_1$ uncertainty set.i: Index of the cluster or of the assets.args...: More positional arguments, which the method ignores.
Returns
risk_ucs::SignedL1UncertaintySet: The set restricted toi.
Examples
julia> ucs = SignedL1UncertaintySet(; ep = 0.4, en = 0.6, sd = [0.1, 0.2, 0.3], mu = [0.05, 0.03, 0.01]);julia> PortfolioOptimisers.port_opt_view(ucs, [1, 3])SignedL1UncertaintySet ep ┼ Float64: 0.4 en ┼ Float64: 0.6 sd ┼ SubArray{Float64, 1, Vector{Float64}, Tuple{Vector{Int64}}, false}: [0.1, 0.3] mu ┴ SubArray{Float64, 1, Vector{Float64}, Tuple{Vector{Int64}}, false}: [0.05, 0.01]Related
PortfolioOptimisers.mu_ucs — Function
mu_ucs(ue::CharacteristicUncertaintySet, X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)
mu_ucs(ue::CharacteristicUncertaintySet{Nothing}, pr::AbstractPriorResult; rd = nothing, kwargs...)Fits an $\ell_1$ uncertainty set on the characteristic vector, from returns data or from a Prior Result.
The two signatures are the two routes of a set with a pe field, and the two routes end in the same steps. The returns-data method fits ue.pe once through ucs_prior, which throws an ArgumentError when ue.pe is nothing. The method then gives the Prior Result to the prior-result method of the same set with pe = nothing. That method selects the shape of the set by dispatch on alg.
The prior-result method has a definition only for a set whose pe is nothing. Inside an optimiser, pr is the prior that the optimiser solves on. So the Radius Calibration reads the same mu as the objective.
The calibration reads the ranking, but the set keeps the order of the universe. mu and sd have one entry for each asset, in the order of the prior. The optimiser indexes the assets in that order, and port_opt_view takes its view in that order. Only the ladders read the sorted vector. A ladder is a list of radii, and it holds no index of an asset. The set holds $\hat{\boldsymbol{\mu}}$ in its mu field, so the consumer bounds the characteristic vector that the calibration read.
Algorithm
The returns-data method does step 1, and then it calls the prior-result method. The two prior-result methods do steps 2 to 5 and step 7 in the same way, and they do step 6 differently.
- Fit the prior
prwithucs_prioronue.pe,XandF. Call the prior-result method of the set withpe = nothing. - Reduce the Prior Result
prto the Investable Mask withinvestable_ucs_reductionto getprr. Inside an optimiser,pris already reduced, and the step changes nothing. Outside an optimiser, on a prior fitted on a point-in-time Asset Panel, the step makes the reduction that an optimiser makes. The ranking then reads noNaN. - Read
alg = ue.alg, the shape algorithm. - If
alg.scaledistrue, takesd = sqrt.(diag(prr.sigma)), the scaling of each asset. Else, takesd = nothing. - Take
idx = sortperm(prr.mu; rev = true), the ranking that sorts the characteristic in non-increasing order. Apply it toprr.muand tosd. - Find the radii with
l1_resolve_epson the sorted vectors. Build the set from the radii, withmu = prr.muandsdin the order of the universe. - Write the set back onto the full universe with
expand_investable_ucs, and return it. A set fitted outside an optimiser then covers the same assets as the prior. A view of the set at the mask gives the reduced fit again.
For an L1UncertaintySetAlgorithm, step 6 finds the radius eps from alg.method and alg.paired, and builds an L1UncertaintySet.
For a SignedL1UncertaintySetAlgorithm, step 6 finds two radii on two ladders, and builds a SignedL1UncertaintySet. en comes from alg.mm on the sorted ranking. ep comes from alg.mp on the reversed, negated ranking, which is the bottom of the same ranking. Corollary 13 of [8] states this construction. Both calls pass paired = false, because the construction sets both ladders. The consumer multiplies en by $[\max_i (\sigma_i w_i)]_{+}$, and ep by $[\max_i (-\sigma_i w_i)]_{+}$. So en is the radius for the long leg and ep is the radius for the short leg, and each leg matches the end of the ranking that its calibration read.
Arguments
ue: Characteristic uncertainty set estimator.X: Data matrix, such as the returns.F: Factor matrix, ornothing. The prior estimator reads it.dims: Dimension along which the computation runs.pr: Prior Result for the calibration. The method readspr.muat the Investable Mask, andpr.sigmathere whenalg.scaledistrue.rd: Returns Result that the three-argument form gives with the prior. The method reduces it with the prior, and does not read it.kwargs...: More keyword arguments, which the returns-data method gives to the prior estimator. The prior-result method ignores them.
Returns
mu_ucs::Union{L1UncertaintySet, SignedL1UncertaintySet}: The uncertainty set, on the full asset universe ofpr.
Examples
julia> X = [0.1875 0.09375 0.0625 0.0625 0.03125 0.0];julia> alg = SignedL1UncertaintySetAlgorithm(; scaled = false);julia> mu_ucs(CharacteristicUncertaintySet(; alg = alg), X)SignedL1UncertaintySet ep ┼ Float64: 0.015625 en ┼ Float64: 0.03125 sd ┼ nothing mu ┴ Vector{Float64}: [0.125, 0.0625, 0.03125]Related
CharacteristicUncertaintySetL1UncertaintySetSignedL1UncertaintySetl1_resolve_epsucs_priorport_opt_view
References
- [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
PortfolioOptimisers.ucs — Function
ucs(ue::CharacteristicUncertaintySet, X::MatNum, F::Option{<:MatNum} = nothing; kwargs...)
sigma_ucs(ue::CharacteristicUncertaintySet, X::MatNum, F::Option{<:MatNum} = nothing; kwargs...)
ucs(ue::CharacteristicUncertaintySet{Nothing}, pr::AbstractPriorResult; kwargs...)
sigma_ucs(ue::CharacteristicUncertaintySet{Nothing}, pr::AbstractPriorResult; kwargs...)Always throw an ArgumentError. CharacteristicUncertaintySet fits a set on the mean only.
The four methods have no procedure, so they have no # Algorithm section. The returns-data pair has the same (X, F) signature as the other families, not a catch-all signature. So the ReturnsResult methods of the base reach these methods with no ambiguity. The prior-result pair has the prior-result signature of the other families. So a set with no prior of its own reaches the same error through the three-argument route.
Arguments
ue: Characteristic uncertainty set estimator.X: Data matrix, such as the returns. The methods ignore it.F: Factor matrix, ornothing. The methods ignore it.pr: Prior Result, which the methods ignore.kwargs...: More keyword arguments, which the methods ignore.
Validation
- All four methods always throw an
ArgumentError. The $\ell_1$ set bounds a characteristic vector, such as the mean, and [8] defines no covariance analogue. So the methods have no covariance set to return. Each message namesNormalUncertaintySet,DeltaUncertaintySetandARCHUncertaintySetfor a covariance set. The message ofucsalso namesmu_ucsfor the mean set.
Returns
- No method returns. Each method throws.
Related
References
- [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
PortfolioOptimisers.l1_resolve_eps — Function
l1_resolve_eps(method, mus::VecNum, sds::Option{<:VecNum}, paired::Bool)Find the radius of a Num_UcSEps on the characteristic vector.
mus must be sorted in non-increasing order, and sds must have the same permutation. The method that takes a Number returns the radius that the caller gave. It has no procedure, so the # Algorithm and # Validation sections are not about it. The method that takes an ActiveAssetsUncertaintyAlgorithm calibrates the radius on the long-only ladder when paired is false, and on the paired ladder when paired is true.
Mathematical definition
The paired ladder is the sum of the ladder of the ranking and the ladder of the reversed, negated ranking. With $\sigma_i = 1$ it is the threshold of Lemma 6 of [8]. The scaled form adds the two scaled ladders of Corollary 13 of [8], which states them for two radii on $\mathcal{A}_2$. [8] states no lemma for one radius on the scaled set. So the scaled form is an extension of this library, and no lemma proves the number of active assets that it gives:
\[\begin{align} F_m &= \sum_{i=1}^{m} \frac{\hat{\mu}_i - \hat{\mu}_m}{\sigma_i} + \sum_{j=1}^{m} \frac{\hat{\mu}_{N-m+1} - \hat{\mu}_{N-j+1}}{\sigma_{N-j+1}}\,, \quad m = 1,\, \ldots,\, \left\lfloor N/2 \right\rfloor\,. \end{align}\]
Where:
- $F_m$: Activation threshold of the $m$-th pair of one long asset and one short asset.
- $\hat{\mu}_i$: $i$-th entry of the characteristic vector, sorted non-increasing.
- $\sigma_i$: Scale factor of the $i$-th entry of the characteristic vector. It is $1$ when the set has no scaling.
- $N$: Number of assets.
A radius in $(F_q,\, F_{q+1})$ makes the top $q$ assets long and the bottom $q$ assets short, so it activates $2q$ assets. Corollary 7 states this with $\sigma_i = 1$. Lemma 5, also with $\sigma_i = 1$, gives the reason that the ladder stops at $\lfloor N/2 \rfloor$. An optimal dollar-neutral solution satisfies $w_i = -w_{N+1-i}$. With an odd $N$, the middle asset is its own pair, so its weight satisfies $w = -w$ and the asset is never active. The largest count that the paired branch can reach is $2 \lfloor N/2 \rfloor$, which is $N-1$ when $N$ is odd.
Algorithm
- Check
musandsds, as# Validationstates. - Read
N = length(mus), the size of the universe. - If
pairedisfalse, build the long-only ladder withl1_activation_ladder, and convertmethod.activeto a count withl1_active_count. Return the radius thatl1_eps_from_ladderfinds from the ladder and the count. - Else, read
half = N ÷ 2, the number of pairs that the universe has. - Add the ladder of
musto the ladder of the reversed, negated ranking. Keep the firsthalfentries asladder, the paired ladder. - Convert the target to a number of pairs with
l1_active_pairs. - Return the radius that
l1_eps_from_ladderfinds fromladderand the number of pairs.
Arguments
method: A radius as aNumber, or anActiveAssetsUncertaintyAlgorithm.mus: Characteristic vector, sorted in non-increasing order.sds: Scaling of each asset in the same permutation, ornothing.paired: Iftrue, the calibration reads the paired ladder. Iffalse, it reads the long-only ladder.
Validation
all(isfinite, mus). Else, the method throws anIsNonFiniteError. ANaNentry makes every rung that reads itNaN, and the tie check ofl1_eps_from_ladderthen names the wrong cause. A prior fitted on a point-in-time Asset Panel hasNaNoutside its Investable Mask, andmu_ucsreduces it to the mask before the calibration.- If
sdsis notnothing: every entry is finite and> 0. Else, the method throws aDomainError. The ladder divides by each entry. A set can hold a zero scale, but the closed form of the radius cannot read one. N ÷ 2 >= 1whenpairedistrue. Else, the method throws anArgumentError. One asset cannot make a pair of a long asset and a short asset, so it has no paired ladder.
Returns
eps::Number: The radius.
Examples
julia> PortfolioOptimisers.l1_resolve_eps(0.25)0.25julia> alg = ActiveAssetsUncertaintyAlgorithm(; active = 2);julia> mus = [0.125, 0.0625, 0.03125, 0.0];julia> PortfolioOptimisers.l1_resolve_eps(alg, mus, nothing, false)0.09375julia> PortfolioOptimisers.l1_resolve_eps(alg, mus, nothing, true)0.046875Related
l1_activation_ladderl1_active_countl1_eps_from_ladderL1UncertaintySetAlgorithmSignedL1UncertaintySetAlgorithm
References
- [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
References
- [8]
- R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).