Dimensional Reduction Regression

PortfolioOptimisers.PCAType
struct PCA{__T_kwargs} <: DimensionReductionTarget

Replaces the factors with the principal components of their standardised covariance.

The kwargs field is forwarded to MultivariateStats.fit(MultivariateStats.PCA, X; kwargs...), and it is the only place the retained width is set: pratio caps the share of variance the retained components must explain and maxoutdim caps their number. The default kwargs = (;) takes that library's own defaults, which on a factor matrix of full rank retain every component and reduce nothing: on five factors of full rank PCA() retained five components, while PCA(; kwargs = (; pratio = 0.8)) retained four and PCA(; kwargs = (; maxoutdim = 2)) retained two.

Fields

  • kwargs: Keyword arguments passed to fit(MultivariateStats.PCA, X; kwargs...)

Constructors

PCA(;    kwargs::NamedTuple = (;)) -> PCA

Keywords correspond to the struct's fields.

Examples

julia> PCA()PCA  kwargs ┴ @NamedTuple{}: NamedTuple()

Related

References

  • [35] K. Pearson. On lines and planes of closest fit to systems of points in space. The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science 2, 559–572 (1901).
  • [36] H. Hotelling. Analysis of a complex of statistical variables into principal components. Journal of Educational Psychology 24, 417–441 (1933).
source
PortfolioOptimisers.PPCAType
struct PPCA{__T_kwargs} <: DimensionReductionTarget

Replaces the factors with the latent components of a Gaussian latent-variable model.

The model is the maximum-likelihood factor analyser with an isotropic noise variance; its latent directions span the same subspace as the principal components of PCA, and they coincide with them in the zero-noise limit. The kwargs field is forwarded to MultivariateStats.fit(MultivariateStats.PPCA, X; kwargs...). Its default width is one fewer than PCA's, because that library caps a latent-variable model at one less than the number of input dimensions: on five factors of full rank PCA() retained five components and PPCA() retained four. maxoutdim lowers that width and must not raise it to the factor count: at the full width the third-party fit succeeds and MultivariateStats.projection then raises an ArgumentError out of its singular value decomposition, so the failure would surface inside prep_dim_red_reg rather than at construction. StatsAPI.fit(::PPCA, ::MatNum) checks the cap before it calls that library, and raises a DomainError naming maxoutdim instead. The constructor cannot hold the check, because it never sees the factor matrix.

Fields

  • kwargs: Keyword arguments passed to fit(MultivariateStats.PPCA, X; kwargs...)

Constructors

PPCA(;    kwargs::NamedTuple = (;)) -> PPCA

Keywords correspond to the struct's fields.

Examples

julia> PPCA()PPCA  kwargs ┴ @NamedTuple{}: NamedTuple()

Related

References

  • [37] M. E. Tipping and C. M. Bishop. Probabilistic principal component analysis. Journal of the Royal Statistical Society: Series B (Statistical Methodology) 61, 611–622 (1999).
source
PortfolioOptimisers.DimensionReductionRegressionType
struct DimensionReductionRegression{__T_ve, __T_drtgt, __T_retgt} <: AbstractTimeSeriesRegressionEstimator

Estimates a loadings matrix by regressing each asset on the leading components of the factors.

drtgt reduces the standardised factors to a smaller orthogonal basis, retgt fits each asset in that basis, and the coefficients are then mapped back to the original factors. ve supplies the mean and the standard deviation that mapping divides by; the expected returns estimator it reads is ve.me, and a nothing there falls back to SimpleExpectedReturns(). Unlike StepwiseRegression, every asset keeps every factor. The standardisation and the recovery read the same statistics: prep_dim_red_reg computes them from ve, and _regression recovers the coefficients with the pair it returned, so a weighted ve — the one factory builds from the incoming observation weights — is honoured end to end, as Equations 4.13, 4.15 and 4.20 of [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). require.

Fields

  • ve: Variance estimator.
  • drtgt: Dimension reduction target.
  • retgt: Regression model target.

Constructors

DimensionReductionRegression(;    ve::AbstractVarianceEstimator = SimpleVariance(),    drtgt::DimensionReductionTarget = PCA(),    retgt::AbstractRegressionTarget = LinearModel()) -> DimensionReductionRegression

Keywords correspond to the struct's fields.

Validation

  • If retgt.kwargs carries a weights entry, it must be an ObsWeights and, when it is a vector, !isempty(retgt.kwargs.weights).

Propagated parameters

When factory is called on this type, the following @fprop-tagged fields are automatically propagated:

  • ve: Recursively updated via factory.
  • drtgt: Recursively updated via factory.
  • retgt: Recursively updated via factory.

View parameters

When port_opt_view is called on this type, the following @vprop-tagged fields are automatically subset to the selected indices:

Examples

julia> DimensionReductionRegression()DimensionReductionRegression     ve ┼ SimpleVariance        │          me ┼ SimpleExpectedReturns        │             │   w ┴ nothing        │           w ┼ nothing        │   corrected ┴ Bool: true  drtgt ┼ PCA        │   kwargs ┴ @NamedTuple{}: NamedTuple()  retgt ┼ LinearModel        │   kwargs ┴ @NamedTuple{}: NamedTuple()

Related

References

  • [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 4.3.1, Equations 4.12-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
StatsAPI.fitMethod
StatsAPI.fit(drtgt::PCA, X::MatNum)

Fit a Principal Component Analysis (PCA) model to the data matrix X using the configuration in drtgt.

This method applies PCA as a dimension reduction technique for regression-based moment estimation.

Algorithm

  1. Read drtgt.kwargs, which carries the retained width through pratio and maxoutdim.
  2. Call MultivariateStats.fit on MultivariateStats.PCA with X and those keyword arguments, giving the fitted model.

Arguments

  • drtgt: A PCA dimension reduction target, specifying keyword arguments for PCA.
  • X: Data matrix factors × observations, standardised by the caller.

Returns

  • model::PCA: A fitted PCA model object from MultivariateStats.jl.

Related

source
StatsAPI.fitMethod
StatsAPI.fit(drtgt::PPCA, X::MatNum)

Fit a Probabilistic Principal Component Analysis (PPCA) model to the data matrix X using the configuration in drtgt.

This method applies PPCA as a dimension reduction technique for regression-based moment estimation.

Algorithm

  1. Read drtgt.kwargs, which carries the retained width through maxoutdim.
  2. If maxoutdim is present, check it against the number of factors, size(X, 1).
  3. Call MultivariateStats.fit on MultivariateStats.PPCA with X and those keyword arguments, giving the fitted model.

Arguments

  • drtgt: A PPCA dimension reduction target, specifying keyword arguments for PPCA.
  • X: Data matrix factors × observations, standardised by the caller.

Validation

  • If drtgt.kwargs carries a maxoutdim entry, 0 < drtgt.kwargs.maxoutdim < size(X, 1) must hold. MultivariateStats caps a probabilistic PCA at one latent dimension fewer than the number of factors, and its own fit accepts the full width and returns a model whose weights are NaN. Without this check the failure reaches the caller as an ArgumentError from LAPACK, raised by MultivariateStats.projection inside prep_dim_red_reg, which names neither the cause nor the keyword.

Returns

  • model::PPCA: A fitted PPCA model object from MultivariateStats.jl.

Related

source
PortfolioOptimisers.regressionMethod
regression(re::DimensionReductionRegression, X::MatNum, F::MatNum)

Reduces the factors once and regresses every asset on the same reduced basis.

The reduction is fitted on F alone, so it does not depend on the assets and one asset's response cannot move another's loadings.

Algorithm

  1. Allocate rr, a dense assets × (factors + 1) buffer of zeros.
  2. Reduce F with prep_dim_red_reg, giving f1, Vp, mu and sigma.
  3. For each asset i, fit that column of X in the reduced basis and map the coefficients back, and write the result into row i of rr.
  4. Take the first column of rr as b and its remaining columns as M.
  5. Undo the rescaling and the projection of M in turn, giving L, the coefficients in the reduced basis.
  6. Build a Regression from b, M and L.

Arguments

  • re: Dimension reduction regression estimator that supplies the variance estimator, the dimension reduction target and the regression target.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • F: Data matrix observations × factors if the dims keyword does not exist or dims = 1, factors × observations when dims = 2.

Returns

  • reg::Regression: Regression result carrying:

    • b: Intercept of each asset, a view of the first column of rr.
    • M: Coefficient of each asset and factor in the original factor space, a view of the remaining columns of rr. Every asset keeps every factor, so M carries no structural zero.
    • L: Coefficient of each asset and retained component, $(\mathbf{M} \odot \boldsymbol{\sigma}^{\intercal}) \mathbf{V}_p^{+\intercal}$. It reproduces the reduced-space coefficients the fits of step 3 produced, checked at 2.2e-16 against them on a 200×5 sample, and size(L, 2) is the number of retained components, which is the width risk is decomposed in.

Related

References

  • [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 4.3.1, Equations 4.12-4.22.
  • [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.factoryMethod
factory(drtgt::DimensionReductionTarget, args...; kwargs...) -> DimensionReductionTarget

No-op factory for DimensionReductionTarget subtypes. Returns the target unchanged.

Dimension reduction targets (such as PCA and PPCA) do not depend on observation weights, so this method returns drtgt unchanged. This allows generic code to call factory on dimension reduction targets without special-casing. The weights reach the reduction through DimensionReductionRegression's ve instead, which standardises the factors before the target ever sees them.

Arguments

  • drtgt: Dimension reduction target.
  • args...: Additional arguments (ignored).
  • kwargs...: Additional keyword arguments (ignored).

Returns

  • drtgt: The input dimension reduction target, unchanged.

Related

source

References

[5]
D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
[35]
K. Pearson. On lines and planes of closest fit to systems of points in space. The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science 2, 559–572 (1901).
[36]
H. Hotelling. Analysis of a complex of statistical variables into principal components. Journal of Educational Psychology 24, 417–441 (1933).
[37]
M. E. Tipping and C. M. Bishop. Probabilistic principal component analysis. Journal of the Royal Statistical Society: Series B (Statistical Methodology) 61, 611–622 (1999).
[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).