Factor Family Basis Transforms

Types

PortfolioOptimisers.UnseenMemberDesignResult — Type
struct UnseenMemberDesignResult{__T_Z, __T_P} <: AbstractResult

The answer of an Unseen Member rule: the design that the regression of a CrossSectionalFactorPrior solves, and the change of each observation that maps its coefficients back to the reduced factor returns.

unseen_member_design returns it, and an Unseen Member rule of a caller builds it in its own method of that verb, as the # Interfaces section of AbstractUnseenMemberRule states. So the type is the contract of the interface, and its constructor checks each change against the design. The fit regresses on Z, and unseen_member_returns maps the coefficients of each observation in P back. A caller reads the fields by name, as res.Z or (; Z, P) = res.

Fields

  • Z: The design to regress on, assets × reduced factors × observations.
  • P: One t => P_t pair per observation that the rule changes, where P_t is reduced factors × reduced factors, and the factor returns of t are P_t times the coefficients of t. It is empty or () when the rule changes no observation.

Constructors

UnseenMemberDesignResult(Z::Arr3Num,                         P::Union{Tuple{Vararg{Pair{<:Integer, <:AbstractMatrix}}}, AbstractVector{<:Pair{<:Integer, <:AbstractMatrix}}})UnseenMemberDesignResult(; Z::Arr3Num,                         P::Union{Tuple{Vararg{Pair{<:Integer, <:AbstractMatrix}}}, AbstractVector{<:Pair{<:Integer, <:AbstractMatrix}}} = ())

The positional constructor checks the values. The keyword constructor takes Z by name, and P with the default (), a rule that changes no observation, and calls it.

Validation

  • The observation t of each pair of P is an observation of Z, in axes(Z, 3). Otherwise, the constructor raises a DomainError.
  • The change P_t of each pair of P is square on the factor axis of Z, size(Z, 2) × size(Z, 2). Otherwise, the constructor raises a DimensionMismatch.

Examples

julia> res = PortfolioOptimisers.UnseenMemberDesignResult(; Z = ones(2, 2, 3),                                                          P = [2 => [1.0 0.0; 0.0 0.0]]);julia> (size(res.Z), first.(res.P))((2, 2, 3), [2])julia> PortfolioOptimisers.UnseenMemberDesignResult(ones(2, 2, 3), [4 => [1.0 0.0; 0.0 0.0]])ERROR: DomainError with 4:the observation of each change must be an observation of Z, in 1:3[...]

Related

source

Functions

PortfolioOptimisers.reduce_factor_names — Function
reduce_factor_names(fcb::FactorFamilyBasis, nf::VecStr)

Return the names of the reduced factor axis.

The reduced axis follows the raw order with the dropped factor of every constrained family removed, so a retained factor keeps its raw name and its economic meaning.

Arguments

  • fcb: A Factor Family Basis.
  • nf::VecStr: Names of the raw factor axis, of length fcb.K.

Validation

  • length(nf) == fcb.K.

Returns

  • nf::Vector{String}: The retained names, in reduced-axis order.

Examples

julia> fcb = FactorFamilyBasis(; fnm = ["ind"], fi = [[2, 3]], di = [2],                               ratios = reshape([0.5], 1, 1), K = 3);julia> PortfolioOptimisers.reduce_factor_names(fcb, ["mkt", "ind=a", "ind=b"])2-element Vector{String}: "mkt" "ind=a"

Related

source
PortfolioOptimisers.reduce_exposures — Function
reduce_exposures(fcb::Nothing, Ms::Arr3Num) -> Ms
reduce_exposures(fcb::FactorFamilyBasis, Ms::Arr3Num)

Map an exposure history onto the reduced factor axis.

The function applies the ratios of each observation to the exposures of that observation. A fit that constrains no Factor Family has no basis, and its raw axis is the reduced one. So the method on Nothing gives Ms unchanged, as cross_sectional_transform gives its input unchanged under no transform.

Mathematical definition

\[\begin{align} \mathbf{B}^{\mathrm{red}}_{t} &= \mathbf{B}_{t} \mathbf{R}_{t}\,, \\ \mathbf{B}^{\mathrm{red}}_{t} \boldsymbol{f}^{\mathrm{red}}_{t} &= \mathbf{B}_{t} \boldsymbol{f}^{\mathrm{raw}}_{t} \quad \text{when} \quad \boldsymbol{f}^{\mathrm{raw}}_{t} = \mathbf{R}_{t} \boldsymbol{f}^{\mathrm{red}}_{t}\,. \end{align}\]

The column of a retained member $j$ of a family that drops $k$ is the column of $j$ less $r_{t}(j)$ times the column of $k$, and a factor outside every constrained family keeps its column. The second line follows from the first, so the two bases give the same fitted values.

Where:

  • $\mathbf{B}_{t}$: Exposure slice of observation $t$, $N \times K$, the exposures the factor returns of $t$ are read against.
  • $\mathbf{B}^{\mathrm{red}}_{t}$: Exposure slice of observation $t$ on the reduced axis, $N \times K_{r}$.
  • $\mathbf{R}_{t}$: Change of basis of observation $t$ from the reduced factor axis to the raw one, $K \times K_{r}$. The column of a retained factor $j$ holds $1$ in row $j$, and $-r_{t}(j)$ in row $k$ when $j$ belongs to a constrained Factor Family that drops $k$. Every other entry is 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$.
  • $K_{r}$: Reduced factor count, $K$ less one factor for each constrained Factor Family.
  • $\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}$.

Arguments

  • fcb: A Factor Family Basis, or nothing.
  • Ms::Arr3Num: Exposure history on the raw axis, assets × factors × observations.

Validation

  • size(Ms, 2) == fcb.K, and size(Ms, 3) matches the observation axis of the basis, when fcb is a Factor Family Basis.

Returns

  • Ms::Arr3Num: The exposure history on the reduced axis, assets × reduced factors × observations. It is a new Array under a basis, and Ms itself under nothing.

Related

source
PortfolioOptimisers.reduce_loadings — Function
reduce_loadings(fcb::FactorFamilyBasis, M::MatNum, t::Integer = size(fcb.ratios, 1))

Map a point-in-time loading matrix onto the reduced factor axis.

This is reduce_exposures at one observation. It applies the ratios of observation t to a matrix of assets by raw factors. A stack of loading matrices, one slice per observation of the basis, is an exposure history, and reduce_exposures reduces it. Each of the two functions takes one rank of array, so a caller whose argument has no inferred type reaches one method.

Mathematical definition

\[\begin{align} \mathbf{L} &= \mathbf{M} \mathbf{R}_{t}\,. \end{align}\]

Where:

  • $\mathbf{M}$: Loading matrix on the raw axis, $N \times K$.
  • $\mathbf{L}$: Loading matrix on the reduced axis, $N \times K_{r}$.
  • $\mathbf{R}_{t}$: Change of basis of observation $t$ from the reduced factor axis to the raw one, $K \times K_{r}$. The column of a retained factor $j$ holds $1$ in row $j$, and $-r_{t}(j)$ in row $k$ when $j$ belongs to a constrained Factor Family that drops $k$. Every other entry is 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$.
  • $K_{r}$: Reduced factor count, $K$ less one factor for each constrained Factor Family.

Arguments

  • fcb: A Factor Family Basis.
  • M::MatNum: Loading matrix on the raw axis, assets × factors.
  • t::Integer: Observation whose ratios the function applies to a matrix. It defaults to the last observation of the basis.

Validation

  • The factor axis of M is fcb.K, and t indexes the observation axis of the basis.

Returns

  • L::Matrix{<:Real}: The loading matrix on the reduced axis, assets × reduced factors.

Related

source
PortfolioOptimisers.reduce_factor_returns — Function
reduce_factor_returns(fcb::FactorFamilyBasis, f::MatNum)
reduce_factor_returns(fcb::FactorFamilyBasis, f::VecNum)

Drop the redundant factor returns, giving the reduced-axis factor returns.

The reduction keeps the retained columns and applies no ratio. It undoes expand_factor_returns, and the converse holds only for raw returns that satisfy the zero-sum condition of every constrained Factor Family.

Mathematical definition

\[\begin{align} \boldsymbol{f}^{\mathrm{red}}_{t} &= \mathbf{S}^{\intercal} \boldsymbol{f}^{\mathrm{raw}}_{t}\,, \\ \mathbf{S}^{\intercal} \mathbf{R}_{t} &= \mathbf{I}\,. \end{align}\]

The second line follows from the definitions of $\mathbf{S}$ and $\mathbf{R}_{t}$.

Where:

  • $\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}$.
  • $\mathbf{S}$: Retention matrix, $K \times K_{r}$, the columns of the identity matrix at the retained factors, in raw order.
  • $\mathbf{R}_{t}$: Change of basis of observation $t$ from the reduced factor axis to the raw one, $K \times K_{r}$. The column of a retained factor $j$ holds $1$ in row $j$, and $-r_{t}(j)$ in row $k$ when $j$ belongs to a constrained Factor Family that drops $k$. Every other entry is 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$.
  • $K_{r}$: Reduced factor count, $K$ less one factor for each constrained Factor Family.
  • $\mathbf{I}$: Identity matrix.

Arguments

  • fcb: A Factor Family Basis.
  • f::VecNum_MatNum: Factor returns on the raw axis, either one observation per row or one observation alone.

Validation

  • The factor axis of f is fcb.K.

Returns

  • f::Array{<:Real}: The factor returns on the reduced axis, of the same number of dimensions as the input.

Related

source
PortfolioOptimisers.reduce_factor_mu — Function
reduce_factor_mu(fcb::FactorFamilyBasis, mu::VecNum)

Drop the redundant entries of a factor mean, giving the reduced-axis mean.

The reduction applies no ratio. It undoes expand_factor_returns, and the converse holds only for a raw mean that satisfies the zero-sum condition of every constrained Factor Family.

Mathematical definition

\[\begin{align} \boldsymbol{\mu}^{\mathrm{red}} &= \mathbf{S}^{\intercal} \boldsymbol{\mu}^{\mathrm{raw}}\,, \\ \mathbf{S}^{\intercal} \mathbf{R}_{t} &= \mathbf{I}\,. \end{align}\]

The second line follows from the definitions of $\mathbf{S}$ and $\mathbf{R}_{t}$.

Where:

  • $\boldsymbol{\mu}^{\mathrm{raw}}$, $\boldsymbol{\mu}^{\mathrm{red}}$: Raw and reduced factor mean, $K \times 1$ and $K_{r} \times 1$.
  • $\mathbf{S}$: Retention matrix, $K \times K_{r}$, the columns of the identity matrix at the retained factors, in raw order.
  • $\mathbf{R}_{t}$: Change of basis of observation $t$ from the reduced factor axis to the raw one, $K \times K_{r}$. The column of a retained factor $j$ holds $1$ in row $j$, and $-r_{t}(j)$ in row $k$ when $j$ belongs to a constrained Factor Family that drops $k$. Every other entry is 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$.
  • $K_{r}$: Reduced factor count, $K$ less one factor for each constrained Factor Family.
  • $\mathbf{I}$: Identity matrix.

Arguments

  • fcb: A Factor Family Basis.
  • mu::VecNum: Factor mean on the raw axis.

Validation

  • length(mu) == fcb.K.

Returns

  • mu::Vector{<:Real}: The factor mean on the reduced axis.

Related

source
PortfolioOptimisers.reduce_factor_covariance — Function
reduce_factor_covariance(fcb::FactorFamilyBasis, sigma::MatNum)
reduce_factor_covariance(fcb::FactorFamilyBasis, sigma::Arr3Num)

Take the full-rank block of a factor covariance, giving the reduced-axis covariance.

The reduced factor returns are the retained raw ones, so the reduced covariance is the block of the retained factors and the reduction applies no ratio. It undoes expand_factor_covariance, and the converse holds only for a raw covariance of the form $\mathbf{R}_{t} \mathbf{\Sigma}^{\mathrm{red}} \mathbf{R}_{t}^{\intercal}$. A stack of covariances, one slice per observation, gives the stack of their blocks.

Mathematical definition

\[\begin{align} \mathbf{\Sigma}^{\mathrm{red}} &= \mathbf{S}^{\intercal} \mathbf{\Sigma}^{\mathrm{raw}} \mathbf{S}\,, \\ \mathbf{S}^{\intercal} \mathbf{R}_{t} &= \mathbf{I}\,. \end{align}\]

The second line follows from the definitions of $\mathbf{S}$ and $\mathbf{R}_{t}$.

Where:

  • $\mathbf{\Sigma}^{\mathrm{raw}}$, $\mathbf{\Sigma}^{\mathrm{red}}$: Raw and reduced factor covariance, $K \times K$ and $K_{r} \times K_{r}$.
  • $\mathbf{S}$: Retention matrix, $K \times K_{r}$, the columns of the identity matrix at the retained factors, in raw order.
  • $\mathbf{R}_{t}$: Change of basis of observation $t$ from the reduced factor axis to the raw one, $K \times K_{r}$. The column of a retained factor $j$ holds $1$ in row $j$, and $-r_{t}(j)$ in row $k$ when $j$ belongs to a constrained Factor Family that drops $k$. Every other entry is 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$.
  • $K_{r}$: Reduced factor count, $K$ less one factor for each constrained Factor Family.
  • $\mathbf{I}$: Identity matrix.

Arguments

  • fcb: A Factor Family Basis.
  • sigma::MatNum_Arr3Num: Factor covariance on the raw axis, factors × factors, or a stack of them, factors × factors × observations.

Validation

  • Both factor axes of sigma are fcb.K.

Returns

  • sigma::Array{<:Real}: The factor covariance on the reduced axis, of the same number of dimensions as the input.

Related

source
PortfolioOptimisers.expand_factor_returns — Function
expand_factor_returns(fcb::FactorFamilyBasis, g::MatNum)
expand_factor_returns(fcb::FactorFamilyBasis, mu::VecNum, t::Integer = size(fcb.ratios, 1))

Reconstruct the raw-axis factor returns, or a raw-axis factor mean, from the reduced-axis ones.

A vector is the returns of one observation, or a factor mean. The function expands it with the ratios of observation t, and reduce_factor_mu undoes it for a mean.

The retained returns pass through, and the zero-sum condition of each family gives the return of the factor it drops.

Mathematical definition

\[\begin{align} \boldsymbol{f}^{\mathrm{raw}}_{t} &= \mathbf{R}_{t} \boldsymbol{f}^{\mathrm{red}}_{t}\,, \\ f^{\mathrm{raw}}_{t,k} &= -\sum_{j \in \mathcal{F} \setminus \{k\}} r_{t}(j) \, f^{\mathrm{raw}}_{t,j}\,. \end{align}\]

The second line follows from the first for every constrained Factor Family $\mathcal{F}$ that drops $k$.

Where:

  • $\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}$.
  • $\mathbf{R}_{t}$: Change of basis of observation $t$ from the reduced factor axis to the raw one, $K \times K_{r}$. The column of a retained factor $j$ holds $1$ in row $j$, and $-r_{t}(j)$ in row $k$ when $j$ belongs to a constrained Factor Family that drops $k$. Every other entry is 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$.
  • $\mathcal{F}$: Raw factors of one family.
  • $K_{r}$: Reduced factor count, $K$ less one factor for each constrained Factor Family.

Arguments

  • fcb: A Factor Family Basis.
  • g::MatNum: Factor returns on the reduced axis, one observation per row, or one mean per observation. The function expands each row with the ratios of that row.
  • mu::VecNum: Factor returns of one observation, or a factor mean, on the reduced axis.
  • t::Integer: Observation whose ratios the function applies to a vector. It defaults to the last observation of the basis.

Validation

  • The factor axis of g or mu is the reduced factor count, t indexes the observation axis of the basis, and a matrix matches that axis.

Returns

  • f::Array{<:Real}: The factor returns on the raw axis, of the same number of dimensions as the input.

Related

source
PortfolioOptimisers.expand_factor_covariance — Function
expand_factor_covariance(fcb::FactorFamilyBasis, sigma::MatNum,
                         t::Integer = size(fcb.ratios, 1))
expand_factor_covariance(fcb::FactorFamilyBasis, sigma::Arr3Num)
expand_factor_covariance(fcb::Nothing, sigma::Arr3Num)

Reconstruct the raw-axis factor covariance from the reduced-axis one.

The answer is singular by construction, because the raw axis is a linear image of a smaller one. reduce_factor_covariance undoes it. A stack holds one covariance per observation of the basis, and the function expands slice t with the ratios of observation t. The standard errors of a realised attribution read such a stack, one covariance of the estimated factor returns per observation.

A fit with no family re-basis holds nothing in its basis slot, and its regression axis is the raw axis. The method on Nothing returns the stack unchanged, without a check, as cross_sectional_transform does for a skipped step.

Mathematical definition

\[\begin{align} \mathbf{\Sigma}^{\mathrm{raw}} &= \mathbf{R}_{t} \mathbf{\Sigma}^{\mathrm{red}} \mathbf{R}_{t}^{\intercal}\,, \\ \mathbf{S}^{\intercal} \mathbf{\Sigma}^{\mathrm{raw}} \mathbf{S} &= \mathbf{\Sigma}^{\mathrm{red}}\,, \\ \mathbf{D}^{\intercal} \mathbf{\Sigma}^{\mathrm{raw}} \mathbf{S} &= \mathbf{W}_{t} \mathbf{\Sigma}^{\mathrm{red}}\,, \\ \mathbf{D}^{\intercal} \mathbf{\Sigma}^{\mathrm{raw}} \mathbf{D} &= \mathbf{W}_{t} \mathbf{\Sigma}^{\mathrm{red}} \mathbf{W}_{t}^{\intercal}\,, \\ \operatorname{rank} \mathbf{\Sigma}^{\mathrm{raw}} &\le K_{r} < K\,. \end{align}\]

The last four lines follow from the first. The second, third and fourth give the retained block, the block of the dropped rows against the retained columns, and the dropped block.

Where:

  • $\mathbf{\Sigma}^{\mathrm{raw}}$, $\mathbf{\Sigma}^{\mathrm{red}}$: Raw and reduced factor covariance, $K \times K$ and $K_{r} \times K_{r}$.
  • $\mathbf{R}_{t}$: Change of basis of observation $t$ from the reduced factor axis to the raw one, $K \times K_{r}$. The column of a retained factor $j$ holds $1$ in row $j$, and $-r_{t}(j)$ in row $k$ when $j$ belongs to a constrained Factor Family that drops $k$. Every other entry is 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$.
  • $\mathbf{S}$: Retention matrix, $K \times K_{r}$, the columns of the identity matrix at the retained factors, in raw order.
  • $\mathbf{D}$: Drop matrix, the columns of the $K \times K$ identity matrix at the dropped factors, one column for each constrained Factor Family.
  • $\mathbf{W}_{t} = \mathbf{D}^{\intercal} \mathbf{R}_{t}$: Reconstruction weights of observation $t$, one row for each constrained Factor Family and $K_{r}$ columns. A row applied to a reduced-axis vector gives the entry of the factor that its family drops.
  • $K_{r}$: Reduced factor count, $K$ less one factor for each constrained Factor Family.
  • $K$: Number of factors.

Algorithm

  1. Check that sigma is $K_{r} \times K_{r}$.
  2. Build the reconstruction weights W of observation t with dropped_factor_weights.
  3. Multiply W by sigma with support_product, giving DR, the block of the dropped rows against the retained columns. A NaN of sigma reaches only the dropped factors whose weight at it is not zero.
  4. Multiply W, sigma and the transpose of W with support_product, giving DD, the dropped block.
  5. Write sigma, DR, the transpose of DR and DD into their blocks of the $K \times K$ answer raw.
  6. For a stack, check that it holds one slice per observation of the basis, and do steps 1 to 5 on slice t with the ratios of observation t.

Arguments

  • fcb: A Factor Family Basis, or nothing for a stack on the raw axis.
  • sigma::MatNum_Arr3Num: Factor covariance on the reduced axis, reduced factors × reduced factors, or a stack of them, reduced factors × reduced factors × observations.
  • t::Integer: Observation whose ratios the function applies to a matrix. It defaults to the last observation of the basis.

Validation

  • Both factor axes of sigma are the reduced factor count, t indexes the observation axis of the basis, and a stack matches that axis, when fcb is a Factor Family Basis.

Returns

  • sigma::Array{<:Real}: The factor covariance on the raw axis, of the same number of dimensions as the input. It is a new Array under a basis, and sigma itself under nothing.

Examples

julia> fcb = FactorFamilyBasis(; fnm = ["ind"], fi = [[2, 3]], di = [2],                               ratios = reshape([0.5, 2.0], 2, 1), K = 3);julia> V = cat([1.0 0.0; 0.0 1.0], [1.0 0.0; 0.0 4.0]; dims = 3);julia> S = PortfolioOptimisers.expand_factor_covariance(fcb, V);julia> S[:, :, 1]3×3 Matrix{Float64}: 1.0   0.0   0.0 0.0   1.0  -0.5 0.0  -0.5   0.25julia> S[:, :, 2] == PortfolioOptimisers.expand_factor_covariance(fcb, V[:, :, 2], 2)true

Related

source
PortfolioOptimisers.project_factor_coordinates — Function
project_factor_coordinates(fcb::FactorFamilyBasis, x::MatNum)
project_factor_coordinates(fcb::FactorFamilyBasis, x::VecNum)

Project raw factor-space coordinates into the reduced basis.

The map applies the transpose of the change of basis, so it is not a column selection. The coordinate of a dropped factor contributes to the retained coordinates of its family. The factor exposure of a portfolio is such a coordinate.

Mathematical definition

\[\begin{align} \boldsymbol{y} &= \mathbf{R}_{t}^{\intercal} \boldsymbol{x}\,, \\ \mathbf{R}_{t}^{\intercal} \boldsymbol{g}_{t} &= (\mathbf{B}_{t} \mathbf{R}_{t})^{\intercal} \boldsymbol{w}_{t}\,. \end{align}\]

The entry of a retained member $j$ of a family that drops $k$ is $x_{j} - r_{t}(j) \, x_{k}$, and the entry of a factor outside every constrained family is $x_{j}$. The second line follows from the first, because $\boldsymbol{g}_{t} = \mathbf{B}_{t}^{\intercal} \boldsymbol{w}_{t}$. The projected factor exposure of a portfolio is its exposure to the reduced factors of reduce_exposures.

Where:

  • $\boldsymbol{x}$: Coordinates on the raw axis, $K \times 1$, with entry $x_{j}$ for factor $j$.
  • $\boldsymbol{y}$: Coordinates on the reduced axis, $K_{r} \times 1$.
  • $\mathbf{R}_{t}$: Change of basis of observation $t$ from the reduced factor axis to the raw one, $K \times K_{r}$. The column of a retained factor $j$ holds $1$ in row $j$, and $-r_{t}(j)$ in row $k$ when $j$ belongs to a constrained Factor Family that drops $k$. Every other entry is 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$.
  • $K_{r}$: Reduced factor count, $K$ less one factor for each constrained Factor Family.
  • $\boldsymbol{g}_{t} = \mathbf{B}_{t}^{\intercal} \boldsymbol{w}_{t}$: Portfolio factor exposure of observation $t$, $K \times 1$, with entry $g_{tk}$ for factor $k$.
  • $\mathbf{B}_{t}$: Exposure slice of observation $t$, $N \times K$, the exposures the factor returns of $t$ are read against.
  • $\boldsymbol{w}_{t}$: Portfolio weights held over observation $t$, $N \times 1$, with entry $w_{ti}$ for asset $i$. A constant weight vector is the same at every $t$.

Arguments

  • fcb: A Factor Family Basis.
  • x::VecNum_MatNum: Coordinates on the raw axis, either one observation per row or one observation alone. The function projects each row of a matrix with the ratios of that row, and a vector with the ratios of the last observation.

Validation

  • The factor axis of x is fcb.K, and a matrix matches the observation axis of the basis.

Returns

  • y::Array{<:Real}: The coordinates on the reduced axis, of the same number of dimensions as the input.

Related

source
PortfolioOptimisers.dropped_factor_weights — Function
dropped_factor_weights(fcb::FactorFamilyBasis, t::Integer)
dropped_factor_weights(fcb::FactorFamilyBasis)

Return the reduced-axis weights that reconstruct the dropped factors at one observation.

Row j holds the coefficients of the zero-sum condition of family j, so the row applied to a reduced-axis vector gives the entry of the factor that family drops. The function builds these rows from the ratios and never forms the change of basis. Without t, it gives the weights of every observation of the basis, one slice per observation.

Mathematical definition

\[\begin{align} \mathbf{W}_{t} &= \mathbf{D}^{\intercal} \mathbf{R}_{t}\,. \end{align}\]

The row of a family that drops $k$ holds $-r_{t}(j)$ in the column of each retained member $j$, and zero in every other column.

Where:

  • $\mathbf{W}_{t} = \mathbf{D}^{\intercal} \mathbf{R}_{t}$: Reconstruction weights of observation $t$, one row for each constrained Factor Family and $K_{r}$ columns. A row applied to a reduced-axis vector gives the entry of the factor that its family drops.
  • $\mathbf{D}$: Drop matrix, the columns of the $K \times K$ identity matrix at the dropped factors, one column for each constrained Factor Family.
  • $\mathbf{R}_{t}$: Change of basis of observation $t$ from the reduced factor axis to the raw one, $K \times K_{r}$. The column of a retained factor $j$ holds $1$ in row $j$, and $-r_{t}(j)$ in row $k$ when $j$ belongs to a constrained Factor Family that drops $k$. Every other entry is 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$.
  • $K_{r}$: Reduced factor count, $K$ less one factor for each constrained Factor Family.

Arguments

  • fcb: A Factor Family Basis.
  • t::Integer: Observation whose ratios the function reads.

Validation

  • t indexes the observation axis of the basis.

Returns

  • W::Array{<:Real}: The reconstruction weights, constrained families × reduced factors, or without t the stack of them, constrained families × reduced factors × observations.

Related

source
PortfolioOptimisers.unseen_member_design — Function
unseen_member_design(rule::AbstractUnseenMemberRule, fcb::Nothing, B::Arr3Num, Zl::Arr3Num,
                     W::MatNum) -> UnseenMemberDesignResult
unseen_member_design(rule::SolvedUnseenMember, fcb::FactorFamilyBasis, B::Arr3Num,
                     Zl::Arr3Num, W::MatNum) -> UnseenMemberDesignResult
unseen_member_design(rule::ZeroUnseenMember, fcb::FactorFamilyBasis, B::Arr3Num,
                     Zl::Arr3Num, W::MatNum) -> UnseenMemberDesignResult

Return the design that the regression of a CrossSectionalFactorPrior solves under an Unseen Member rule, and the change of each observation that maps its coefficients back.

Without a constrained Factor Family there is no Unseen Member. Under SolvedUnseenMember the regression solves the reduced design itself. In both cases the design is Zl, and no observation changes.

The exposures lag the returns, so the condition of an observation reads the benchmark weights of an earlier one. An asset that loads on a member there can leave the regression sample of the observation, for example when it delists. If no asset of the sample loads on the member, the data state nothing about its return, and its column of the raw design is zero. The member then fixes the condition by itself. The condition no longer identifies the other members of the family, so the reduced design is rank-deficient, and a pseudo-inverse answer depends on the member that the family drops.

Under ZeroUnseenMember the function gives the member a return of zero, as an Empty Factor has, and as the member has at an observation that gives it no benchmark weight. The condition then holds over the members that the sample sees, and over the whole family too, because the member adds a zero term to it. So the observation is identified again, and its answer does not depend on the dropped member. The residuals of the pairs of positive weight do not change when the members that the sample sees span the same fitted values, as a one-hot family does. The residual of an asset outside the sample reads the return of each Unseen Member that it loads on, which is zero.

Mathematical definition

\[\begin{align} \mathcal{U}_{t} &= \left\{j \in \mathcal{F} : B_{tij} = 0 \ \forall i : u_{ti} > 0\right\}\,, \\ f^{\mathrm{raw}}_{t,j} &= 0\,, \quad j \in \mathcal{U}_{t}\,, \\ \sum_{j \in \mathcal{F} \setminus \mathcal{U}_{t}} c_{t}(j) \, f^{\mathrm{raw}}_{t,j} &= 0\,, \\ \boldsymbol{f}^{\mathrm{red}}_{t} &= \mathbf{P}_{t} \boldsymbol{h}_{t}\,, \quad \boldsymbol{h}_{t} = \underset{\boldsymbol{h}}{\arg\min} \sum_{i} u_{ti} \left(x_{t,\,i} - \mathbf{B}^{\mathrm{red}}_{t,i} \mathbf{P}_{t} \boldsymbol{h}\right)^{2}\,. \end{align}\]

$\mathbf{P}_{t}$ is the identity with a zero column at each retained member of $\mathcal{U}_{t}$. When the dropped member $k$ is in $\mathcal{U}_{t}$, the condition moves onto the retained member $q$ the sample sees with the largest $|r_{t}(q)|$: the column of $q$ is zero, and its row holds $-r_{t}(j) / r_{t}(q)$ at each other retained member $j$ the sample sees. So $\mathbf{B}^{\mathrm{red}}_{t} \mathbf{P}_{t} \boldsymbol{h}_{t} = \mathbf{B}^{\mathrm{red}}_{t} \boldsymbol{f}^{\mathrm{red}}_{t}$. $\mathbf{P}_{t}$ is idempotent, $\mathbf{P}_{t} \mathbf{P}_{t} = \mathbf{P}_{t}$, so the changed design times the factor returns is the same product too, and a consumer that reads the changed design with the stored factor returns gets the fitted values of the fit. The covariance of the factor returns is $\mathbf{P}_{t} \mathbf{V}_{h} \mathbf{P}_{t}^{\intercal}$, where $\mathbf{V}_{h}$ is the covariance of $\boldsymbol{h}_{t}$. So an Unseen Member has a variance of zero, as its return is stated, not estimated. And the expansion of $\boldsymbol{f}^{\mathrm{red}}_{t}$ through $\mathbf{R}_{t}$ gives the raw returns above. Under ZeroUnseenMember the function changes no observation where every member of $\mathcal{U}_{t}$ has $c_{t}(j) = 0$ and the sample sees $k$, because there the zero column already states that answer.

Where:

  • $\mathcal{F}$: Raw factors of one family.
  • $\mathcal{U}_{t}$: Members of $\mathcal{F}$ that no asset of positive weight at observation $t$ loads on.
  • $B_{tik}$: Exposure of asset $i$ to factor $k$ at observation $t$.
  • $u_{ti}$: Cross-sectional weight of asset $i$ at observation $t$.
  • $c_{t}(j)$: Benchmark-weighted exposure of factor $j$ at observation $t$, with a non-finite exposure 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}$.
  • $\mathbf{B}^{\mathrm{red}}_{t,i}$: Reduced exposures of asset $i$ at observation $t$, $1 \times K_{r}$.
  • $x_{t,\,i}$: Return of asset $i$ at observation $t$.
  • $\mathbf{P}_{t}$: Change of the reduced design of observation $t$, $K_{r} \times K_{r}$.
  • $\boldsymbol{h}_{t}$: Coefficients of the regression on the changed design, $K_{r} \times 1$.

Arguments

  • rule: The Unseen Member rule.
  • fcb: The Factor Family Basis of the lagged exposures, one row per observation of Zl, or nothing without a constrained Factor Family.
  • B: Lagged exposures on the raw axis, assets × factors × observations.
  • Zl: Lagged exposures on the reduced axis, which fcb gives from B.
  • W: Cross-sectional weights matrix observations × assets. The pairs of positive weight are the sample of each observation, as cross_sectional_design_mask states it. The fit passes the weights it regresses with, and a consumer of a CrossSectionalFactorModel passes the stored weights rw.

Validation

  • The factor axis of B is fcb.K, and B matches the observation axis of the basis.
  • W has the observations and the assets of B.

Returns

  • res::UnseenMemberDesignResult: Z, the design to regress on, Zl with Zl[:, :, t] * P_t at each observation in P, and P, one t => P_t pair per observation that the function changes. P is empty when the function changes none, and () without a basis or under SolvedUnseenMember.

Related

source