Base Prior
PortfolioOptimisers.LowOrderPrior Type
struct LowOrderPrior{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12} <:
AbstractPriorResult
X::T1
mu::T2
sigma::T3
chol::T4
w::T5
ens::T6
kld::T7
ow::T8
rr::T9
f_mu::T10
f_sigma::T11
f_w::T12
endContainer 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: Asset returns matrix.mu: Mean vector.sigma: Covariance matrix.chol: Cholesky factorisation of the factor-adjusted covariance matrix. Factor models sparsify the covariance matrix, so using their smaller, sparser Cholesky factor makes for more numerically stable and efficient optimisations.w: Asset weights.ens: Effective number of scenarios.kld: Kullback-Leibler divergence.ow: Opinion pooling weights.rr: Regression result.f_mu: Factor mean vector.f_sigma: Factor covariance matrix.f_w: Factor weights.
Constructor
LowOrderPrior(; X::AbstractMatrix, mu::AbstractVector, sigma::AbstractMatrix,
chol::Union{Nothing, <:AbstractMatrix} = nothing,
w::Union{Nothing, <:AbstractWeights} = nothing,
ens::Union{Nothing, <:Real} = nothing,
kld::Union{Nothing, <:Real, <:AbstractVector{<:Real}} = nothing,
ow::Union{Nothing, <:AbstractVector} = nothing,
rr::Union{Nothing, <:Regression} = nothing,
f_mu::Union{Nothing, <:AbstractVector} = nothing,
f_sigma::Union{Nothing, <:AbstractMatrix} = nothing,
f_w::Union{Nothing, <:AbstractVector} = nothing)Keyword arguments correspond to the fields above.
Validation
X,mu, andsigmamust be non-empty.size(sigma, 1) == size(sigma, 2).size(X, 2) == length(mu) == size(sigma, 1).If
wis provided,!isempty(w)andlength(w) == size(X, 1).If
kldis anAbstractVector,!isempty(kld).If
owis provided,!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 provided, it must be square andsize(f_sigma, 1) == size(rr.M, 2).If
cholis provided,!isempty(chol)andlength(mu) == size(chol, 2).If
f_wis provided,!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{T1, T2, T3, T4, T5, T6, T7} <: AbstractPriorResult
pr::T1
kt::T2
L2::T3
S2::T4
sk::T5
V::T6
skmp::T7
endContainer 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 for low order moments.kt: Cokurtosis tensor.L2: Elimination matrix.S2: Summation matrix.sk: Coskewness tensor.V: Negative quadratic skewness matrix.skmp: Matrix processing estimator for post-processing quadratic skewness.
Constructor
HighOrderPrior(; pr::AbstractPriorResult, kt::Union{Nothing, <:AbstractMatrix} = nothing,
L2::Union{Nothing, <:AbstractMatrix} = nothing,
S2::Union{Nothing, <:AbstractMatrix} = nothing,
sk::Union{Nothing, <:AbstractMatrix} = nothing,
V::Union{Nothing, <:AbstractMatrix} = nothing,
skmp::Union{Nothing, <:AbstractMatrixProcessingEstimator} = DefaultMatrixProcessing())Keyword arguments correspond to the fields above.
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),
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}
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 ┴ 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::ClusteringEstimator, 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
sourcePortfolioOptimisers.AbstractPriorEstimator Type
abstract type AbstractPriorEstimator <: AbstractEstimator endAbstract 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 <: AbstractPriorEstimator endAbstract 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 <: AbstractLowOrderPriorEstimator endLow 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 <: AbstractLowOrderPriorEstimator endLow 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 <: AbstractLowOrderPriorEstimator endLow 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 <: AbstractPriorEstimator endAbstract 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 <: AbstractResult endAbstract 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
source