arviz.from_pystan#
- arviz.from_pystan(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, coords=None, dims=None, posterior_model=None, prior_model=None, save_warmup=None, dtypes=None)[source]#
Convert PyStan data into an InferenceData object.
For a usage example read the Creating InferenceData section on from_pystan
- Parameters:
- posterior
StanFit4Modelorstan.fit.Fit PyStan fit object for posterior.
- posterior_predictive
str,alistofstr Posterior predictive samples for the posterior.
- predictions
str,alistofstr Out-of-sample predictions for the posterior.
- prior
StanFit4Modelorstan.fit.Fit PyStan fit object for prior.
- prior_predictive
str,alistofstr Posterior predictive samples for the prior.
- observed_data
stroralistofstr observed data used in the sampling. Observed data is extracted from the
posterior.data. PyStan3 needs model object for the extraction. Seeposterior_model.- constant_data
strorlistofstr Constants relevant to the model (i.e. x values in a linear regression).
- predictions_constant_data
strorlistofstr Constants relevant to the model predictions (i.e. new x values in a linear regression).
- log_likelihood
dictof {str:str},listofstrorstr, optional Pointwise log_likelihood for the data. log_likelihood is extracted from the posterior. It is recommended to use this argument as a dictionary whose keys are observed variable names and its values are the variables storing log likelihood arrays in the Stan code. In other cases, a dictionary with keys equal to its values is used. By default, if a variable
log_likis present in the Stan model, it will be retrieved as pointwise log likelihood values. UseFalseor setdata.log_likelihoodto false to avoid this behaviour.- coords
dict[str, iterable] A dictionary containing the values that are used as index. The key is the name of the dimension, the values are the index values.
- dims
dict[str,List(str)] A mapping from variables to a list of coordinate names for the variable.
- posterior_model
stan.model.Model PyStan3 specific model object. Needed for automatic dtype parsing and for the extraction of observed data.
- prior_model
stan.model.Model PyStan3 specific model object. Needed for automatic dtype parsing.
- save_warmupbool
Save warmup iterations into InferenceData object. If not defined, use default defined by the rcParams.
- dtypes: dict
A dictionary containing dtype information (int, float) for parameters. By default dtype information is extracted from the model code. Model code is extracted from fit object in PyStan 2 and from model object in PyStan 3.
- posterior
- Returns: