Cross-Sectional Regression (b): private API
Functions
PortfolioOptimisers.cross_sectional_systematic — Function
cross_sectional_systematic(f::MatNum, b::Option{<:VecNum}, Z::Arr3Num) -> MatNumReturn 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 matrixobservations × factors.b::Option{<:VecNum}: Intercept vector, ornothingwhen none was fitted.Z::Arr3Num: Exposure tensorassets × factors × observations. The asset axis may differ from the one the fit saw. The observation axis and the factor axis must matchf.
Validation
size(Z, 3) == size(f, 1)andsize(Z, 2) == size(f, 2).
Returns
Xh::MatNum: Systematic returns,observations × assets.
Related
PortfolioOptimisers.cross_sectional_residuals — Function
cross_sectional_residuals(X::MatNum, f::MatNum, b::Option{<:VecNum}, Z::Arr3Num) -> MatNumReturn 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
- For each observation
tand asseti, take the dot product of the exposuresZ[i, :, t]and the factor returnsf[t, :], in the element type off. - Add the intercept
b[t]when one was fitted. - Subtract the sum from
X[t, i].
Arguments
X::MatNum: Returns matrixobservations × assets.f::MatNum: Factor returns matrixobservations × factors.b::Option{<:VecNum}: Intercept vector, ornothingwhen none was fitted.Z::Arr3Num: Exposure tensorassets × factors × observations.
Validation
- The rules of
cross_sectional_systematic, andsize(X) == (size(Z, 3), size(Z, 1)).
Returns
eps::MatNum: Residuals,observations × assets.
Related