Norm error: private API

PortfolioOptimisers.norm_errorFunction
norm_error(f::L2Norm, a, b, T::Option{<:Number} = nothing)
norm_error(f::SquaredL2Norm, a, b, T::Option{<:Number} = nothing)
norm_error(::L1Norm, a, b, T::Option{<:Number} = nothing)
norm_error(f::LpNorm, a, b, T::Option{<:Number} = nothing)
norm_error(f::LInfNorm, a, b, T::Option{<:Number} = nothing)
norm_error(f::Option{<:NormError}, a, T::Option{<:Number} = nothing)

Compute the norm-based tracking error between portfolio and benchmark weights.

norm_error takes the norm that f selects, and divides it by the norm_factor that the same f declares. Each NormError subtype names one pair. The three-argument form takes the norm of a - b. The two-argument form takes the norm of a alone, for a caller that already holds the deviation vector; f = nothing there means an unweighted L2 norm.

Mathematical definition

\[\begin{align} \mathrm{TE}_{L_2}(\boldsymbol{a},\boldsymbol{b}) &= \frac{\lVert \boldsymbol{a} - \boldsymbol{b} \rVert_2}{\sqrt{T - d}}\,, \\ \mathrm{TE}_{L_2^2}(\boldsymbol{a},\boldsymbol{b}) &= \frac{\lVert \boldsymbol{a} - \boldsymbol{b} \rVert_2^2}{T - d}\,, \\ \mathrm{TE}_{L_1}(\boldsymbol{a},\boldsymbol{b}) &= \frac{\lVert \boldsymbol{a} - \boldsymbol{b} \rVert_1}{T}\,, \\ \mathrm{TE}_{L_p}(\boldsymbol{a},\boldsymbol{b}) &= \frac{\lVert \boldsymbol{a} - \boldsymbol{b} \rVert_p}{(T-d)^{1/p}}\,, \\ \mathrm{TE}_{L_\infty}(\boldsymbol{a},\boldsymbol{b}) &= \frac{\lVert \boldsymbol{a} - \boldsymbol{b} \rVert_\infty}{T - d}\,. \end{align}\]

Where:

  • $\mathrm{TE}_{L_2}(\boldsymbol{a},\boldsymbol{b})$: L2-norm error.
  • $\mathrm{TE}_{L_2^2}(\boldsymbol{a},\boldsymbol{b})$: Squared L2-norm error.
  • $\mathrm{TE}_{L_1}(\boldsymbol{a},\boldsymbol{b})$: L1-norm error.
  • $\mathrm{TE}_{L_p}(\boldsymbol{a},\boldsymbol{b})$: Lp-norm error.
  • $\mathrm{TE}_{L_\infty}(\boldsymbol{a},\boldsymbol{b})$: L∞-norm error, the largest absolute deviation.
  • $\boldsymbol{a}$: Portfolio weight or return vector $T \times 1$.
  • $\boldsymbol{b}$: Benchmark vector $T \times 1$.
  • $T$: Number of observations.
  • $d$: Degrees of freedom, ddof. When $T$ is not provided the denominator is 1.
  • $p$: Norm order.

Algorithm

The method Julia selects on the type of f is the algorithm, and every method runs the same two steps.

  1. Take the norm that f names, of a - b in the three-argument form and of a alone in the two-argument form.
  2. Divide the norm of step 1 by norm_factor of the same f and T, which is 1 when T is nothing.

Arguments

  • f: Norm-based error algorithm, a NormError subtype.
  • a: Portfolio weights, or the deviation vector in the two-argument form.
  • b: Benchmark weights.
  • T: Optional number of observations.

Returns

  • err::Number: Norm-based tracking error.

Examples

julia> PortfolioOptimisers.norm_error(L2Norm(), [0.5, 0.5], [0.6, 0.4], 2)0.14142135623730948julia> PortfolioOptimisers.norm_error(L1Norm(), [0.5, 0.5], [0.6, 0.4], 2)0.09999999999999998

Related

source