Base Prior
PortfolioOptimisers.LowOrderPrior Type
struct LowOrderPrior{__T_X, __T_mu, __T_sigma, __T_chol, __T_w, __T_ens, __T_kld, __T_ow, __T_rr, __T_f_mu, __T_f_sigma, __T_f_w} <: AbstractPriorResultContainer type for low order prior results in PortfolioOptimisers.jl.
LowOrderPrior stores the output of low order prior estimation routines, including asset returns, mean vector, covariance matrix, Cholesky factor, weights, entropy, Kullback-Leibler divergence, outlier weights, regression results, and optional factor moments. It is used throughout the package to represent validated prior information for portfolio optimisation and analytics.
Fields
X: Data matrixobservations × featuresif thedimskeyword does not exist ordims = 1,features × observationswhendims = 2.mu: Expected returns vectorfeatures × 1.sigma: Covariance matrixfeatures × features.chol: Cholesky factorisation of the covariance matrix.w: Portfolio weights vector used in prior computation.ens: Effective sample size.kld: Kullback-Leibler divergence.ow: Opinion pooling weights.rr: Regression result.f_mu: Factor expected returns vector.f_sigma: Factor covariance matrix.f_w: Factor weights vector.
Constructors
LowOrderPrior(;
X::MatNum,
mu::VecNum,
sigma::MatNum,
chol::Option{<:MatNum} = nothing,
w::Option{<:ObsWeights} = nothing,
ens::Option{<:Number} = nothing,
kld::Option{<:Num_VecNum} = nothing,
ow::Option{<:VecNum} = nothing,
rr::Option{<:Regression} = nothing,
f_mu::Option{<:VecNum} = nothing,
f_sigma::Option{<:MatNum} = nothing,
f_w::Option{<:VecNum} = nothing
) -> LowOrderPriorKeywords correspond to the struct's fields.
Validation
X,mu, andsigmamust be non-empty.size(sigma, 1) == size(sigma, 2).size(X, 2) == length(mu) == size(sigma, 1).If
wis notnothing,!isempty(w)andlength(w) == size(X, 1).If
kldis anAbstractVector,!isempty(kld).If
owis notnothing,!isempty(ow).If any of
rr,f_mu, orf_sigmaare provided, all must be provided and non-empty,size(rr.M, 2) == length(f_mu) == size(f_sigma, 1), andsize(rr.M, 1) == length(mu).If
f_sigmais notnothing, it must be square andsize(f_sigma, 1) == size(rr.M, 2).If
cholis notnothing,!isempty(chol)andlength(mu) == size(chol, 2).If
f_wis notnothing,!isempty(f_w)andlength(f_w) == size(X, 1).
Examples
julia> LowOrderPrior(; X = [0.01 0.02; 0.03 0.04], mu = [0.02, 0.03],
sigma = [0.0001 0.0002; 0.0002 0.0003])
LowOrderPrior
X ┼ 2×2 Matrix{Float64}
mu ┼ Vector{Float64}: [0.02, 0.03]
sigma ┼ 2×2 Matrix{Float64}
chol ┼ nothing
w ┼ nothing
ens ┼ nothing
kld ┼ nothing
ow ┼ nothing
rr ┼ nothing
f_mu ┼ nothing
f_sigma ┼ nothing
f_w ┴ nothingRelated
sourcePortfolioOptimisers.HighOrderPrior Type
struct HighOrderPrior{__T_pr, __T_kt, __T_D2, __T_L2, __T_S2, __T_sk, __T_V, __T_skmp, __T_f_kt, __T_f_sk, __T_f_V} <: AbstractPriorResultContainer type for high order prior results in PortfolioOptimisers.jl.
HighOrderPrior stores the output of high order prior estimation routines, including low order prior results, cokurtosis tensor, elimination and summation matrices, coskewness tensor, quadratic skewness matrix, and matrix processing estimator. It is used throughout the package to represent validated prior information for portfolio optimisation and analytics involving higher moments.
Fields
pr: Prior result.kt: Cokurtosis matrixfeatures^2 × features^2.D2: Duplication matrix.L2: Elimination matrix.S2: Summation matrix.sk: Coskewness matrixfeatures × features^2.V: Sum of the negative spectral slices of the cokurtosis matrixfeatures × features.skmp: Coskewness matrix processing estimator.f_kt: Factor cokurtosis matrix.f_sk: Factor coskewness matrix.f_V: Factor sum of negative spectral slices of the cokurtosis matrix.
Constructors
HighOrderPrior(;
pr::AbstractPriorResult,
kt::Option{<:MatNum} = nothing,
D2::Option{<:MatNum} = nothing,
L2::Option{<:MatNum} = nothing,
S2::Option{<:MatNum} = nothing,
sk::Option{<:MatNum} = nothing,
V::Option{<:MatNum} = nothing,
skmp::Option{<:AbstractMatrixProcessingEstimator} = MatrixProcessing()
) -> HighOrderPriorKeywords correspond to the struct's fields.
Validation
Defining N = length(pr.mu).
If any of
kt,L2, orS2are provided, all must be provided, non-empty, andsize(kt) == (N^2, N^2),size(L2) == size(S2) == (div(N * (N + 1), 2), N^2).If
skorVare provided, both must be provided, non-empty, andsize(sk) == (N, N^2),size(V) == (N, N).
Examples
julia> HighOrderPrior(;
pr = LowOrderPrior(; X = [0.01 0.02; 0.03 0.04], mu = [0.02, 0.03],
sigma = [0.0001 0.0002; 0.0002 0.0003]), kt = rand(4, 4),
D2 = PortfolioOptimisers.duplication_matrix(2),
L2 = PortfolioOptimisers.elimination_matrix(2),
S2 = PortfolioOptimisers.summation_matrix(2), sk = rand(2, 4),
V = rand(2, 2))
HighOrderPrior
pr ┼ LowOrderPrior
│ X ┼ 2×2 Matrix{Float64}
│ mu ┼ Vector{Float64}: [0.02, 0.03]
│ sigma ┼ 2×2 Matrix{Float64}
│ chol ┼ nothing
│ w ┼ nothing
│ ens ┼ nothing
│ kld ┼ nothing
│ ow ┼ nothing
│ rr ┼ nothing
│ f_mu ┼ nothing
│ f_sigma ┼ nothing
│ f_w ┴ nothing
kt ┼ 4×4 Matrix{Float64}
D2 ┼ 4×3 SparseArrays.SparseMatrixCSC{Int64, Int64}
L2 ┼ 3×4 SparseArrays.SparseMatrixCSC{Int64, Int64}
S2 ┼ 3×4 SparseArrays.SparseMatrixCSC{Int64, Int64}
sk ┼ 2×4 Matrix{Float64}
V ┼ 2×2 Matrix{Float64}
skmp ┼ nothing
f_kt ┼ nothing
f_sk ┼ nothing
f_V ┴ nothingRelated
sourcePortfolioOptimisers.prior Method
prior(pr::AbstractPriorEstimator, rd::ReturnsResult; kwargs...)Compute prior information from asset and/or factor returns using a prior estimator.
prior applies the specified prior estimator to a ReturnsResult object, extracting asset and factor returns and passing them, along with any additional information, to the estimator. Returns a prior result containing computed moments and other prior information for use in portfolio optimisation workflows.
Arguments
pr: Prior estimator.rd: Asset and/or factor returns result.kwargs...: Additional keyword arguments passed to the estimator.
Returns
pr::AbstractPriorResult: Result object containing computed prior information.
Related
sourcePortfolioOptimisers.prior Method
prior(pr::AbstractPriorResult, args...; kwargs...)Propagate or pass through prior result objects.
prior returns the input prior result object unchanged. This method is used to propagate already constructed prior results or enable uniform interface handling in workflows that accept either estimators or results.
Arguments
pr: Prior result object.args...: Additional positional arguments (ignored).kwargs...: Additional keyword arguments (ignored).
Returns
pr::AbstractPriorResult: The input prior result object, unchanged.
Related
sourcePortfolioOptimisers.clusterise Method
clusterise(cle::AbstractClustersEstimator, pr::AbstractPriorResult; kwargs...)Clusterise asset or factor returns from a prior result using a clustering estimator.
clusterise applies the specified clustering estimator to the asset returns matrix contained in the prior result object, producing a clustering result for use in phylogeny analysis, constraint generation, or portfolio construction.
Arguments
cle: Clustering estimator.pr: Prior result object.kwargs...: Additional keyword arguments passed to the clustering estimator.
Returns
clr::AbstractClusteringResult: Result object containing clustering information.
Related
sourceBase.getproperty Method
getproperty(obj::HighOrderPrior, sym::Symbol) -> AnyAccess properties of HighOrderPrior. Forwards unknown property names to the embedded obj.pr prior, allowing transparent access to low-order moment fields.
PortfolioOptimisers.AbstractPriorEstimator Type
abstract type AbstractPriorEstimator <: AbstractEstimatorAbstract supertype for all prior estimators.
AbstractPriorEstimator is the base type for all estimators that compute prior information from asset and/or factor returns. All concrete prior estimators should subtype this type to ensure a consistent interface for prior computation and integration with portfolio optimisation workflows.
Related
sourcePortfolioOptimisers.AbstractLowOrderPriorEstimator Type
abstract type AbstractLowOrderPriorEstimator <: AbstractPriorEstimatorAbstract supertype for low order prior estimators.
AbstractLowOrderPriorEstimator is the base type for estimators that compute low order moments (mean and covariance) from asset and/or factor returns. All concrete low order prior estimators should subtype this type for consistent moment estimation and integration.
Related
PortfolioOptimisers.AbstractLowOrderPriorEstimator_A Type
abstract type AbstractLowOrderPriorEstimator_A <: AbstractLowOrderPriorEstimatorLow order prior estimator using only asset returns.
AbstractLowOrderPriorEstimator_A is the base type for estimators that compute low order moments (mean and covariance) using only asset returns data. All concrete asset-only prior estimators should subtype this type.
Related
sourcePortfolioOptimisers.AbstractLowOrderPriorEstimator_F Type
abstract type AbstractLowOrderPriorEstimator_F <: AbstractLowOrderPriorEstimatorLow order prior estimator using factor returns.
AbstractLowOrderPriorEstimator_F is the base type for estimators that compute low order moments (mean and covariance) requiring the use of both asset and factor returns data. All concrete factor-adjusted prior estimators should subtype this type.
Related
sourcePortfolioOptimisers.AbstractLowOrderPriorEstimator_AF Type
abstract type AbstractLowOrderPriorEstimator_AF <: AbstractLowOrderPriorEstimatorLow order prior estimator using both asset and factor returns.
AbstractLowOrderPriorEstimator_AF is the base type for estimators that compute low order moments (mean and covariance) using both asset and optionally factor returns data. All concrete prior estimators which may optionally use factor returns should subtype this type.
Related
sourcePortfolioOptimisers.AbstractLowOrderPriorEstimator_A_AF Type
const AbstractLowOrderPriorEstimator_A_AF = Union{<:AbstractLowOrderPriorEstimator_A,
<:AbstractLowOrderPriorEstimator_AF}Union type for asset-only and asset-and-factor low order prior estimators.
AbstractLowOrderPriorEstimator_A_AF is a union type that allows dispatch on both asset-only and asset-and-factor prior estimators. This is useful for generic algorithms that operate on estimators using asset returns, with or without factor returns.
Related
PortfolioOptimisers.AbstractLowOrderPriorEstimator_F_AF Type
const AbstractLowOrderPriorEstimator_F_AF = Union{<:AbstractLowOrderPriorEstimator_F,
<:AbstractLowOrderPriorEstimator_AF}Union type for factor-only and asset-and-factor low order prior estimators.
AbstractLowOrderPriorEstimator_F_AF is a union type that allows dispatch on both factor-only and asset-and-factor prior estimators. This is useful for generic algorithms that operate on estimators using factor returns, with or without asset returns.
Related
PortfolioOptimisers.AbstractLowOrderPriorEstimator_A_F_AF Type
const AbstractLowOrderPriorEstimator_A_F_AF = Union{<:AbstractLowOrderPriorEstimator_A,
<:AbstractLowOrderPriorEstimator_F,
<:AbstractLowOrderPriorEstimator_AF}Union type for asset-only, factor-only, and asset-and-factor low order prior estimators.
AbstractLowOrderPriorEstimator_A_F_AF is a union type that allows dispatch on asset-only, factor-only, and asset-and-factor prior estimators. This is useful for generic algorithms that operate on estimators using any combination of asset and factor returns.
Related
PortfolioOptimisers.AbstractHighOrderPriorEstimator Type
abstract type AbstractHighOrderPriorEstimator <: AbstractPriorEstimatorAbstract supertype for high order prior estimators.
AbstractHighOrderPriorEstimator is the base type for estimators that compute high order moments (such as coskewness and cokurtosis) from asset and/or factor returns. All concrete high order prior estimators should subtype this type to ensure a consistent interface for higher moment estimation and integration with portfolio optimisation workflows.
Related
sourcePortfolioOptimisers.AbstractPriorResult Type
abstract type AbstractPriorResult <: AbstractResultAbstract supertype for all prior result types.
AbstractPriorResult is the base type for all result objects produced by prior estimators, containing computed prior information such as moments, asset returns, and factor returns. All concrete prior result types should subtype this to ensure a consistent interface for integration with portfolio optimisation workflows.
Related
sourcePortfolioOptimisers.Pr_RR Type
const Pr_RR = Union{<:AbstractPriorResult, <:ReturnsResult}Alias for a union of prior result and returns result types.
Related
sourcePortfolioOptimisers.PrE_Pr Type
const PrE_Pr = Union{<:AbstractPriorEstimator, <:AbstractPriorResult}Alias for a union of prior estimator and prior result types.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(pr, args...; kwargs...)Get a view or subset of a prior estimator or result for slicing.
Returns the prior unchanged for estimators (they are not sliceable), or returns a sliced prior result for a given cluster or asset index. Used in hierarchical optimisation to provide cluster-specific priors.
Arguments
pr: Prior estimator or result.args...: Additional arguments (index, etc.).kwargs...: Additional keyword arguments.
Returns
- Sliced prior result or unchanged estimator.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
pr::LowOrderPrior,
i,
args...
) -> LowOrderPrior{var"#s179", var"#s1791", <:AbstractMatrix{var"#s21"}} where {var"#s21"<:(Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}), var"#s179"<:AbstractMatrix{var"#s21"}, var"#s21"<:(Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}), var"#s1791"<:AbstractVector{var"#s21"}, var"#s21"<:(Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar})}Return a view of a LowOrderPrior restricted to assets at index i.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
pr::HighOrderPrior,
i,
args...
) -> HighOrderPrior{<:AbstractPriorResult}Return a view of a HighOrderPrior restricted to assets at index i, slicing all relevant moment tensors accordingly.
Related
source