arviz_stats.rhat_nested#
- arviz_stats.rhat_nested(data, sample_dims=None, group='posterior', var_names=None, filter_vars=None, method='rank', coords=None, superchain_ids=None, chain_axis=0, draw_axis=1)[source]#
Compute nested R-hat.
Nested R-hat is a convergence diagnostic useful when running many short chains. It is calculated on superchains, which are groups of chains that have been initialized at the same point.
Note that there is a slight difference in the calculation of R-hat and nested R-hat, as nested R-hat is lower bounded by 1. This means that nested R-hat with one chain per superchain will not be exactly equal to basic R-hat see [1] for details.
- Parameters:
- dataarray_like,
xarray.DataArray
,xarray.Dataset
,xarray.DataTree
,DataArrayGroupBy
,DatasetGroupBy
, or idata-like Input data. It will have different pre-processing applied to it depending on its type:
array-like: call array layer within
arviz-stats
.xarray object: apply dimension aware function to all relevant subsets
others: passed to
arviz_base.convert_to_dataset
At least 2 posterior chains are needed to compute this diagnostic of one or more stochastic parameters.
- sample_dimsiterable of
hashable
, optional Dimensions to be considered sample dimensions and are to be reduced. Default
rcParams["data.sample_dims"]
.- group
hashable
, default “posterior” Group on which to compute the R-hat.
- var_names
str
orlist
ofstr
, optional Names of the variables for which the Rhat should be computed.
- filter_vars{
None
, “like”, “regex”}, defaultNone
- method
str
, default “rank” Valid methods are: - “rank” # recommended by Vehtari et al. (2021) - “split” - “folded” - “z_scale” - “identity”
- coords
dict
, optional Dictionary of dimension/index names to coordinate values defining a subset of the data for which to perform the computation.
- superchain_ids
list
Lisf ot length
chains
specifying which superchain each chain belongs to. There should be equal numbers of chains in each superchain. All chains within the same superchain are assumed to have been initialized at the same point.- chain_axis, draw_axis
int
, optional Integer indicators of the axis that correspond to the chain and the draw dimension. chain_axis can be
None
.
- dataarray_like,
See also
arviz.rhat
Calculate estimate of the effective sample size (ess).
arviz.ess
Calculate Markov Chain Standard Error statistic.
plot_forest
Forest plot to compare HDI intervals from a number of distributions.
References
[1]Margossian et al Nested R-hat: Assessing the convergence of Markov Chain Monte Carlo when running many short chains. Bayesian Analysis, (2024). https://doi.org/10.1214/24-BA1453