Shrunk Expected Returns: private API
PortfolioOptimisers.AbstractShrunkExpectedReturnsEstimator — Type
abstract type AbstractShrunkExpectedReturnsEstimator <: AbstractExpectedReturnsEstimatorAbstract supertype for all shrunk expected returns estimators.
A subtype computes the sample expected returns and moves them toward a shrinkage target.
Related
PortfolioOptimisers.AbstractShrunkExpectedReturnsAlgorithm — Type
abstract type AbstractShrunkExpectedReturnsAlgorithm <: AbstractExpectedReturnsAlgorithmAbstract supertype for all shrinkage algorithms for expected returns estimation.
A subtype holds a shrinkage target and selects the formula that combines the sample expected returns with that target.
Related
PortfolioOptimisers.AbstractShrunkExpectedReturnsTarget — Type
abstract type AbstractShrunkExpectedReturnsTarget <: AbstractExpectedReturnsAlgorithmAbstract supertype for all shrinkage targets used in expected returns estimation.
A subtype selects a method of target_mean, which returns a vector whose entries all hold the same value.
Related
PortfolioOptimisers.target_mean — Function
target_mean(
tgt::GrandMean,
mu::ArrNum,
sigma::MatNum,
args...;
kwargs...
) -> StepRangeLen
target_mean(
tgt::VolatilityWeighted,
mu::ArrNum,
sigma::MatNum,
isigma::Option{<:MatNum} = nothing;
kwargs...
) -> StepRangeLen
target_mean(
tgt::MeanSquaredError,
mu::ArrNum,
sigma::MatNum,
args...;
T::Real,
kwargs...
) -> StepRangeLenCompute the shrinkage target vector for expected returns estimation.
JamesStein, BayesStein and BodnarOkhrinParolya all call target_mean, so the library computes each target in one place.
Every element of the returned vector holds the same value, so the function returns a StepRangeLen and not a dense vector.
Algorithm
Julia selects the method from the type of tgt. The docstring of each target type states the closed form of its method. Every method computes one scalar val and returns the constant range range(val, val; length = length(mu)).
- If
tgtis aGrandMean, take the unweighted mean ofmu. This method does not readsigma,isigmaorT. - If
tgtis aVolatilityWeighted, solve forisigmawhen the caller did not pass it. Flattenmuwhen it has one row. Then divide the sum ofisigma * muby the sum ofisigma. - If
tgtis aMeanSquaredError, divide the trace ofsigmaby the keywordT. This method does not read the values ofmuorisigma. It reads only the length ofmu.
Each method accepts, through args... and kwargs..., the arguments that only the other methods read. One call therefore works for all three targets.
Arguments
tgt: The shrinkage target type.tgt::GrandMean: Fills the vector with the mean ofmu.tgt::VolatilityWeighted: Fills the vector with the inverse-covariance-weighted mean ofmu.tgt::MeanSquaredError: Fills the vector with the trace ofsigmadivided byT.
mu: The array of the sample expected returns, a vector or a matrix with one row or one column.sigma: Covariance matrixassets × assets.isigma: The inverse covariance matrix. TheVolatilityWeightedmethod takes it as a positional argument. If it isnothing, that method computessigma \ LinearAlgebra.I. The other two methods accept it inargs...and do not read it.T: The effective number of observations of the sample mean, fromeffective_observation_count. TheMeanSquaredErrormethod needs it as a keyword. The other two methods accept it inkwargs...and do not read it.kwargs...: More keyword arguments. The function does not read them.
Returns
b::StepRangeLen: The shrinkage target vector, of lengthlength(mu).
Related
GrandMean: the closed form of the branch of step 1.VolatilityWeighted: the closed form of the branch of step 2.MeanSquaredError: the closed form of the branch of step 3.AbstractShrunkExpectedReturnsTargetShrunkExpectedReturnsArrNumMatNumOption
References
- [52] A. Meucci. Risk and Asset Allocation (Springer Berlin Heidelberg, 2005). Section 4.4, Equations 4.136, 4.141 and 4.142.
- [54] P. Jorion. Bayes-Stein estimation for portfolio analysis. The Journal of Financial and Quantitative Analysis 21, 279–292 (1986). Section IV, Equation 14.
- [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Equation 3.43. The original source of this formulation was not found. The formulation follows this work and is not checked against the original.
References
- [12]
- D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
- [52]
- A. Meucci. Risk and Asset Allocation (Springer Berlin Heidelberg, 2005).
- [54]
- P. Jorion. Bayes-Stein estimation for portfolio analysis. The Journal of Financial and Quantitative Analysis 21, 279–292 (1986).