bebi103.hmc.tail_xi_hat
- bebi103.hmc.tail_xi_hat(samples, omit=(), omit_array_entry=())
Compute the empirical generalized Pareto shape (xi_hat) for the upper and lower tails of a sample of expectand values, ignoring any autocorrelation between the values. The draws from all chains are pooled together.
- Parameters:
samples (cmdstanpy.CmdStanMCMC instance or dict) – MCMC samples from which to compute xi_hat, either as a cmdstanpy.CmdStanMCMC instance or as a dictionary of two-dimensional arrays for each expectand. For the dictionary, the first dimension of each element indexes the Markov chains and the second dimension indexes the sequential states within each Markov chain.
omit (str, re.Pattern, or iterable thereof) – Glob pattern(s) matched against the base (non-indexed) name of each variable. Any variable whose base name matches an entry is omitted, whether scalar or array valued. For example, omit=’*_pred’ omits every variable whose name ends in ‘_pred’. Compiled re.Pattern entries are matched as regular expressions. A single string or pattern may be given instead of an iterable.
omit_array_entry (str or iterable of str) – Specific array entries to omit, e.g. ‘y_pred[1]’ or ‘beta[1,2]’. Each entry must include bracketed, comma-separated integer indices. A single string may be given instead of an iterable.
- Returns:
output – Each key is an expectand, and each value is a Numpy array of shape (2,) holding the shape estimates for the lower and upper tails, in that order, computed from the draws of all chains pooled together. An entry is NaN if there were too few draws to estimate the shape of that tail.
- Return type:
dict
Notes
Uses the method of Zhang and Stephens, “A New and Efficient Estimation Method for the Generalized Pareto Distribution”, Technometrics, 2009, https://doi.org/10.1198/tech.2009.08017.
Within the generalized Pareto family all moments up to the mth order are finite if and only if xi_hat < 1 / m.