Shrunk Expected Returns: private API

PortfolioOptimisers.AbstractShrunkExpectedReturnsAlgorithmType
abstract type AbstractShrunkExpectedReturnsAlgorithm <: AbstractExpectedReturnsAlgorithm

Abstract supertype for all shrinkage algorithms for expected returns estimation.

All concrete and/or abstract types implementing specific shrinkage algorithms (e.g., James-Stein, Bayes-Stein) should be subtypes of AbstractShrunkExpectedReturnsAlgorithm.

Related

References

  • [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 3.4.1.
source
PortfolioOptimisers.AbstractShrunkExpectedReturnsTargetType
abstract type AbstractShrunkExpectedReturnsTarget <: AbstractExpectedReturnsAlgorithm

Abstract supertype for all shrinkage targets used in expected returns estimation.

Concrete types implementing specific shrinkage targets (e.g., grand mean, volatility-weighted mean) should subtype AbstractShrunkExpectedReturnsTarget.

Related

References

  • [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Equation 3.43.
  • [25] A. Meucci. Risk and Asset Allocation (Springer Berlin Heidelberg, 2005).
  • [26] Y. Feng and D. P. Palomar. A signal processing perspective of financial engineering. Foundations and Trends in Signal Processing 9, 1–231 (2016).
source
PortfolioOptimisers.target_meanFunction
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::Integer,
    kwargs...
) -> StepRangeLen

Compute the shrinkage target vector for expected returns estimation.

target_mean is the single owner of the three shrinkage targets. JamesStein, BayesStein and BodnarOkhrinParolya all reach it, so each target is written once.

Every element of the returned vector holds the same value, so the function returns a StepRangeLen rather than a dense vector.

Algorithm

The method that Julia selects is the algorithm, and the closed form of each branch lives on the tag that selects it. Every branch ends the same way: it computes one scalar val and returns range(val, val; length = length(mu)), a constant range rather than a dense vector.

  1. tgt is a GrandMean: take the unweighted mean of mu. It reads neither sigma nor isigma nor T.
  2. tgt is a VolatilityWeighted: solve for isigma when the caller passed none, flatten mu when it has one row, then divide the sum of isigma * mu by the sum of isigma.
  3. tgt is a MeanSquaredError: divide the trace of sigma by the keyword T. It reads neither mu nor isigma, so only the length of mu reaches the result.

Each branch takes the arguments the other two do not need through args... and kwargs..., so one call site serves all three.

Arguments

  • tgt: The shrinkage target type.

    • tgt::GrandMean: Fills the vector with the mean of mu.
    • tgt::VolatilityWeighted: Fills the vector with the inverse-covariance-weighted mean of mu.
    • tgt::MeanSquaredError: Fills the vector with the trace of sigma divided by T.
  • mu: 1D array of expected returns.

  • sigma: Covariance matrix assets × assets.

  • isigma: Inverse covariance matrix, taken positionally by the VolatilityWeighted method. If nothing, the method computes sigma \ LinearAlgebra.I itself. The other two methods swallow it in args....

  • T: Number of observations. It is a required keyword of the MeanSquaredError method. The other two methods swallow it in kwargs....

  • kwargs...: Additional keyword arguments (ignored).

Returns

  • b::StepRangeLen: Target vector for shrinkage estimation, of length length(mu).

Related

References

  • [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Equation 3.43.
  • [25] A. Meucci. Risk and Asset Allocation (Springer Berlin Heidelberg, 2005).
  • [26] Y. Feng and D. P. Palomar. A signal processing perspective of financial engineering. Foundations and Trends in Signal Processing 9, 1–231 (2016).
source

References

[5]
D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
[25]
A. Meucci. Risk and Asset Allocation (Springer Berlin Heidelberg, 2005).
[26]
Y. Feng and D. P. Palomar. A signal processing perspective of financial engineering. Foundations and Trends in Signal Processing 9, 1–231 (2016).