Bootstrap Uncertainty Sets: private API

PortfolioOptimisers.bootstrap_generator — Function
bootstrap_generator(ue::ARCHUncertaintySet, X::MatNum; kwargs...)

Refits the mean and the covariance on every block bootstrap resample of X, in one pass over one index stream.

The function fits both statistics on the same resample. So a caller that needs both axes gets them from ue.n_sim index vectors, and not from two runs of ue.n_sim index vectors each.

Algorithm

  1. Read the observation count T from X. Allocate mus and sigmas.
  2. Resolve the generator with resolve_rng to get rng. If ue.seed is set, rng is a private reseeded copy. The stream then starts at the same place on every call, and ue.rng does not advance. If ue.seed is nothing, rng is ue.rng, and the stream continues from the end of the previous call.
  3. For each of the ue.n_sim simulations, draw one index vector with bootstrap_indices. Take those rows of X to get the resample Xi.
  4. Fit ue.me on Xi to get one column of mus.
  5. Fit ue.ce on Xi to get one slice of sigmas. Steps 4 and 5 read the same Xi, so the two statistics of one simulation come from one resample.
  6. Return mus and sigmas. This function does not read ue.pe.

Arguments

  • ue: ARCH uncertainty set estimator.
  • X: Data matrix that the function resamples, with one row per observation.
  • kwargs...: More keyword arguments, which the function gives to ue.me and ue.ce.

Returns

  • mus::Matrix{<:Number}: Bootstrap expected returns, with one column per simulation. Its size is size(X, 2) × ue.n_sim.
  • sigmas::Array{<:Number, 3}: Bootstrap covariance matrices, with one slice per simulation. Its size is size(X, 2) × size(X, 2) × ue.n_sim.

Related

source
PortfolioOptimisers.mu_bootstrap_generator — Function
mu_bootstrap_generator(ue::ARCHUncertaintySet, X::MatNum; kwargs...)

Refits the mean on every block bootstrap resample of X, and fits no covariance.

The function draws its index vectors as bootstrap_generator does, one vector per simulation. If ue.seed is set, the stream starts at the same place on every call, so this function sees the same resamples as the other two generators. If ue.seed is nothing, the three generators read different parts of one shared stream.

Algorithm

  1. Read the observation count T from X. Allocate mus.
  2. Resolve the generator with resolve_rng to get rng. If ue.seed is set, rng is a private reseeded copy. The stream then starts at the same place on every call, and ue.rng does not advance. If ue.seed is nothing, rng is ue.rng, and the stream continues from the end of the previous call.
  3. For each of the ue.n_sim simulations, draw one index vector with bootstrap_indices. Take those rows of X to get the resample Xi.
  4. Fit ue.me on Xi to get one column of mus.
  5. Return mus. This function reads neither ue.ce nor ue.pe.

Arguments

  • ue: ARCH uncertainty set estimator.
  • X: Data matrix that the function resamples, with one row per observation.
  • kwargs...: More keyword arguments, which the function gives to ue.me.

Returns

  • mus::Matrix{<:Number}: Bootstrap expected returns, with one column per simulation. Its size is size(X, 2) × ue.n_sim.

Related

source
PortfolioOptimisers.sigma_bootstrap_generator — Function
sigma_bootstrap_generator(ue::ARCHUncertaintySet, X::MatNum; kwargs...)

Refits the covariance on every block bootstrap resample of X, and fits no mean.

The function draws its index vectors as bootstrap_generator does, one vector per simulation. If ue.seed is set, the stream starts at the same place on every call, so this function sees the same resamples as the other two generators. If ue.seed is nothing, the three generators read different parts of one shared stream.

Algorithm

  1. Read the observation count T from X. Allocate sigmas.
  2. Resolve the generator with resolve_rng to get rng. If ue.seed is set, rng is a private reseeded copy. The stream then starts at the same place on every call, and ue.rng does not advance. If ue.seed is nothing, rng is ue.rng, and the stream continues from the end of the previous call.
  3. For each of the ue.n_sim simulations, draw one index vector with bootstrap_indices. Take those rows of X to get the resample Xi.
  4. Fit ue.ce on Xi to get one slice of sigmas. On the ellipsoidal route, this is the first of the two fits of ue.ce.
  5. Return sigmas. This function reads neither ue.me nor ue.pe.

Arguments

  • ue: ARCH uncertainty set estimator.
  • X: Data matrix that the function resamples, with one row per observation.
  • kwargs...: More keyword arguments, which the function gives to ue.ce.

Returns

  • sigmas::Array{<:Number, 3}: Bootstrap covariance matrices, with one slice per simulation. Its size is size(X, 2) × size(X, 2) × ue.n_sim.

Related

source
PortfolioOptimisers.bootstrap_ellipsoidal_set — Function
bootstrap_ellipsoidal_set(
    ue::ARCHUncertaintySet,
    X::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
    cov::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
    class::AbstractUncertaintySetClass,
    val::AbstractArray{<:Union{Number, AbstractJuMPScalar}}
) -> EllipsoidalUncertaintySet{var"#s185", var"#s1851", var"#s1852", <:AbstractArray{var"#s166", N}} where {var"#s166"<:Union{Number, AbstractJuMPScalar}, var"#s185"<:AbstractMatrix{var"#s166"}, var"#s1851"<:Number, var"#s1852"<:AbstractUncertaintySetClass, var"#s166"<:Union{Number, AbstractJuMPScalar}, N}

Builds the EllipsoidalUncertaintySet of a bootstrap estimator from the bootstrap deviations and their sample covariance.

The shape is the sample covariance of the $M$ rows of X, so its rank is at most $M - 1$. If $M - 1$ is less than the dimension of the set, the repaired shape is flat in the other directions. A chi-squared radius at the full dimension is then too large for the set. So the degrees of freedom are the dimension of the set, capped at $M - 1$. This is the rank that norm_ball_deviation_set measures on the same sample, so the two routes of one bootstrap set give one radius.

Algorithm

  1. Calculate df = ucs_dimension(class, ue.alg.diagonal, size(X, 2), size(X, 1)). This is the dimension of the set, capped at the number of rows of X minus one.
  2. Build the set with ellipsoidal_set on ue.alg, ue.q, X, cov, class, val and df.

Arguments

  • ue: Bootstrap uncertainty set estimator. It gives the set algorithm and the significance level.
  • X: Bootstrap deviations, with one row per resample.
  • cov: Sample covariance of X. It becomes the shape matrix.
  • class: Axis tag of the set.
  • val: Centre of the set. It is the fitted expected returns on the mean axis, and the fitted covariance on the covariance axis.

Returns

  • ucs::EllipsoidalUncertaintySet: The set.

Related

source