bebi103.hmc.check_expectand_diagnostics

bebi103.hmc.check_expectand_diagnostics(samples, min_ess_hat_per_chain=100, xi_hat_threshold=0.25, omit=(), omit_array_entry=(), verbosity=2)

Check all expectand-specific diagnostics for a collection of Markov chains (tail xi_hats, empirical variance, split Rhat, incremental integrated autocorrelation time, and effective sample size).

Parameters:
  • samples (cmdstanpy.CmdStanMCMC instance or dict) – MCMC samples from which to check expectand diagnostics, 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.

  • min_ess_hat_per_chain (float, default 100) – The minimum empirical effective sample size per chain below which a warning is flagged.

  • xi_hat_threshold (float, default 0.25) – Tail xi_hats at or above this value are flagged as warnings. Also passed through to tail_xi_hat() when computing the tail xi_hats.

  • 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.

  • verbosity (int, default 2) – Level of verbosity for messages printed to the screen. 0 prints nothing. 1 prints a summary of the diagnostics. 2 prints the summary followed by descriptions of what the triggered diagnostics mean. 3 prints per-chain detail followed by the descriptions.

Returns:

output – Dictionary with keys ‘xi_hat’, ‘variance’, ‘rhat’, ‘inc_tau_hat’, and ‘ess_hat’, whose values are the dictionaries returned by tail_xi_hat(), check_variance(), split_rhat(), tau_hat(), and ess_hat(), respectively. Each is paired with a Boolean success flag (‘xi_hat_success’, ‘variance_success’, ‘rhat_success’, ‘inc_tau_hat_success’, and ‘ess_hat_success’) that is True when no expectand triggered the corresponding warning.

Return type:

dict

Notes