arviz.from_pystan — ArviZ dev documentation (original) (raw)
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 theCreating InferenceData section on from_pystan
Parameters:
posteriorStanFit4Model
or stan.fit.Fit
PyStan fit object for posterior.
posterior_predictivestr, a
list of str
Posterior predictive samples for the posterior.
Out-of-sample predictions for the posterior.
priorStanFit4Model
or stan.fit.Fit
PyStan fit object for prior.
prior_predictivestr, a
list of str
Posterior predictive samples for the prior.
observed_datastr or a
list of str
observed data used in the sampling. Observed data is extracted from the posterior.data
. PyStan3 needs model object for the extraction. See posterior_model
.
constant_datastr or list of str
Constants relevant to the model (i.e. x values in a linear regression).
predictions_constant_datastr or list of str
Constants relevant to the model predictions (i.e. new x values in a linear regression).
log_likelihooddict of {str: str}, list of str or str, 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_lik
is present in the Stan model, it will be retrieved as pointwise log likelihood values. Use False
or set data.log_likelihood
to false to avoid this behaviour.
A dictionary containing the values that are used as index. The key is the name of the dimension, the values are the index values.
A mapping from variables to a list of coordinate names for the variable.
posterior_modelstan.model.Model
PyStan3 specific model object. Needed for automatic dtype parsing and for the extraction of observed data.
prior_modelstan.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.
Returns: