Dimensional Reduction Regression: private API

PortfolioOptimisers.DimensionReductionTargetType
abstract type DimensionReductionTarget <: AbstractRegressionAlgorithm

Abstract 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

source
PortfolioOptimisers._regressionMethod
_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

  1. Take the mean of y, giving mean_y. Weight it by re.retgt.kwargs.weights when that entry is present.
  2. Fit re.retgt to x1 and y, and drop the leading coefficient, giving beta_pc.
  3. Map beta_pc through Vp and divide by sigma, giving beta, the coefficients in the original factor space.
  4. Subtract the mu-weighted sum of beta from mean_y, giving beta0.
  5. Prepend beta0 to beta.

Arguments

  • re: Dimension reduction regression.
  • y: Response vector observations × 1.
  • mu: Mean vector of the original factors. It must be the mean that standardised them, which is why prep_dim_red_reg returns 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, from prep_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).
source
PortfolioOptimisers.prep_dim_red_regFunction
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

  1. Read the expected returns estimator from re.ve.me, giving me. Fall back to SimpleExpectedReturns() when it is nothing.
  2. Take the standard deviation of each column of X under re.ve, giving sigma, and raise every entry to at least eps(eltype(sigma)), so a constant factor cannot divide by zero.
  3. Take the mean of each column of X under me, giving mu.
  4. Centre X with demean_returns at mu, divide each column by its entry of sigma, and transpose, giving X_std.
  5. Fit re.drtgt to X_std, giving model.
  6. Project X_std through model and transpose, giving Xp, the factors in the reduced basis.
  7. Read the projection matrix of model, giving Vp.
  8. Prepend a column of ones to Xp, giving x1.

Arguments

  • re: Dimension reduction regression estimator. Its ve supplies the standard deviation, and its ve.me the mean. A nothing in ve.me falls back to SimpleExpectedReturns().
  • X: Factor matrix observations × factors, to be reduced.

Returns

  • x1::MatNum: Projected factor matrix observations × components, with an intercept column prepended.
  • Vp::MatNum: Projection matrix factors × components, from the fitted dimension reduction model.
  • mu::VecNum: Factor means used to centre X.
  • sigma::VecNum: Factor standard deviations used to scale X.

Related

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).
source

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).