arviz_base.from_cmdstanpy

Contents

arviz_base.from_cmdstanpy#

arviz_base.from_cmdstanpy(posterior=None, *, posterior_predictive=None, predictions=None, prior=None, prior_predictive=None, observed_data=None, constant_data=None, predictions_constant_data=None, log_likelihood=None, index_origin=None, coords=None, dims=None, save_warmup=None, dtypes=None)[source]#

Convert CmdStanPy data into an InferenceData object.

For a usage example read the Creating InferenceData section on from_cmdstanpy

Parameters:
posteriorcmdstanpy.CmdStanMCMC, optional

CmdStanPy CmdStanMCMC

posterior_predictivestr or list of str, optional

Posterior predictive samples for the fit.

predictionsstr or list of str, optional

Out of sample prediction samples for the fit.

priorcmdstanpy.CmdStanMCMC, optional

CmdStanPy CmdStanMCMC

prior_predictivestr or list of str, optional

Prior predictive samples for the fit.

observed_datamapping of {strarray_like}, optional

Observed data used in the sampling.

constant_datamapping of {strarray_like}, optional

Constant data used in the sampling.

predictions_constant_datadict, optional

Constant data for predictions used in the sampling.

log_likelihoodstr or list of str or dict of {strstr}, optional

Pointwise log_likelihood for the data. If a dict, its keys should represent var_names from the corresponding observed data and its values the stan variable where the data is stored. By default, if a variable log_lik is present in the Stan model, it will be retrieved as pointwise log likelihood values. Use False to avoid this behaviour.

index_originint, optional

Starting value of integer coordinate values. Defaults to the value in rcParam data.index_origin.

coordsdict, optional

A dictionary containing the values that are used as index. The key is the name of the dimension, the values are the index values.

dimsmapping of {hashablesequence of hashable}, optional

A mapping from variables to a list of coordinate names for the variable.

save_warmupbool, optional

Save warmup iterations into InferenceData object, if found in the input files. If not defined, use default defined by the rcParams.

dtypesdict, str or cmdstanpy.CmdStanModel, optional

A dictionary containing dtype information (int, float) for parameters. If input is a string, it is assumed to be a model code or path to model code file. Model code can be extracted from cmdstanpy.CmdStanModel object.

Returns:
xarray.DataTree