Bootstrap Uncertainty Sets
PortfolioOptimisers.StationaryBootstrap Type
struct StationaryBootstrap <: ARCHBootstrapSetBootstrap algorithm for constructing uncertainty sets using a stationary bootstrap [13] in time series data. Blocks have geometrically distributed random lengths with mean block_size, and wrap around the end of the sample.
Related
sourcePortfolioOptimisers.CircularBootstrap Type
struct CircularBootstrap <: ARCHBootstrapSetBootstrap algorithm for constructing uncertainty sets using a circular block bootstrap [14] in time series data. Blocks have fixed length block_size and wrap around the end of the sample.
Related
sourcePortfolioOptimisers.MovingBootstrap Type
struct MovingBootstrap <: ARCHBootstrapSetBootstrap algorithm for constructing uncertainty sets using a moving block bootstrap [15] in time series data. Blocks have fixed length block_size and do not wrap around the end of the sample.
Related
sourcePortfolioOptimisers.ARCHUncertaintySet Type
struct ARCHUncertaintySet{__T_pe, __T_ce, __T_me, __T_alg, __T_n_sim, __T_block_size, __T_q, __T_rng, __T_seed, __T_bootstrap, __T_kwargs} <: BootstrapUncertaintySetEstimatorEstimator for box or ellipsoidal uncertainty sets using bootstrap methods for time series data in portfolio optimisation.
Fields
pe: Prior estimator.ce: Covariance estimator.me: Expected returns estimator.alg: Uncertainty set algorithm.n_sim: Number of simulation samples.block_size: Block size for bootstrap sampling.q: Confidence level that sizes the uncertainty set (0 < q < 1). A smallerqis more demanding and yields a larger, more conservative set (wider box intervals / larger ellipsoid radius); a largerqgives a tighter set closer to the point estimate.rng: Random number generator.seed: Seed for the random number generator.bootstrap: Bootstrap algorithm.kwargs: Additional keyword arguments.
Constructors
ARCHUncertaintySet(;
pe::AbstractLowOrderPriorEstimator = EmpiricalPrior(),
ce::StatsBase.CovarianceEstimator = PortfolioOptimisersCovariance(),
me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns(),
alg::AbstractUncertaintySetAlgorithm = BoxUncertaintySetAlgorithm(),
n_sim::Integer = 3_000,
block_size::Integer = 3,
q::Number = 0.05,
rng::Random.AbstractRNG = Random.default_rng(),
seed::Option{<:Integer} = nothing,
bootstrap::ARCHBootstrapSet = StationaryBootstrap(),
kwargs::NamedTuple = (;),
) -> ARCHUncertaintySetKeywords correspond to the struct's fields.
Validation
n_sim > 0.block_size > 0.0 < q < 1.
Examples
julia> ARCHUncertaintySet()
ARCHUncertaintySet
pe ┼ EmpiricalPrior
│ ce ┼ PortfolioOptimisersCovariance
│ │ ce ┼ Covariance
│ │ │ me ┼ SimpleExpectedReturns
│ │ │ │ w ┴ nothing
│ │ │ ce ┼ GeneralCovariance
│ │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
│ │ │ │ w ┴ nothing
│ │ │ alg ┴ FullMoment()
│ │ 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
ce ┼ PortfolioOptimisersCovariance
│ ce ┼ Covariance
│ │ me ┼ SimpleExpectedReturns
│ │ │ w ┴ nothing
│ │ ce ┼ GeneralCovariance
│ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
│ │ │ w ┴ nothing
│ │ alg ┴ FullMoment()
│ 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
alg ┼ BoxUncertaintySetAlgorithm()
n_sim ┼ Int64: 3000
block_size ┼ Int64: 3
q ┼ Float64: 0.05
rng ┼ Random.TaskLocalRNG: Random.TaskLocalRNG()
seed ┼ nothing
bootstrap ┼ StationaryBootstrap()
kwargs ┴ @NamedTuple{}: NamedTuple()Related
PortfolioOptimisers.ucs Function
ucs(ue::ARCHUncertaintySet{<:Any, <:Any, <:Any, <:BoxUncertaintySetAlgorithm, <:Any, <:Any,
<:Any, <:Any, <:Any}, X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs box uncertainty sets for expected returns and covariance statistics using bootstrap resampling for time series data.
Mathematical definition
Generate
Where:
, : Lower/upper bounds for expected return of asset . , : Lower/upper covariance bounds. , : Quantile functions at level . : Bootstrap mean for asset in sample . : Bootstrap covariance element in sample . : Significance level.
Arguments
ue: ARCH uncertainty set estimator.X: Data matrix to be resampled.F: Optional factor matrix. Used by the prior estimator.dims: Dimension 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 set.
Details
Computes prior statistics using the provided prior estimator.
Generates bootstrap samples of expected returns and covariance using the specified bootstrap algorithm.
Computes lower and upper bounds for expected returns and covariance using quantiles of bootstrapped samples.
Returns both sets as a tuple.
Related
PortfolioOptimisers.ucs Function
ucs(ue::ARCHUncertaintySet{<:Any, <:Any, <: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 using bootstrap resampling for time series data.
Mathematical definition
Compute bootstrap deviations
Then form ellipsoidal sets:
Where:
: Empirical covariance of bootstrap mean deviations. : Empirical covariance of bootstrap covariance deviations (vectorised). , : Estimated mean and covariance. , : Bootstrap deviations for mean and covariance. : Ellipsoidal uncertainty set for expected returns. : Ellipsoidal uncertainty set for covariance. , : Empirically fitted scaling parameters.
Arguments
ue: ARCH uncertainty set estimator. Contains prior estimator, ellipsoidal algorithm, simulation parameters, block size, quantile, rng, seed, and bootstrap type.X: Data matrix to be resampled.F: Optional factor matrix. Used by the prior estimator.dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mu_ucs::EllipsoidalUncertaintySet: Ellipsoidal uncertainty set for expected returns.sigma_ucs::EllipsoidalUncertaintySet: Ellipsoidal uncertainty set for covariance.
Details
Computes prior statistics using the provided prior estimator.
Generates bootstrap samples of expected returns and covariance using the specified bootstrap algorithm.
Computes deviations from prior statistics for each bootstrap sample.
Computes covariance matrices of deviations and constructs ellipsoidal uncertainty sets using the specified method and quantile.
Returns both sets as a tuple.
Related
PortfolioOptimisers.mu_ucs Function
mu_ucs(ue::ARCHUncertaintySet{<:Any, <:Any, <:Any, <:BoxUncertaintySetAlgorithm, <:Any, <:Any,
<:Any, <:Any, <:Any}, X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs a box uncertainty set for expected returns using bootstrap resampling for time series data.
Mathematical definition
Where:
, : Lower/upper bounds for expected return of asset . , : Quantile functions at level . : Bootstrap mean for asset in sample . : Significance level.
Arguments
ue: ARCH uncertainty set estimator.X: Data matrix to be resampled.F: Optional factor matrix. Used by the prior estimator.dims: Dimension 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.
Generates bootstrap samples of expected returns using the specified bootstrap algorithm.
Computes lower and upper bounds for expected returns using quantiles of bootstrapped samples.
Returns the expected returns box uncertainty set.
Related
PortfolioOptimisers.mu_ucs Function
mu_ucs(ue::ARCHUncertaintySet{<:Any, <:Any, <:Any, <:EllipsoidalUncertaintySetAlgorithm, <:Any, <:Any,
<:Any, <:Any, <:Any}, X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs an ellipsoidal uncertainty set for expected returns using bootstrap resampling for time series data.
Mathematical definition
Where:
: Empirical covariance of bootstrap mean deviations. : Estimated mean vector. : Ellipsoidal uncertainty set for expected returns. : Empirically fitted scaling parameter.
Arguments
ue: ARCH uncertainty set estimator. Contains prior estimator, ellipsoidal algorithm, simulation parameters, block size, quantile, rng, seed, and bootstrap type.X: Data matrix to be resampled.F: Optional factor matrix. Used by the prior estimator.dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mu_ucs::EllipsoidalUncertaintySet: Ellipsoidal uncertainty set for expected returns.
Details
Computes prior statistics using the provided prior estimator.
Generates bootstrap samples of expected returns using the specified bootstrap algorithm.
Computes deviations from prior expected returns for each bootstrap sample.
Computes the covariance matrix of deviations and constructs an ellipsoidal uncertainty set using the specified method and quantile.
Returns the expected returns ellipsoidal uncertainty set.
Related
PortfolioOptimisers.sigma_ucs Function
sigma_ucs(ue::ARCHUncertaintySet{<:Any, <:Any, <:Any, <:BoxUncertaintySetAlgorithm, <:Any, <:Any,
<:Any, <:Any, <:Any}, X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs a box uncertainty set for covariance using bootstrap resampling for time series data.
Mathematical definition
Where:
, : Lower/upper covariance bounds. , : Quantile functions at level . : Bootstrap covariance element in sample . : Significance level.
Arguments
ue: ARCH uncertainty set estimator. Contains prior estimator, box algorithm, simulation parameters, block size, quantile, rng, seed, and bootstrap type.X: Data matrix to be resampled.F: Optional factor matrix. Used by the prior estimator.dims: Dimension 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.
Generates bootstrap samples of covariance using the specified bootstrap algorithm.
Computes lower and upper bounds for covariance using quantiles of bootstrapped samples.
Returns the covariance box uncertainty set.
Related
PortfolioOptimisers.sigma_ucs Function
sigma_ucs(ue::ARCHUncertaintySet{<:Any, <:Any, <:Any, <:EllipsoidalUncertaintySetAlgorithm, <:Any, <:Any,
<:Any, <:Any, <:Any}, X::MatNum,
F::Option{<:MatNum} = nothing; dims::Int = 1, kwargs...)Constructs an ellipsoidal uncertainty set for covariance using bootstrap resampling for time series data.
Mathematical definition
Where:
: Empirical covariance of bootstrap covariance deviations (vectorised). : Estimated covariance matrix. : Ellipsoidal uncertainty set for covariance. : Empirically fitted scaling parameter.
Arguments
ue: ARCH uncertainty set estimator. Contains prior estimator, ellipsoidal algorithm, simulation parameters, block size, quantile, rng, seed, and bootstrap type.X: Data matrix to be resampled.F: Optional factor matrix. Used by the prior estimator.dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
sigma_ucs::EllipsoidalUncertaintySet: Ellipsoidal uncertainty set for covariance.
Details
Computes prior statistics using the provided prior estimator.
Generates bootstrap samples of covariance using the specified bootstrap algorithm.
Computes deviations from prior covariance for each bootstrap sample.
Computes the covariance matrix of deviations and constructs an ellipsoidal uncertainty set using the specified method and quantile.
Returns the covariance ellipsoidal uncertainty set.
Related
PortfolioOptimisers.BootstrapUncertaintySetEstimator Type
abstract type BootstrapUncertaintySetEstimator <: AbstractUncertaintySetEstimatorAbstract type for estimators that construct uncertainty sets using bootstrap methods in portfolio optimisation.
Subtypes implement specific bootstrap algorithms (e.g., stationary, circular, moving block) to estimate uncertainty sets for risk or prior statistics.
Related
sourcePortfolioOptimisers.ARCHBootstrapSet Type
abstract type ARCHBootstrapSet <: AbstractAlgorithmAbstract type for bootstrap algorithms used in constructing uncertainty sets for time series data in portfolio optimisation.
Subtypes implement specific block bootstrap methods for dependent (time series) data.
Related
sourcePortfolioOptimisers.bootstrap_indices Function
bootstrap_indices(alg::ARCHBootstrapSet, rng::Random.AbstractRNG, T::Integer,
block_size::Integer)Generate a vector of T observation indices for one block bootstrap resample.
Arguments
alg: Bootstrap algorithm type.rng: Random number generator.T: Number of observations in the sample being resampled.block_size: Size of blocks for resampling. Mean block length forStationaryBootstrap, fixed block length otherwise.
Returns
idx::Vector{Int}: Indices in1:Tselecting the rows of one bootstrap resample.
Details
StationaryBootstrap: each index either continues the previous block (wrapping aroundT) or, with probability1 / block_size, starts a new block at a uniformly random position, yielding geometrically distributed block lengths [13].CircularBootstrap: fixed-length blocks with uniformly random starts, wrapping aroundT[14].MovingBootstrap: fixed-length blocks with uniformly random starts in1:(T - block_size + 1), no wrap-around [15].
Validation
MovingBootstraprequiresblock_size <= T.
Related
sourcePortfolioOptimisers.bootstrap_generator Function
bootstrap_generator(ue::ARCHUncertaintySet, X::MatNum; kwargs...)Generates bootstrapped samples of expected returns and covariance statistics for time series data using the specified bootstrap algorithm.
Arguments
ue: ARCH uncertainty set estimator.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mus::Matrix{<:Number}: Matrix of bootstrapped expected return vectors (size(X, 2) × ue.n_sim).sigmas::Array{<:Number, 3}): Array of bootstrapped covariance matrices (size(X, 2) × size(X, 2) × ue.n_sim).
Details
Uses the bootstrap algorithm specified in
ue.bootstrapto generate resampled datasets.If
ue.seedis provided, seedsue.rngbefore resampling for reproducibility.For each bootstrap sample, computes the expected return and covariance using the prior estimator in
ue.pe.Stores the bootstrapped expected returns and covariances for uncertainty set estimation.
Related
sourcePortfolioOptimisers.mu_bootstrap_generator Function
mu_bootstrap_generator(ue::ARCHUncertaintySet, X::MatNum; kwargs...)Generates bootstrap samples of expected return vectors for returns data using the specified bootstrap algorithm.
Arguments
ue: ARCH uncertainty set estimator.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
mus::Matrix{<:Number}: Matrix of bootstrapped expected return vectors (size(X, 2) × ue.n_sim).
Details
Uses the bootstrap algorithm specified in
ue.bootstrapto generate resampled datasets.If
ue.seedis provided, seedsue.rngbefore resampling for reproducibility.For each bootstrap sample, computes the expected return using the prior estimator in
ue.pe.Stores the bootstrapped expected returns for uncertainty set estimation.
Related
sourcePortfolioOptimisers.sigma_bootstrap_generator Function
sigma_bootstrap_generator(ue::ARCHUncertaintySet, X::MatNum; kwargs...)Generates bootstrap samples of covariance matrices for time series data using the specified bootstrap algorithm.
Arguments
ue: ARCH uncertainty set estimator.kwargs...: Additional keyword arguments passed to the prior estimator.
Returns
sigmas::Array{<:Number, 3}: Array of bootstrapped covariance matrices (size(X, 2) × size(X, 2) × ue.n_sim).
Details
Uses the bootstrap algorithm specified in
ue.bootstrapto generate resampled datasets.If
ue.seedis provided, seedsue.rngbefore resampling for reproducibility.For each bootstrap sample, computes the covariance using the prior estimator in
ue.pe.Stores the bootstrapped covariances for uncertainty set estimation.
Related
source