skfolio.uncertainty_set
.BootstrapCovarianceUncertaintySet#
- class skfolio.uncertainty_set.BootstrapCovarianceUncertaintySet(prior_estimator=None, confidence_level=0.95, diagonal=True, n_bootstrap_samples=1000, block_size=None, seed=None)[source]#
Bootstrap Covariance Uncertainty set.
Compute the covariance ellipsoidal uncertainty set using circular bootstrap:
\[U_{\Sigma}=\left\{\Sigma\,|\left(\text{vec}(\Sigma)-\text{vec}(\hat{\Sigma})\right)S^{-1}\left(\text{vec}(\Sigma)-\text{vec}(\hat{\Sigma})\right)^{T}\leq k^{2}\,,\,\Sigma\succeq 0\right\}\]The size of the ellipsoid \(\kappa\) (confidence region), is computed using:
\[\kappa^2 = \chi^2_{n\_assets^2} (\beta)\]with \(\chi^2_{n\_assets^2}(\beta)\) the inverse cumulative distribution function of the chi-squared distribution with
n_assets
degrees of freedom at the \(\beta\) confidence level.The Shape of the ellipsoid \(S\) is computed using stationary bootstrap with the option to force the non-diagonal elements of the covariance matrix to zero.
- Parameters:
- prior_estimatorBasePrior, optional
The prior estimator used to estimate the assets covariance matrix. The default (
None
) is to useEmpiricalPrior
.- confidence_levelfloat , default=0.95
Confidence level \(\beta\) of the inverse cumulative distribution function of the chi-squared distribution. The default value is
0.95
.- diagonalbool, default=True
If this is set to True, the non-diagonal elements of the covariance matrix are set to zero.
- n_bootstrap_samplesint, default=1000
Number of bootstrap samples to generate. The default value is
1000
.- block_sizefloat, optional
Bootstrap block size. The default (
None
) is to estimate the optimal block size using Politis & White algorithm for all individual assets.- seedint, optional
Random seed used to initialize the pseudo-random number generator
- Attributes:
- uncertainty_set_UncertaintySet
Covariance Uncertainty set
UncertaintySet
.- prior_estimator_BasePrior
Fitted
prior_estimator
.
References
[1]“Robustness properties of mean-variance portfolios”, Optimization: A Journal of Mathematical Programming and Operations Research, Schöttle & Werner (2009).
[2]“Automatic Block-Length Selection for the Dependent Bootstrap”, Politis & White (2004).
[3]“Correction to Automatic Block-Length Selection for the Dependent Bootstrap”, Patton, Politis & White (2009).
Methods
fit
(X[, y])Fit the Bootstrap Covariance Uncertainty set estimator.
Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
set_params
(**params)Set the parameters of this estimator.
- fit(X, y=None, **fit_params)[source]#
Fit the Bootstrap Covariance Uncertainty set estimator.
- Parameters:
- Xarray-like of shape (n_observations, n_assets)
Price returns of the assets.
- yarray-like of shape (n_observations, n_factors), optional
Price returns of factors. The default is
None
.- **fit_paramsdict
Parameters to pass to the underlying estimators. Only available if
enable_metadata_routing=True
, which can be set by usingsklearn.set_config(enable_metadata_routing=True)
. See Metadata Routing User Guide for more details.
- Returns:
- selfEmpiricalCovarianceUncertaintySet
Fitted estimator.
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequest
encapsulating routing information.
- get_params(deep=True)#
Get parameters for this estimator.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- set_params(**params)#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline
). The latter have parameters of the form<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters:
- **paramsdict
Estimator parameters.
- Returns:
- selfestimator instance
Estimator instance.