bebi103.viz.trace
- bebi103.viz.trace(samples=None, parameters=None, palette=None, omit=None, omit_array_entry=(), include_ppc=None, include_log_lik=None, line_kwargs=None, **kwargs)
Make a trace plot of MCMC samples.
- Parameters:
samples (cmdstanpy.CmdStanMCMC instance, dict, or DataFrame) – Result of MCMC sampling. May be a cmdstanpy.CmdStanMCMC instance, a dictionary of two-dimensional arrays for each expectand and HMC diagnostic as output by bebi103.hmc.convert_samples(), or a pandas.DataFrame or polars.DataFrame with one row per draw and one column per expectand, optionally with ‘chain__’, ‘draw__’, and ‘divergent__’ columns. If a data frame lacks ‘chain__’ and ‘draw__’ columns, the samples are treated as a single chain with draws in row order.
parameters (list of str, or None (default)) – Names of parameters to include in the plot. If None, use all parameters. For multidimensional parameters, each entry must be given separately, e.g., [‘alpha[1]’, ‘alpha[2]’, ‘beta[1,1]’]. If a given entry is a 2-tuple, the first entry is the variable name, and the second entry is the label for the parameter in plots.
palette (list of strings of hex colors, or single hex string) – If a list, color palette to use. If a single string representing a hex color, all glyphs are colored with that color. Default is colorcet.b_glasbey_category10 from the colorcet package.
omit (str, re.Pattern, or iterable thereof, default None) – Variables to exclude when parameters is None. Each string entry is a glob pattern matched against the base (non-indexed) variable name; e.g. ‘theta’ omits ‘theta’ and every entry of ‘theta[1]’, ‘theta[2]’, …. A compiled re.Pattern entry is matched as a regular expression against the base name. A single string or pattern may be given instead of an iterable. Cannot be used together with parameters.
omit_array_entry (str or iterable of str, default ()) – 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. Cannot be used together with parameters.
line_kwargs (dict, default None) – Dictionary of kwargs to be passed to p.multi_line() in making the plot of non-divergent samples.
kwargs – Any kwargs to be passed to bokeh.plotting.figure().
- Returns:
output – Set of chain traces as a Bokeh gridplot.
- Return type:
Bokeh gridplot