skfolio.moments.ShrunkMu#

class skfolio.moments.ShrunkMu(covariance_estimator=None, vol_weighted_target=False, method=JAMES_STEIN)[source]#

Shrinkage Expected Returns (Mu) estimator.

Estimates the expected returns using shrinkage.

The sample mean estimator is unbiased but has high variance. Stein (1955) proved that it’s possible to find an estimator with reduced total error using shrinkage by trading a small bias against high variance.

The estimator shrinks the sample mean toward a target vector:

\[\hat{\mu} = \alpha\bar{\mu}+\beta \mu_{target}\]

with \(\bar{\mu}\) the sample mean, \(\mu_{target}\) the target vector and \(\alpha\) and \(\beta\) two constants to determine.

There are two choices for the target vector \(\mu_{target}\) :

  • Grand Mean: constant vector of the mean of the sample mean

  • Volatility-Weighted Grand Mean: volatility-weighted sample mean

And three methods for \(\alpha\) and \(\beta\) :

  • James-Stein

  • Bayes-Stein

  • Bodnar Okhrin Parolya

Parameters:
covariance_estimatorBaseCovariance, optional

Covariance estimator used to estimate the covariance in the shrinkage formulae. The default (None) is to use EmpiricalCovariance.

vol_weighted_targetbool, default=False

If this is set to True, the target vector \(\mu_{target}\) is the Volatility-Weighted Grand Mean otherwise it is the Grand Mean. The default is False.

methodShrunkMuMethods, default=ShrunkMuMethods.JAMES_STEIN

Shrinkage method ShrunkMuMethods.

Possible values are:

  • JAMES_STEIN

  • BAYES_STEIN

  • BODNAR_OKHRIN

The default value is ShrunkMuMethods.JAMES_STEIN.

Attributes:
mu_ndarray of shape (n_assets,)

Estimated expected returns of the assets.

covariance_estimator_BaseCovariance

Fitted covariance_estimator.

mu_target_ndarray of shape (n_assets,)

Target vector \(\mu_{target}\).

alpha_float

Alpha value \(\alpha\).

beta_float

Beta value \(\beta\).

n_features_in_int

Number of assets seen during fit.

feature_names_in_ndarray of shape (n_features_in_,)

Names of assets seen during fit. Defined only when X has assets names that are all strings.

References

[1]

“Risk and Asset Allocation”, Attilio Meucci (2005)

[2]

“Bayes-stein estimation for portfolio analysis”, Philippe Jorion (1986)

[3]

“Optimal shrinkage estimator for high-dimensional mean vector” Bodnar, Okhrin and Parolya (2019)

Methods

fit(X[, y])

Fit the ShrunkMu estimator model.

get_metadata_routing()

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 ShrunkMu estimator model.

Parameters:
Xarray-like of shape (n_observations, n_assets)

Price returns of the assets.

yIgnored

Not used, present for API consistency by convention.

**fit_paramsdict

Parameters to pass to the underlying estimators. Only available if enable_metadata_routing=True, which can be set by using sklearn.set_config(enable_metadata_routing=True). See Metadata Routing User Guide for more details.

Returns:
selfShrunkMu

Fitted estimator.

get_metadata_routing()[source]#

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.