Skip to content
18

Median expected returns

PortfolioOptimisers.MedianExpectedReturns Type
julia
struct MedianExpectedReturns{__T_w} <: AbstractExpectedReturnsEstimator

Expected returns estimator that returns the optionally weighted asset medians.

Fields

  • w: Optional observation weights vector observations × 1, or a concrete subtype of DynamicAbstractWeights. If nothing, the computation is unweighted.

Constructors

julia
MedianExpectedReturns(;
    w::Option{<:ObsWeights} = nothing
) -> MedianExpectedReturns

Keywords correspond to the struct's fields.

Examples

julia
julia> me = MedianExpectedReturns()
MedianExpectedReturns
  w ┴ nothing

julia> factory(me, StatsBase.Weights([0.1, 0.2, 0.7]))
MedianExpectedReturns
  w ┴ StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.1, 0.2, 0.7]

Related

source
Statistics.mean Method
julia
Statistics.mean(me::MedianExpectedReturns, X::MatNum;
                dims::Int = 1, kwargs...)

Compute expected returns as the median of each asset.

This method returns the median of each asset across observations in X. If me.w is nothing, the median is computed directly with Statistics.median(X; dims = dims). Otherwise, the method computes a weighted median for each asset using the observation weights w.

Mathematical definition

μ^j=median(r1j,r2j,,rTj).

Where:

  • μ^j: Median expected return of asset j.

  • rtj: Return of asset j at time t.

  • T: Number of observations.

Arguments

  • me: Median expected returns estimator.

  • X: Data matrix of asset returns (observations × assets).

  • dims: Dimension along which to perform the computation.

  • kwargs: Additional keyword arguments (ignored).

Returns

  • mu::Matrix{<:Number}: Median vector, shaped as (1, N) if dims == 1 or (N, 1) if dims == 2.

Related

source
Statistics.mean Method
julia
mean(
    me::MedianExpectedReturns{<:Union{var"#s30", var"#s29"} where {var"#s30"<:DynamicAbstractWeights, var"#s29"<:AbstractWeights}},
    X::AbstractMatrix{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}};
    dims,
    kwargs...
) -> Any

Weighted-median overload of mean(me::MedianExpectedReturns, X::MatNum; dims::Int = 1, kwargs...). Computes per-asset weighted median using the ObsWeights stored in me.w.

source