Skip to content
13

Empirical Prior

PortfolioOptimisers.EmpiricalPrior Type
julia
struct EmpiricalPrior{__T_ce, __T_me, __T_horizon} <: AbstractLowOrderPriorEstimator_A

Empirical prior estimator for asset returns.

EmpiricalPrior is a low order prior estimator that computes the mean and covariance of asset returns using empirical (sample-based) statistics. It supports custom expected returns and covariance estimators, as well as an optional investment horizon for log-normalisation and scaling.

Fields

  • ce: Covariance estimator.

  • me: Expected returns estimator.

  • horizon: Optional investment horizon for log-normalising returns. If nothing, returns are not adjusted.

Constructors

julia
EmpiricalPrior(;
    ce::StatsBase.CovarianceEstimator = PortfolioOptimisersCovariance(),
    me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns(),
    horizon::Option{<:Number} = nothing
) -> EmpiricalPrior

Keywords correspond to the struct's fields.

Validation

  • If horizon is not nothing, horizon > 0.

Examples

julia
julia> EmpiricalPrior()
EmpiricalPrior
       ce ┼ PortfolioOptimisersCovariance
          │   ce ┼ Covariance
          │      │    me ┼ SimpleExpectedReturns
          │      │       │   w ┴ nothing
          │      │    ce ┼ GeneralCovariance
          │      │       │   ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
          │      │       │    w ┴ nothing
          │      │   alg ┴ Full()
          │   mp ┼ MatrixProcessing
          │      │     pdm ┼ Posdef
          │      │         │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton
          │      │         │   kwargs ┴ @NamedTuple{}: NamedTuple()
          │      │      dn ┼ nothing
          │      │      dt ┼ nothing
          │      │     alg ┼ nothing
          │      │   order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)
       me ┼ SimpleExpectedReturns
          │   w ┴ nothing
  horizon ┴ nothing

Related

source
PortfolioOptimisers.factory Method
julia
factory(
    pe::EmpiricalPrior,
    w::Union{DynamicAbstractWeights, AbstractWeights}
) -> Union{EmpiricalPrior{<:CovarianceEstimator, <:AbstractExpectedReturnsEstimator, Nothing}, EmpiricalPrior{<:CovarianceEstimator, <:AbstractExpectedReturnsEstimator, <:Number}}

Return a new EmpiricalPrior estimator with observation weights w applied to the underlying covariance and expected returns estimators.

Related

source
PortfolioOptimisers.prior Method
julia
prior(pe::EmpiricalPrior{<:Any, <:Any, Nothing}, X::MatNum, args...; dims::Int = 1,
      kwargs...)

Compute empirical prior moments for asset returns (no horizon adjustment).

prior estimates the mean and covariance of asset returns using the specified empirical prior estimator, without log-normalisation or scaling for investment horizon. The mean and covariance are computed using the estimators stored in pe, and returned in a LowOrderPrior result.

Mathematical definition

The empirical prior directly estimates first and second moments from the sample:

μ^=1Tt=1Txt,Σ^=1T1t=1T(xtμ^)(xtμ^).

Where:

  • μ^: N×1 sample mean vector.

  • Σ^: N×N sample covariance matrix.

  • xt: N×1 vector of asset returns at time t.

  • T: Number of observations.

Arguments

  • pe: Empirical prior estimator.

  • X: Asset returns matrix (observations × assets).

  • args...: Additional positional arguments (ignored).

  • dims: Dimension along which to perform the computation.

  • kwargs...: Additional keyword arguments passed to mean and covariance estimators.

Returns

  • pr::LowOrderPrior: Result object containing asset returns, mean vector, and covariance matrix.

Validation

  • dims in (1, 2).

Related

source
PortfolioOptimisers.prior Method
julia
prior(pe::EmpiricalPrior{<:Any, <:Any, <:Number}, X::MatNum, args...; dims::Int = 1,
      kwargs...)

Compute empirical prior moments for asset returns with investment horizon adjustment.

prior estimates the mean and covariance of asset returns using the specified empirical prior estimator, applying log-normalisation and scaling for the investment horizon. The asset returns are log-transformed, moments are computed using the estimators stored in pe, and then rescaled according to the investment horizon. The final mean and covariance are transformed back to arithmetic returns and returned in a LowOrderPrior result.

Mathematical definition

Log-returns are computed and scaled by the investment horizon h, then converted back to arithmetic returns:

μ~=hμ^log,Σ~=hΣ^log.μ^i=exp(μ~i+12σ~ii)1,σ^ij=(μ^i+1)(μ^j+1)(exp(σ~ij)1).

Where:

  • μ~, Σ~: Horizon-scaled log-return mean and covariance.

  • h: Investment horizon.

  • μ^log, Σ^log: Sample mean and covariance of log-returns log(1+xt).

  • μ^i: Arithmetic mean return for asset i.

  • σ^ij: Arithmetic covariance between assets i and j.

Arguments

  • pe: Empirical prior estimator.

  • X: Asset returns matrix (observations × assets).

  • args...: Additional positional arguments (ignored).

  • dims: Dimension along which to perform the computation.

  • kwargs...: Additional keyword arguments passed to mean and covariance estimators.

Returns

  • pr::LowOrderPrior: Result object containing asset returns, mean vector, and covariance matrix.

Validation

  • dims in (1, 2).

Related

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(
    pe::EmpiricalPrior,
    i,
    args...
) -> Union{EmpiricalPrior{<:CovarianceEstimator, <:AbstractExpectedReturnsEstimator, Nothing}, EmpiricalPrior{<:CovarianceEstimator, <:AbstractExpectedReturnsEstimator, <:Number}}

Return a new EmpiricalPrior estimator restricted to the assets at index i.

Related

source