Cross-Sectional Regression (b): private API

Functions

PortfolioOptimisers.cross_sectional_systematic — Function
cross_sectional_systematic(f::MatNum, b::Option{<:VecNum}, Z::Arr3Num) -> MatNum

Return the systematic part of a cross-sectional regression, observations × assets.

Mathematical definition

\[\begin{align} \hat{x}_{t,i} &= b_{t} + \boldsymbol{z}_{t,i}^{\intercal} \boldsymbol{f}_{t}\,. \end{align}\]

Where:

  • $\hat{x}_{t,i}$: Systematic return of asset $i$ at observation $t$.
  • $\boldsymbol{z}_{t,i}$: Exposures of asset $i$ at observation $t$.
  • $\boldsymbol{f}_{t}$: Factor returns of observation $t$.
  • $b_{t}$: Intercept of observation $t$. The term is zero when no intercept was fitted.

Arguments

  • f::MatNum: Factor returns matrix observations × factors.
  • b::Option{<:VecNum}: Intercept vector, or nothing when none was fitted.
  • Z::Arr3Num: Exposure tensor assets × factors × observations. The asset axis may differ from the one the fit saw. The observation axis and the factor axis must match f.

Validation

  • size(Z, 3) == size(f, 1) and size(Z, 2) == size(f, 2).

Returns

  • Xh::MatNum: Systematic returns, observations × assets.

Related

source
PortfolioOptimisers.cross_sectional_residuals — Function
cross_sectional_residuals(X::MatNum, f::MatNum, b::Option{<:VecNum}, Z::Arr3Num) -> MatNum

Return the residuals of a cross-sectional regression, observations × assets: the returns X less the systematic part of cross_sectional_systematic, in one pass.

Each element takes the roundings of X - cross_sectional_systematic(f, b, Z) in the same order, so the two give the same bits. The pass allocates the residuals alone, where the two-step form also allocates the systematic part and, with an intercept, its shifted copy.

Algorithm

  1. For each observation t and asset i, take the dot product of the exposures Z[i, :, t] and the factor returns f[t, :], in the element type of f.
  2. Add the intercept b[t] when one was fitted.
  3. Subtract the sum from X[t, i].

Arguments

  • X::MatNum: Returns matrix observations × assets.
  • f::MatNum: Factor returns matrix observations × factors.
  • b::Option{<:VecNum}: Intercept vector, or nothing when none was fitted.
  • Z::Arr3Num: Exposure tensor assets × factors × observations.

Validation

Returns

  • eps::MatNum: Residuals, observations × assets.

Related

source