Median expected returns
PortfolioOptimisers.MedianExpectedReturns Type
struct MedianExpectedReturns{__T_w} <: AbstractExpectedReturnsEstimatorExpected returns estimator that returns the optionally weighted asset medians.
Fields
w: Optional observation weights vectorobservations × 1, or a concrete subtype ofDynamicAbstractWeights. Ifnothing, the computation is unweighted.
Constructors
MedianExpectedReturns(;
w::Option{<:ObsWeights} = nothing
) -> MedianExpectedReturnsKeywords correspond to the struct's fields.
Examples
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
sourceStatistics.mean Method
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
Where:
: Median expected return of asset . : Return of asset at time . : 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)ifdims == 1or(N, 1)ifdims == 2.
Related
sourceStatistics.mean Method
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...
) -> AnyWeighted-median overload of mean(me::MedianExpectedReturns, X::MatNum; dims::Int = 1, kwargs...). Computes per-asset weighted median using the ObsWeights stored in me.w.