Skip to content
13

Median Absolute Deviation Risk

PortfolioOptimisers.MedianCenteringFunction Type
julia
abstract type MedianCenteringFunction <: AbstractAlgorithm

Abstract supertype for centering functions used in the Median Absolute Deviation risk measure.

Related Types

source
PortfolioOptimisers.MedianCentering Type
julia
struct MedianCentering <: MedianCenteringFunction

Centres the returns series using the (weighted) median before computing the Median Absolute Deviation.

Related Types

source
PortfolioOptimisers.MeanCentering Type
julia
struct MeanCentering <: MedianCenteringFunction

Centres the returns series using the (weighted) mean before computing the Median Absolute Deviation.

Related Types

source
PortfolioOptimisers.MedAbsDevMu Type
julia
const MedAbsDevMu = Union{<:Num_VecNum_VecScalar, <:MedianCenteringFunction}

Union of valid centring-target types for MedianAbsoluteDeviation.

Accepts a numeric scalar/vector target or a MedianCenteringFunction (e.g. mean or median centering).

Related

source
PortfolioOptimisers.MedianAbsoluteDeviation Type
julia
struct MedianAbsoluteDeviation{__T_settings, __T_w, __T_mu, __T_flag} <: HierarchicalRiskMeasure

Represents the Median Absolute Deviation (MAD) risk measure for hierarchical portfolio optimisation.

MedianAbsoluteDeviation computes the median (or mean) absolute deviation of portfolio returns about a specified centre, providing a robust alternative to variance for measuring dispersion.

Mathematical Definition

Let μ be the chosen centre (median or mean of returns, or a user-supplied value). Define the deviations δt=xtμ. The MAD is:

MAD(x)=median1tT(|δt|).

When flag = true (default), the result is scaled by a consistency factor (Φ1(3/4))11.4826 so that the MAD is a consistent estimator of the standard deviation under normality.

Fields

  • settings: Hierarchical risk measure configuration.

  • w: Optional observation weights.

  • mu: Centre of the deviation (centering function, scalar, vector, or VecScalar).

  • flag: If true, applies the consistency correction factor.

Constructors

julia
MedianAbsoluteDeviation(;
    settings::HierarchicalRiskMeasureSettings = HierarchicalRiskMeasureSettings(),
    w::Option{<:ObsWeights} = nothing,
    mu::MedAbsDevMu = MedianCentering(),
    flag::Bool = true
) -> MedianAbsoluteDeviation

Keywords correspond to the struct's fields.

Validation

  • If mu is a VecNum: !isempty(mu) and all(isfinite, mu).

  • If mu is a Number: isfinite(mu).

  • If w is not nothing: !isempty(w).

Functor

julia
(r::MedianAbsoluteDeviation)(w::VecNum, X::MatNum, fees = nothing)

Computes the MAD of the portfolio returns series.

Arguments

  • w::VecNum: Portfolio weights vector.

  • X::MatNum: Asset returns matrix (T×N).

  • fees: Optional fee structure.

Examples

julia
julia> MedianAbsoluteDeviation()
MedianAbsoluteDeviation
  settings ┼ HierarchicalRiskMeasureSettings
           │   scale ┴ Float64: 1.0
         w ┼ nothing
        mu ┼ MedianCentering()
      flag ┴ Bool: true

Related

source