Dimensional Reduction Regression
PortfolioOptimisers.PCA Type
struct PCA{T1} <: DimensionReductionTarget
kwargs::T1
endPrincipal Component Analysis (PCA) dimension reduction target.
PCA is used to specify principal component analysis as the dimension reduction method for regression-based moment estimation. The kwargs field stores keyword arguments to be passed to the underlying PCA implementation (e.g., from MultivariateStats.jl).
Fields
kwargs: Keyword arguments forMultivariateStats.fit.
Constructor
PCA(; kwargs::NamedTuple = ())Keyword arguments correspond to the fields above.
Examples
julia> PCA()
PCA
kwargs ┴ @NamedTuple{}: NamedTuple()Related
sourceStatsAPI.fit Method
StatsAPI.fit(drtgt::PCA, X::AbstractMatrix)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. The keyword arguments stored in drtgt.kwargs are passed to MultivariateStats.fit.
Arguments
drtgt: APCAdimension reduction target, specifying keyword arguments for PCA.X: Data matrix (observations × features) to which PCA will be fitted.
Returns
model: A fitted PCA model object fromMultivariateStats.jl.
Related
sourcePortfolioOptimisers.PPCA Type
struct PPCA{T1} <: DimensionReductionTarget
kwargs::T1
endProbabilistic Principal Component Analysis (PPCA) dimension reduction target.
PPCA is used to specify probabilistic principal component analysis as the dimension reduction method for regression-based moment estimation. The kwargs field stores keyword arguments to be passed to the underlying PPCA implementation (e.g., from MultivariateStats.jl).
Fields
kwargs: Keyword arguments forMultivariateStats.fit.
Constructor
PPCA(; kwargs::NamedTuple = ())Keyword arguments correspond to the fields above.
Examples
julia> PPCA()
PPCA
kwargs ┴ @NamedTuple{}: NamedTuple()Related
sourceStatsAPI.fit Method
StatsAPI.fit(drtgt::PPCA, X::AbstractMatrix)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. The keyword arguments stored in drtgt.kwargs are passed to MultivariateStats.fit.
Arguments
drtgt: APPCAdimension reduction target, specifying keyword arguments for PPCA.X: Data matrix (observations × features) to which PPCA will be fitted.
Returns
model: A fitted PPCA model object fromMultivariateStats.jl.
Related
sourcePortfolioOptimisers.DimensionReductionRegression Type
struct DimensionReductionRegression{T1, T2, T3, T4} <: AbstractRegressionEstimator
me::T1
ve::T2
drtgt::T3
retgt::T4
endEstimator for dimension reduction regression-based moment estimation.
DimensionReductionRegression is a flexible estimator type for performing regression with dimension reduction, such as PCA or PPCA, as a preprocessing step. It allows users to specify the expected returns estimator, variance estimator, dimension reduction target (e.g., PCA, PPCA), and the regression target (e.g., LinearModel). This enables modular workflows for moment estimation in high-dimensional settings.
Fields
me: Expected returns estimator.ve: Variance estimator.drtgt: Dimension reduction target.retgt: Regression target type.
Constructor
DimensionReductionRegression(;
me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns(),
ve::AbstractVarianceEstimator = SimpleVariance(),
drtgt::DimensionReductionTarget = PCA(),
retgt::AbstractRegressionTarget = LinearModel())Keyword arguments correspond to the fields above.
Examples
julia> DimensionReductionRegression()
DimensionReductionRegression
me ┼ SimpleExpectedReturns
│ w ┴ nothing
ve ┼ SimpleVariance
│ me ┼ SimpleExpectedReturns
│ │ w ┴ nothing
│ w ┼ nothing
│ corrected ┴ Bool: true
drtgt ┼ PCA
│ kwargs ┴ @NamedTuple{}: NamedTuple()
retgt ┼ LinearModel
│ kwargs ┴ @NamedTuple{}: NamedTuple()Related
PortfolioOptimisers.regression Method
regression(re::DimensionReductionRegression, X::AbstractMatrix, F::AbstractMatrix)Apply dimension reduction regression to each column of a response matrix.
This method fits a regression model with dimension reduction (e.g., PCA or PPCA) to each column of the response matrix X, using the feature matrix F as predictors. For each response vector (column of X), the features are first standardized and projected into a lower-dimensional space using the dimension reduction target specified in re.drtgt. A regression model (specified by re.retgt) is then fitted in the reduced space, and the coefficients are mapped back to the original feature space.
Arguments
re: Dimension reduction regression estimator specifying the expected returns estimator, variance estimator, dimension reduction target, and regression target.X: Response matrix (observations × targets/assets).F: Feature matrix (observations × features).
Returns
Regression: A regression result object containing:b: Vector of intercepts for each response.M: Matrix of coefficients for each response and feature (in the original feature space).L: Matrix of coefficients in the reduced (projected) space.
Details
For each column in
X, the features inFare standardized, projected using the dimension reduction model, and a regression is fitted in the reduced space.The resulting coefficients are transformed back to the original feature space and rescaled.
The output
Regressionobject contains the intercepts, coefficient matrix in the original space, and the projected coefficients.
Related
sourcePortfolioOptimisers.DimensionReductionTarget Type
abstract type DimensionReductionTarget <: AbstractRegressionAlgorithm endAbstract supertype for all dimension reduction regression algorithm targets in PortfolioOptimisers.jl.
All concrete types implementing dimension reduction algorithms for regression (such as PCA or PPCA) should subtype DimensionReductionTarget. This enables a consistent and extensible interface for specifying dimension reduction strategies within regression-based moment estimation.
These types are used to specify the dimension reduction method when constructing a DimensionReductionRegression estimator.
Related
sourcePortfolioOptimisers._regression Method
_regression(re::DimensionReductionRegression, y::AbstractVector, mu::AbstractVector,
sigma::AbstractVector, x1::AbstractMatrix, Vp::AbstractMatrix)Fit a regression model in reduced-dimensional space and recover coefficients in the original feature space.
This function fits a regression model (as specified by retgt) to the response vector y using the projected feature matrix x1 (typically obtained from a dimension reduction method such as PCA or PPCA). It then transforms the estimated coefficients from the reduced space back to the original feature space using the projection matrix Vp and rescales them by the standard deviations sigma. The intercept is adjusted to account for the mean of y and the means of the original features.
Arguments
re: Dimension reduction regression.y: Response vector.mu: Mean vector of the original features.sigma: Standard deviation vector of the original features.x1: Projected feature matrix with intercept column (from dimension reduction).Vp: Projection matrix from the fitted dimension reduction model.
Returns
beta::Vector{<:Real}: Vector of regression coefficients in the original feature space, with the intercept as the first element.
Details
Fits the regression model in the reduced space using
x1andy.Extracts the coefficients for the principal components (excluding the intercept).
Transforms the coefficients back to the original feature space using
Vpand rescales bysigma.Computes the intercept so that predictions are unbiased with respect to the means.
Related
sourcePortfolioOptimisers.prep_dim_red_reg Function
prep_dim_red_reg(drtgt::DimensionReductionTarget, X::AbstractMatrix)Prepare data for dimension reduction regression.
This helper function standardizes the feature matrix X (using Z-score normalization), fits the specified dimension reduction model (e.g., PCA or PPCA), and projects the standardized data into the reduced-dimensional space. It returns the projected data (with an intercept column) and the projection matrix.
Arguments
drtgt: Dimension reduction target (e.g.,PCA(),PPCA()).X: Feature matrix (observations × features) to be reduced.
Returns
x1::AbstractMatrix{<:Real}: Projected feature matrix with an intercept column prepended.Vp::AbstractMatrix{<:Real}: Projection matrix from the fitted dimension reduction model.
Details
Standardizes
Xusing Z-score normalization (mean 0, variance 1).Fits the dimension reduction model specified by
drtgtto the standardized data.Projects the standardized data into the reduced space.
Prepends a column of ones to the projected data for use as an intercept in regression.
Related
source