Normal Uncertainty Sets
PortfolioOptimisers.NormalUncertaintySet Type
struct NormalUncertaintySet{T1, T2, T3, T4, T5, T6, T7} <: AbstractUncertaintySetEstimator
pe::T1
alg::T2
n_sim::T3
q::T4
rng::T5
seed::T6
ens::T7
endEstimator for box or ellipsoidal uncertainty sets under the assumption of normally distributed returns in portfolio optimisation.
Fields
pe: Prior estimator used to compute mean and covariance statistics.alg: Uncertainty set algorithm (box or ellipsoidal).n_sim: Number of simulations for uncertainty set estimation.q: Quantile or confidence level for uncertainty set bounds.rng: Random number generator for simulation.seed: Optional random seed for reproducibility.ens: Optional effective number of scenarios used for scaling the uncertainty sets.
Constructors
NormalUncertaintySet(; pe::AbstractLowOrderPriorEstimator = EmpiricalPrior(),
alg::AbstractUncertaintySetAlgorithm = BoxUncertaintySetAlgorithm(),
n_sim::Integer = 3_000, q::Number = 0.05,
rng::Random.AbstractRNG = Random.default_rng(),
seed::Option{<:Integer} = nothing, ens::Option{<:Number} = nothing)Keyword arguments correspond to the fields above.
Validation
n_sim > 0.0 < q < 1.
Examples
julia> NormalUncertaintySet()
NormalUncertaintySet
pe ┼ EmpiricalPrior
│ ce ┼ PortfolioOptimisersCovariance
│ │ ce ┼ Covariance
│ │ │ me ┼ SimpleExpectedReturns
│ │ │ │ w ┼ nothing
│ │ │ │ idx ┴ nothing
│ │ │ ce ┼ GeneralCovariance
│ │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
│ │ │ │ w ┼ nothing
│ │ │ │ idx ┴ nothing
│ │ │ alg ┴ Full()
│ │ mp ┼ DenoiseDetoneAlgMatrixProcessing
│ │ │ pdm ┼ Posdef
│ │ │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton
│ │ │ │ kwargs ┴ @NamedTuple{}: NamedTuple()
│ │ │ dn ┼ nothing
│ │ │ dt ┼ nothing
│ │ │ alg ┼ nothing
│ │ │ order ┴ DenoiseDetoneAlg()
│ me ┼ SimpleExpectedReturns
│ │ w ┼ nothing
│ │ idx ┴ nothing
│ horizon ┴ nothing
alg ┼ BoxUncertaintySetAlgorithm()
n_sim ┼ Int64: 3000
q ┼ Float64: 0.05
rng ┼ Random.TaskLocalRNG: Random.TaskLocalRNG()
seed ┼ nothing
ens ┴ nothingRelated
PortfolioOptimisers.ucs Function
ucs(ue::NormalUncertaintySet{<:Any, <:BoxUncertaintySetAlgorithm, <:Any, <:Any, <:Any},
X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs box uncertainty sets for mean and covariance statistics under the assumption of normally distributed returns.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mu_ucs::BoxUncertaintySet: Expected returns uncertainty set.sigma_ucs::BoxUncertaintySet: Covariance uncertainty sets.
Details
Computes prior statistics using the provided prior estimator.
Simulates covariance matrices using the Wishart distribution.
Computes lower and upper bounds for covariance using quantiles of simulated values.
Computes upper bound for mean using the normal quantile and simulated covariance.
Returns both sets as a tuple.
Related
sourcePortfolioOptimisers.ucs Function
ucs(ue::NormalUncertaintySet{<:Any,
<:EllipsoidalUncertaintySetAlgorithm{<:NormalKUncertaintyAlgorithm, <:Any},
<:Any, <:Any, <:Any},
X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs ellipsoidal uncertainty sets for expected returns and covariance statistics under the assumption of normally distributed returns.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mu_ucs::EllipsoidalUncertaintySet: Expected returns uncertainty set.sigma_ucs::EllipsoidalUncertaintySet: Covariance uncertainty sets.
Details
Computes prior statistics using the provided prior estimator.
Simulates mean and covariance using multivariate normal and Wishart distributions.
Constructs commutation matrix for covariance vectorization.
Computes scaling parameters for mean and covariance using the specified ellipsoidal algorithm.
Returns both sets as a tuple.
Related
sourcePortfolioOptimisers.ucs Function
ucs(ue::NormalUncertaintySet{<:Any,
<:EllipsoidalUncertaintySetAlgorithm{<:ChiSqKUncertaintyAlgorithm, <:Any},
<:Any, <:Any, <:Any},
X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs ellipsoidal uncertainty sets for expected returns and covariance statistics using the chi-squared scaling algorithm under the assumption of normally distributed returns.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mu_ucs::EllipsoidalUncertaintySet: Expected returns uncertainty set.sigma_ucs::EllipsoidalUncertaintySet: Covariance uncertainty sets.
Details
Computes prior statistics using the provided prior estimator.
Constructs commutation matrix for covariance vectorization.
Computes scaling parameters for mean and covariance using the chi-squared scaling algorithm.
Applies diagonal processing if specified in the algorithm.
Returns both sets as a tuple.
Related
PortfolioOptimisers.ucs Function
ucs(ue::NormalUncertaintySet{<:Any, <:EllipsoidalUncertaintySetAlgorithm{<:Any, <:Any},
<:Any, <:Any, <:Any}, X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs ellipsoidal uncertainty sets for expected returns and covariance statistics under the assumption of normally distributed returns, using a generic ellipsoidal algorithm.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mu_ucs::EllipsoidalUncertaintySet: Expected returns uncertainty set.sigma_ucs::EllipsoidalUncertaintySet: Covariance uncertainty sets.
Details
Computes prior statistics using the provided prior estimator.
Constructs commutation matrix for covariance vectorization.
Computes scaling parameters for mean and covariance using the provided ellipsoidal algorithm.
Applies diagonal processing if specified in the algorithm.
Returns both sets as a tuple.
Related
sourcePortfolioOptimisers.mu_ucs Function
mu_ucs(ue::NormalUncertaintySet{<:Any, <:BoxUncertaintySetAlgorithm, <:Any, <:Any, <:Any},
X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs a box uncertainty set for expected returns under the assumption of normally distributed returns.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mu_ucs::BoxUncertaintySet: Expected returns uncertainty set.
Details
Computes prior statistics using the provided prior estimator.
Computes the upper bound for mean using the normal quantile and simulated covariance.
Sets the lower bound for mean to zero.
Ignores additional arguments and keyword arguments except those passed to the prior estimator.
Related
sourcePortfolioOptimisers.mu_ucs Function
mu_ucs(ue::NormalUncertaintySet{<:Any,
<:EllipsoidalUncertaintySetAlgorithm{<:NormalKUncertaintyAlgorithm, <:Any},
<:Any, <:Any, <:Any},
X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs an ellipsoidal uncertainty set for expected returns under the assumption of normally distributed returns, using a normal scaling algorithm.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mu_ucs::EllipsoidalUncertaintySet: Expected returns uncertainty set.
Details
Computes prior statistics using the provided prior estimator.
Simulates mean vectors using the multivariate normal distribution.
Applies diagonal processing to the covariance if specified in the algorithm.
Computes the scaling parameter for the ellipsoidal using the normal scaling algorithm.
Returns an ellipsoidal uncertainty set for the mean.
Related
sourcePortfolioOptimisers.mu_ucs Function
mu_ucs(ue::NormalUncertaintySet{<:Any,
<:EllipsoidalUncertaintySetAlgorithm{<:ChiSqKUncertaintyAlgorithm, <:Any},
<:Any, <:Any, <:Any},
X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs an ellipsoidal uncertainty set for expected returns under the assumption of normally distributed returns, using a chi-squared scaling algorithm.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mu_ucs::EllipsoidalUncertaintySet: Expected returns uncertainty set.
Details
Computes prior statistics using the provided prior estimator.
Processes the covariance matrix for positive definiteness.
Applies diagonal processing to the covariance if specified in the algorithm.
Computes the scaling parameter for the ellipsoidal using the chi-squared scaling algorithm.
Returns an ellipsoidal uncertainty set for the mean.
Related
PortfolioOptimisers.mu_ucs Function
mu_ucs(ue::NormalUncertaintySet{<:Any,
<:EllipsoidalUncertaintySetAlgorithm{<:ChiSqKUncertaintyAlgorithm, <:Any},
<:Any, <:Any, <:Any},
X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs an ellipsoidal uncertainty set for expected returns under the assumption of normally distributed returns, using a chi-squared scaling algorithm.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mu_ucs::EllipsoidalUncertaintySet: Expected returns uncertainty set.
Details
Computes prior statistics using the provided prior estimator.
Processes the covariance matrix for positive definiteness.
Applies diagonal processing to the covariance if specified in the algorithm.
Computes the scaling parameter for the ellipsoidal using the chi-squared scaling algorithm.
Returns an ellipsoidal uncertainty set for the mean.
Related
PortfolioOptimisers.sigma_ucs Function
sigma_ucs(ue::NormalUncertaintySet{<:Any, <:BoxUncertaintySetAlgorithm, <:Any, <:Any, <:Any},
X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs a box uncertainty set for covariance under the assumption of normally distributed returns.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
sigma_ucs::BoxUncertaintySet: Covariance uncertainty set.
Details
Computes prior statistics using the provided prior estimator.
Simulates covariance matrices using the Wishart distribution.
Computes lower and upper bounds for covariance using quantiles of simulated values.
Ensures positive definiteness of the bounds.
Ignores additional arguments and keyword arguments except those passed to the prior estimator.
Related
sourcePortfolioOptimisers.sigma_ucs Function
sigma_ucs(ue::NormalUncertaintySet{<:Any,
<:EllipsoidalUncertaintySetAlgorithm{<:NormalKUncertaintyAlgorithm, <:Any},
<:Any, <:Any, <:Any},
X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs an ellipsoidal uncertainty set for covariance under the assumption of normally distributed returns, using a normal scaling algorithm.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
sigma_ucs::EllipsoidalUncertaintySet: Covariance uncertainty set.
Details
Computes prior statistics using the provided prior estimator.
Simulates covariance matrices using the Wishart distribution.
Constructs commutation matrix for covariance vectorization.
Computes the scaling parameter for the ellipsoidal using the normal scaling algorithm.
Applies diagonal processing to the covariance if specified in the algorithm.
Returns an ellipsoidal uncertainty set for covariance.
Related
sourcePortfolioOptimisers.sigma_ucs Function
sigma_ucs(ue::NormalUncertaintySet{<:Any,
<:EllipsoidalUncertaintySetAlgorithm{<:ChiSqKUncertaintyAlgorithm, <:Any},
<:Any, <:Any, <:Any},
X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs an ellipsoidal uncertainty set for covariance under the assumption of normally distributed returns, using a chi-squared scaling algorithm.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
sigma_ucs::EllipsoidalUncertaintySet: Covariance uncertainty set.
Details
Computes prior statistics using the provided prior estimator.
Processes the covariance matrix for positive definiteness.
Constructs commutation matrix for covariance vectorization.
Computes the scaling parameter for the ellipsoidal using the chi-squared scaling algorithm.
Applies diagonal processing to the covariance if specified in the algorithm.
Returns an ellipsoidal uncertainty set for covariance.
Related
PortfolioOptimisers.sigma_ucs Function
sigma_ucs(ue::NormalUncertaintySet{<:Any,
<:EllipsoidalUncertaintySetAlgorithm{<:Any, <:Any},
<:Any, <:Any, <:Any}, X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs an ellipsoidal uncertainty set for covariance under the assumption of normally distributed returns, using a generic ellipsoidal algorithm.
Arguments
ue: Normal uncertainty set estimator.X: Data matrix.F: Optional factor matrix. Used by the prior estimator.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
sigma_ucs::EllipsoidalUncertaintySet: Covariance uncertainty set.
Details
Computes prior statistics using the provided prior estimator.
Processes the covariance matrix for positive definiteness.
Constructs commutation matrix for covariance vectorization.
Computes the scaling parameter for the ellipsoidal using the provided ellipsoidal algorithm.
Applies diagonal processing to the covariance if specified in the algorithm.
Returns an ellipsoidal uncertainty set for covariance.
Related
sourcePortfolioOptimisers.commutation_matrix Function
commutation_matrix(X::MatNum)Constructs the commutation matrix for a given matrix.
Arguments
X: Input matrix. Used to determine the dimensions of the commutation matrix.
Returns
cX::SparseArrays.SparseMatrixCSC{<:Number, <:Integer}: Returns a sparse commutation matrix of size(m*n, m*n)wherem, n = size(X).
Details
The commutation matrix is used to vectorize and permute matrix elements.
It is constructed by reshaping and transposing the indices of the input matrix.
The output is a sparse matrix for efficiency.
Examples
julia> PortfolioOptimisers.commutation_matrix(rand(2, 2))
4×4 SparseArrays.SparseMatrixCSC{Float64, Int64} with 4 stored entries:
1.0 ⋅ ⋅ ⋅
⋅ ⋅ 1.0 ⋅
⋅ 1.0 ⋅ ⋅
⋅ ⋅ ⋅ 1.0
julia> PortfolioOptimisers.commutation_matrix(rand(2, 3))
6×6 SparseArrays.SparseMatrixCSC{Float64, Int64} with 6 stored entries:
1.0 ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ 1.0 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ 1.0 ⋅
⋅ 1.0 ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 1.0 ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ 1.0
julia> PortfolioOptimisers.commutation_matrix(rand(3, 2))
6×6 SparseArrays.SparseMatrixCSC{Float64, Int64} with 6 stored entries:
1.0 ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 1.0 ⋅ ⋅
⋅ 1.0 ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ 1.0 ⋅
⋅ ⋅ 1.0 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ 1.0