Factor Family Basis

Types

PortfolioOptimisers.FactorFamilyBasis — Type
struct FactorFamilyBasis{__T_fnm, __T_fi, __T_di, __T_ratios, __T_K} <: AbstractFactorFamilyBasis

Compact change of basis between the raw factor axis and the reduced axis a re-based Factor Family is fitted in.

A Factor Family whose one-hot exposures are collinear with a global factor carries one redundant column. The re-basis drops one member of the family and rewrites the family in an equivalent basis of full column rank, in which the benchmark-weighted factor returns of the family sum to zero. The change of basis differs from one observation to the next. The result stores, for each observation, the ratio of the benchmark-weighted exposure of each retained member to that of the dropped member, and it never stores the dense basis matrix.

Mathematical definition

For each constrained Factor Family $\mathcal{F}$ that drops the member $k$, and at each observation $t$,

\[\begin{align} c_{t}(j) &= \left(\mathbf{B}_{t}^{\intercal} \bar{\boldsymbol{w}}_{t}\right)_{j}\,, \\ r_{t}(j) &= \frac{c_{t}(j)}{c_{t}(k)}\,, \quad j \in \mathcal{F} \setminus \{k\}\,, \\ \sum_{j \in \mathcal{F}} c_{t}(j) \, f^{\mathrm{raw}}_{t,j} &= 0\,, \\ f^{\mathrm{raw}}_{t,k} &= -\sum_{j \in \mathcal{F} \setminus \{k\}} r_{t}(j) \, f^{\mathrm{raw}}_{t,j}\,. \end{align}\]

The third line is the zero-sum condition, and the fourth line is the same condition solved for the return of the dropped factor. So the retained factor returns and the ratios fix the whole family, and the reduced axis holds one factor fewer for each family. A ratio is finite only where $c_{t}(k) \neq 0$.

Where:

  • $\mathcal{F}$: Raw factors of one family.
  • $c_{t}(j)$: Benchmark-weighted exposure of factor $j$ at observation $t$, with a non-finite exposure read as zero.
  • $\mathbf{B}_{t}$: Exposure slice of observation $t$, $N \times K$, the exposures the factor returns of $t$ are read against.
  • $\bar{\boldsymbol{w}}_{t}$: Normalised benchmark weights of observation $t$, $N \times 1$, with entry $\bar{w}_{t,i}$ for asset $i$. They are the benchmark weights of the observation over their sum, with a non-finite weight read as zero.
  • $r_{t}(j) = c_{t}(j) / c_{t}(k)$: Ratio of the benchmark-weighted exposure of member $j$ of a constrained Factor Family to that of the member $k$ the family drops, at observation $t$.
  • $\boldsymbol{f}^{\mathrm{raw}}_{t}$, $\boldsymbol{f}^{\mathrm{red}}_{t}$: Raw and reduced factor returns of observation $t$, $K \times 1$ and $K_{r} \times 1$. The entry of factor $j$ is $f^{\mathrm{raw}}_{t,j}$.
  • $K_{r}$: Reduced factor count, $K$ less one factor for each constrained Factor Family.

Fields

  • fnm: Label of each constrained Factor Family, one entry per family, in the order the caller requested them. That order fixes the column order of ratios.
  • fi: Member indices of each constrained Factor Family in the raw factor axis, one vector per family. Two families never share a member.
  • di: Position within fi[j] of the member family j drops, one entry per family. The dropped member is the one the zero-sum condition reconstructs.
  • ratios: Ratios of the benchmark-weighted exposures, observations × C, with C = sum(length(fi[j]) - 1). The block of family j holds one column per retained member, in the member order of fi[j] with the dropped position removed.
  • K: Number of factors on the raw axis. The reduced axis holds K - length(fnm) of them.

Constructors

FactorFamilyBasis(; fnm::VecStr, fi::AbstractVector{<:AbstractVector{<:Integer}},                  di::AbstractVector{<:Integer}, ratios::MatNum, K::Integer)

Keywords correspond to the struct's fields.

Validation

  • K > 0 and !isempty(fnm).
  • fnm, fi and di have the same length, and fnm does not repeat a label.
  • Every family holds at least two members, its members are unique, and every member lies in 1:K.
  • No factor belongs to two families.
  • di[j] indexes fi[j].
  • ratios has one column per retained member of a constrained family, sum(length(fi[j]) - 1) in all.
  • ratios is not empty, and every entry of it is finite.
  • The reduced axis is not empty. The rules above imply it: the families are disjoint, each holds at least two members of 1:K, so K is at least twice the number of families, and no separate check is needed.

Examples

julia> FactorFamilyBasis(; fnm = ["industry"], fi = [[1, 2]], di = [2],                         ratios = reshape([0.5, 0.4], 2, 1), K = 3)FactorFamilyBasis     fnm ┼ Vector{String}: ["industry"]      fi ┼ 1-element Vector{Vector{Int64}}      di ┼ Vector{Int64}: [2]  ratios ┼ 2×1 Matrix{Float64}       K ┴ Int64: 3

Related

source

Functions

PortfolioOptimisers.factor_family_basis — Function
factor_family_basis(families::AbstractVector{<:Pair}, Ms::Arr3Num, bw::MatNum,
                    nf::VecStr, fam::VecStr) -> FactorFamilyBasis

Build the compact change of basis of the requested constrained Factor Families.

The element type of the ratios is the promoted type of Ms and bw. So a Rational history gives exact ratios, and a Float32 history gives Float32 ratios. A dropped factor whose benchmark-weighted exposure is small but not zero gives large finite ratios. The builder accepts them, and they are ill-conditioned. To avoid them, state a dropped factor with a large exposure, or let the automatic choice pick one.

Mathematical definition

For each requested family $\mathcal{F}$, and at each observation $t$,

\[\begin{align} \bar{w}_{t,i} &= \frac{b_{t,i}}{\sum_{l=1}^{N} b_{t,l}}\,, \\ c_{t}(j) &= \left(\mathbf{B}_{t}^{\intercal} \bar{\boldsymbol{w}}_{t}\right)_{j}\,, \\ k &= \underset{j \in \mathcal{F}}{\arg\max} \sum_{t=1}^{T} \lvert c_{t}(j) \rvert\,, \\ r_{t}(j) &= \frac{c_{t}(j)}{c_{t}(k)}\,, \quad j \in \mathcal{F} \setminus \{k\}\,. \end{align}\]

The third line holds when the caller states no dropped factor. Otherwise $k$ is the stated factor. The automatic choice makes $\lvert c_{t}(k) \rvert$ large on average, so the ratios stay moderate.

Where:

  • $b_{t,i}$: Benchmark weight of asset $i$ at observation $t$, with a non-finite weight read as zero.
  • $\bar{\boldsymbol{w}}_{t}$: Normalised benchmark weights of observation $t$, $N \times 1$, with entry $\bar{w}_{t,i}$ for asset $i$. They are the benchmark weights of the observation over their sum, with a non-finite weight read as zero.
  • $c_{t}(j)$: Benchmark-weighted exposure of factor $j$ at observation $t$, with a non-finite exposure read as zero.
  • $\mathbf{B}_{t}$: Exposure slice of observation $t$, $N \times K$, the exposures the factor returns of $t$ are read against.
  • $\mathcal{F}$: Raw factors of one family.
  • $r_{t}(j) = c_{t}(j) / c_{t}(k)$: Ratio of the benchmark-weighted exposure of member $j$ of a constrained Factor Family to that of the member $k$ the family drops, at observation $t$.
  • $N$: Number of assets.
  • $T$: Number of observations.

Algorithm

  1. Check the axes of Ms, bw, nf and fam.
  2. Compute c, the benchmark-weighted exposure of every raw factor at every observation, with weighted_family_exposures.
  3. For each requested family, in the order of families, find its members idx in fam.
  4. Resolve the position d of the dropped member with resolve_dropped_member. On a tie of the automatic choice, the first member in the order of fam wins.
  5. Refuse the family when the dropped member's column of c is zero at an observation.
  6. Divide the columns of c of the retained members by the column of the dropped member, giving the family's block of the ratios.
  7. Build the FactorFamilyBasis from the resolved families and the concatenated blocks, which runs every check of the constructor again.

Arguments

  • families: Pairs of family label => dropped factor name, in the order the families take columns of ratios. A nothing on the right asks for the automatic choice of the dropped factor.
  • Ms::Arr3Num: Exposure history, assets × factors × observations.
  • bw::MatNum: Benchmark weight history, observations × assets.
  • nf::VecStr: Names of the raw factor axis, of length size(Ms, 2).
  • fam::VecStr: Family label of each raw factor, of length size(Ms, 2).

Validation

  • families and Ms are not empty, and no family label appears twice.
  • nf and fam are as long as the factor axis of Ms, and nf does not repeat a name.
  • bw matches Ms on the observation and asset axes, and every finite weight is non-negative.
  • Every observation carries a strictly positive benchmark weight sum.
  • Every requested family label appears in fam, and holds at least two factors.
  • A stated dropped factor name appears in nf, and belongs to the family that names it.
  • The benchmark-weighted exposure of each dropped factor is not zero at any observation, otherwise an IsNonFiniteError, because the ratios would not be finite.
  • The rules of FactorFamilyBasis.

Returns

  • fcb::FactorFamilyBasis: The compact change of basis.

Examples

julia> Ms = reshape([1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0], 2, 2, 2);julia> factor_family_basis(["ind" => nothing], Ms, [0.5 0.5; 0.5 0.5], ["ind=a", "ind=b"],                           ["ind", "ind"])FactorFamilyBasis     fnm ┼ Vector{String}: ["ind"]      fi ┼ 1-element Vector{Vector{Int64}}      di ┼ Vector{Int64}: [1]  ratios ┼ 2×1 Matrix{Float64}       K ┴ Int64: 2

Related

source