Skip to content
13

Factor Prior

PortfolioOptimisers.FactorPrior Type
julia
struct FactorPrior{__T_pe, __T_mp, __T_re, __T_ve, __T_rsd} <: AbstractLowOrderPriorEstimator_F

Factor-based prior estimator for asset returns.

FactorPrior is a low order prior estimator that computes the mean and covariance of asset returns using a factor model. It combines a factor prior estimator, matrix post-processing, regression, and variance estimation to produce posterior moments. Optionally, it can add residual variance to the posterior covariance for robust estimation.

Fields

  • pe: Prior estimator.

  • mp: Matrix processing estimator.

  • re: Regression estimator.

  • ve: Variance estimator.

  • rsd: Whether to include residual variance in the posterior covariance.

Constructors

julia
FactorPrior(;
    pe::AbstractLowOrderPriorEstimator_A_AF = EmpiricalPrior(),
    mp::AbstractMatrixProcessingEstimator = MatrixProcessing(),
    re::AbstractRegressionEstimator = StepwiseRegression(),
    ve::AbstractVarianceEstimator = SimpleVariance(),
    rsd::Bool = true
) -> FactorPrior

Keywords correspond to the struct's fields.

Examples

julia
julia> FactorPrior()
FactorPrior
   pe ┼ EmpiricalPrior
      │        ce ┼ PortfolioOptimisersCovariance
      │           │   ce ┼ Covariance
      │           │      │    me ┼ SimpleExpectedReturns
      │           │      │       │   w ┴ nothing
      │           │      │    ce ┼ GeneralCovariance
      │           │      │       │   ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
      │           │      │       │    w ┴ nothing
      │           │      │   alg ┴ Full()
      │           │   mp ┼ MatrixProcessing
      │           │      │     pdm ┼ Posdef
      │           │      │         │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton
      │           │      │         │   kwargs ┴ @NamedTuple{}: NamedTuple()
      │           │      │      dn ┼ nothing
      │           │      │      dt ┼ nothing
      │           │      │     alg ┼ nothing
      │           │      │   order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)
      │        me ┼ SimpleExpectedReturns
      │           │   w ┴ nothing
      │   horizon ┴ nothing
   mp ┼ MatrixProcessing
      │     pdm ┼ Posdef
      │         │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton
      │         │   kwargs ┴ @NamedTuple{}: NamedTuple()
      │      dn ┼ nothing
      │      dt ┼ nothing
      │     alg ┼ nothing
      │   order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)
   re ┼ StepwiseRegression
      │   crit ┼ PValue
      │        │   t ┴ Float64: 0.05
      │    alg ┼ Forward()
      │    tgt ┼ LinearModel
      │        │   kwargs ┴ @NamedTuple{}: NamedTuple()
   ve ┼ SimpleVariance
      │          me ┼ SimpleExpectedReturns
      │             │   w ┴ nothing
      │           w ┼ nothing
      │   corrected ┴ Bool: true
  rsd ┴ Bool: true

Related

source
PortfolioOptimisers.factory Method
julia
factory(
    pe::FactorPrior,
    w::Union{DynamicAbstractWeights, AbstractWeights}
) -> Union{FactorPrior{<:AbstractLowOrderPriorEstimator_A, <:AbstractMatrixProcessingEstimator, <:AbstractRegressionEstimator, <:AbstractVarianceEstimator, Bool}, FactorPrior{<:AbstractLowOrderPriorEstimator_AF, <:AbstractMatrixProcessingEstimator, <:AbstractRegressionEstimator, <:AbstractVarianceEstimator, Bool}}

Return a new FactorPrior estimator with observation weights w applied to the underlying prior, regression, and variance estimators.

Related

source
Base.getproperty Method
julia
getproperty(obj::FactorPrior, sym::Symbol) -> Any

Access properties of FactorPrior. Exposes :me and :ce from the embedded asset prior estimator obj.pe for transparent access.

source
PortfolioOptimisers.prior Method
julia
prior(pe::FactorPrior, X::MatNum, F::MatNum; dims::Int = 1, kwargs...)

Compute factor-based prior moments for asset returns using a factor model.

prior estimates the mean and covariance of asset returns using the specified factor prior estimator, regression, and matrix post-processing. The factor returns matrix F is used to compute factor moments, which are then mapped to asset space via regression. Optionally, residual variance is added to the posterior covariance for robust estimation. The result is returned as a LowOrderPrior object.

Mathematical definition

The factor model maps factor moments to asset space via the loadings matrix B (with intercepts α):

μ^=Bf^+α.Σ^=BΣfB+Σε.

Where:

  • B: N×K factor loadings matrix.

  • f^: K×1 vector of factor expected returns.

  • α: N×1 vector of regression intercepts.

  • Σf: K×K factor covariance matrix.

  • Σε: N×N diagonal matrix of residual variances (when rsd = true).

Arguments

  • pe: Factor prior estimator.

  • X: Asset returns matrix (observations × assets).

  • F: Factor returns matrix (observations × factors).

  • dims: Dimension along which to perform the computation.

  • kwargs...: Additional keyword arguments passed to matrix processing and estimators.

Returns

  • pr::LowOrderPrior: Result object containing posterior asset returns, mean vector, covariance matrix, Cholesky factor, regression result, and factor moments.

Validation

  • dims in (1, 2).

Related

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(
    pe::FactorPrior,
    i,
    args...
) -> Union{FactorPrior{<:AbstractLowOrderPriorEstimator_A, <:AbstractMatrixProcessingEstimator, <:AbstractRegressionEstimator, <:AbstractVarianceEstimator, Bool}, FactorPrior{<:AbstractLowOrderPriorEstimator_AF, <:AbstractMatrixProcessingEstimator, <:AbstractRegressionEstimator, <:AbstractVarianceEstimator, Bool}}

Return a new FactorPrior estimator restricted to the assets at index i.

Related

source