Dimensional Reduction Regression: private API
PortfolioOptimisers.DimensionReductionTarget — Type
abstract type DimensionReductionTarget <: AbstractRegressionAlgorithmAbstract supertype for all dimension reduction regression algorithm targets.
All concrete and/or abstract types implementing dimension reduction algorithms for regression (such as PCA or PPCA) should be subtypes of DimensionReductionTarget.
These types are used to specify the dimension reduction method when constructing a DimensionReductionRegression estimator. A target must answer StatsAPI.fit(tgt, X) with a model that StatsAPI.predict and MultivariateStats.projection both accept.
Related
PortfolioOptimisers._regression — Method
_regression(re::DimensionReductionRegression, y::VecNum, mu::VecNum,
sigma::VecNum, x1::MatNum, Vp::MatNum)Fits one asset in the reduced basis and maps its coefficients back to the original factors.
The reduced-space intercept is discarded and rebuilt from the response mean, so a fit and its recovery agree only while mu is the mean under the weights that fit used. Matched, the two paths predict the same values, weighted and unweighted alike; standardise with an unweighted mean and fit with weights, and they part.
Mathematical definition
\[\begin{align} \hat{y} &= \hat{\beta}_{0,\mathrm{pc}} + \mathbf{X}_1 \hat{\boldsymbol{\beta}}_{\mathrm{pc}}\,, \\ \hat{\boldsymbol{\beta}} &= \mathbf{V}_p \hat{\boldsymbol{\beta}}_{\mathrm{pc}} \oslash \boldsymbol{\sigma}\,, \\ \hat{\beta}_0 &= \bar{y} - \hat{\boldsymbol{\beta}}^{\intercal} \boldsymbol{\mu}\,. \end{align}\]
Where:
- $\hat{y}$: Fitted response.
- $\hat{\beta}_{0,\mathrm{pc}}$: Intercept of the fit in the reduced space, which this method discards.
- $\hat{\boldsymbol{\beta}}_{\mathrm{pc}}$: Regression coefficients in the reduced (PC) space.
- $\hat{\boldsymbol{\beta}}$: Regression coefficients in the original factor space.
- $\hat{\beta}_0$: Intercept adjusted to the original space.
- $\mathbf{X}_1$: Projected factor matrix in the reduced space, with its leading column of ones.
- $\mathbf{V}_p$: PCA/PPCA projection matrix.
- $\boldsymbol{\sigma}$: Factor standard deviations.
- $\boldsymbol{\mu}$: Factor means.
- $\bar{y}$: Mean of the response.
- $\oslash$: Element-wise division.
Algorithm
- Take the mean of
y, givingmean_y. Weight it byre.retgt.kwargs.weightswhen that entry is present. - Fit
re.retgttox1andy, and drop the leading coefficient, givingbeta_pc. - Map
beta_pcthroughVpand divide bysigma, givingbeta, the coefficients in the original factor space. - Subtract the
mu-weighted sum ofbetafrommean_y, givingbeta0. - Prepend
beta0tobeta.
Arguments
re: Dimension reduction regression.y: Response vectorobservations × 1.mu: Mean vector of the original factors. It must be the mean that standardised them, which is whyprep_dim_red_regreturns it.sigma: Standard deviation vector of the original factors. It must be the scale that standardised them, for the same reason.x1: Projected factor matrix with intercept column, fromprep_dim_red_reg.Vp: Projection matrix from the fitted dimension reduction model.
Returns
beta::VecNum: Regression coefficients in the original factor space, with the intercept as the first element.
Related
References
- [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 4.3.1, Equations 4.18-4.20.
- [38] B. D. Fekedulegn, J. J. Colbert, R. R. Hicks, Jr. and M. E. Schuckers. Coping with multicollinearity: an example on application of principal components regression in dendroecology. Research Paper NE-RP-721 (U.S. Department of Agriculture, Forest Service, Northeastern Research Station, 2002).
PortfolioOptimisers.prep_dim_red_reg — Function
prep_dim_red_reg(re::DimensionReductionRegression, X::MatNum)Standardises the factors, fits the dimension reduction model, and projects the factors into the reduced basis.
It returns the two statistics that did the standardisation along with the projection, because the caller must undo that same scale. Equations 4.13, 4.15 and 4.20 of [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). hold only when the two are the same statistic.
Algorithm
- Read the expected returns estimator from
re.ve.me, givingme. Fall back toSimpleExpectedReturns()when it isnothing. - Take the standard deviation of each column of
Xunderre.ve, givingsigma, and raise every entry to at leasteps(eltype(sigma)), so a constant factor cannot divide by zero. - Take the mean of each column of
Xunderme, givingmu. - Centre
Xwithdemean_returnsatmu, divide each column by its entry ofsigma, and transpose, givingX_std. - Fit
re.drtgttoX_std, givingmodel. - Project
X_stdthroughmodeland transpose, givingXp, the factors in the reduced basis. - Read the projection matrix of
model, givingVp. - Prepend a column of ones to
Xp, givingx1.
Arguments
re: Dimension reduction regression estimator. Itsvesupplies the standard deviation, and itsve.methe mean. Anothinginve.mefalls back toSimpleExpectedReturns().X: Factor matrixobservations × factors, to be reduced.
Returns
x1::MatNum: Projected factor matrixobservations × components, with an intercept column prepended.Vp::MatNum: Projection matrixfactors × components, from the fitted dimension reduction model.mu::VecNum: Factor means used to centreX.sigma::VecNum: Factor standard deviations used to scaleX.
Related
DimensionReductionRegressionPCAPPCAdemean_returns_regression(::DimensionReductionRegression, ::VecNum, ::VecNum, ::VecNum, ::MatNum, ::MatNum)
References
- [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 4.3.1, Equations 4.13, 4.16-4.17.
- [38] B. D. Fekedulegn, J. J. Colbert, R. R. Hicks, Jr. and M. E. Schuckers. Coping with multicollinearity: an example on application of principal components regression in dendroecology. Research Paper NE-RP-721 (U.S. Department of Agriculture, Forest Service, Northeastern Research Station, 2002).
References
- [5]
- D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
- [38]
- B. D. Fekedulegn, J. J. Colbert, R. R. Hicks Jr. and M. E. Schuckers. Coping with multicollinearity: an example on application of principal components regression in dendroecology. Technical Report NE-RP-721 (U.S. Department of Agriculture, Forest Service, Northeastern Research Station, 2002).