Diagnostics

hbayesdm.diagnostics.rhat(model_data, less=None)

Function for extracting Rhat values from hbayesdm output.

Convenience function for extracting Rhat values from hbayesdm output. Also possible to check if all Rhat values are less than a specified value.

Parameters
  • model_data – Output instance of running an hbayesdm model function.

  • less – [Optional] Upper-bound value to compare extracted Rhat values to.

Returns

Dict – Keys are names of the parameters; values are their Rhat values. Or if less was specified, the dictionary values will hold True if all Rhat values (of that parameter) are less than or equal to less.

hbayesdm.diagnostics.print_fit(*args, ic='looic')

Print model-fits (mean LOOIC or WAIC values) of hbayesdm models.

Parameters
  • args – Output instances of running hbayesdm model functions.

  • ic – Information criterion (defaults to ‘looic’).

Returns

pd.DataFrame – Model-fit info per each hbayesdm output given as argument(s).

hbayesdm.diagnostics.hdi(x, credible_interval=0.94)

Calculate highest density interval (HDI).

This function acts as an alias to arviz.hpd function.

Parameters
  • x – Array containing MCMC samples.

  • credible_interval – Credible interval to compute. Defaults to 0.94.

Returns

np.ndarray – Array containing the lower and upper value of the computed interval.

hbayesdm.diagnostics.plot_hdi(x, credible_interval=0.94, title=None, xlabel='Value', ylabel='Density', point_estimate=None, bins='auto', round_to=2, **kwargs)

Plot highest density interval (HDI).

This function redirects input to arviz.plot_posterior function.

Parameters
  • x – Array containing MCMC samples.

  • credible_interval – Credible interval to plot. Defaults to 0.94.

  • title – String to set as title of plot.

  • xlabel – String to set as the x-axis label.

  • ylabel – String to set as the y-axis label.

  • point_estimate – Defaults to None. Possible options are ‘mean’, ‘median’, ‘mode’.

  • bins – Controls the number of bins. Defaults to ‘auto’. Accepts the same values (or keywords) as plt.hist() does.

  • round_to – Controls formatting for floating point numbers. Defaults to 2.

  • **kwargs – Passed as-is to plt.hist().

hbayesdm.diagnostics.extract_ic(model_data, ic='both', ncore=2)

Extract model comparison estimates.

Parameters
  • model_data – hBayesDM output objects from running model functions.

  • ic – Information criterion. ‘looic’, ‘waic’, or ‘both’. Defaults to ‘both’.

  • ncore – Number of cores to use when computing LOOIC. Defaults to 2.

Returns

Dict – Leave-One-Out and/or Watanabe-Akaike information criterion estimates.