bebi103.stan.arviz_to_dataframe

bebi103.stan.arviz_to_dataframe(data, var_names=None, diagnostics=('diverging',))

Convert ArviZ InferenceData to a Pandas data frame.

Any multi-dimensional parameters are converted to one-dimensional equivalents. For example, a 2x2 matrix A is converted to columns in the data frame with headings ‘A[0,0]’, ‘A[0,1]’, ‘A[1,0]’, and ‘A[1,1]’.

Only divergence information, chain ID, and draw number (not additional sampling stats) are stored in the data frame.

Parameters
  • data (ArviZ InferenceData instance) – Results from MCMC sampling to convert to a data frame. It must have a posterior attribute, and it should have a sample_stats attribute if divergence information is to be stored.

  • var_names (list of strings or None) – List of variables present in data.posterior.data_vars to store in the data frame. If None, all variables present in data.posterior.data_vars are stored. Note that only variables in data.posterior.data_vars may be stored.

  • diagnostics (list or tuple of strings) – Diagnostic data to be stored in the data frame. The elements of the list may include: ‘lp’, ‘accept_stat’, ‘stepsize’, ‘treedepth’, ‘n_leapfrog’, ‘diverging’, and ‘energy’.

Returns

output – DataFrame with posterior samples and diagnostics. The column names of all diagnostics, as well as ‘chain’ and ‘draw’, are appended with a double-underscore (__) to signify that they are not samples out of the posterior, but rather metadata about a sample.

Return type

Pandas DataFrame