arviz_stats.ci_in_rope

Contents

arviz_stats.ci_in_rope#

arviz_stats.ci_in_rope(data, rope, var_names=None, filter_vars=None, group='posterior', dim=None, ci_prob=None, ci_kind=None, rope_dim='rope_dim')[source]#

Compute the percentage of a credible interval that falls within a ROPE.

A region of practical equivalence (ROPE) indicates a small range of parameter values that are considered to be practically equivalent to the null value for purposes of the particular application see [1] for more details.

Parameters:
dataxarray.DataTree, DataSet or InferenceData
rope(2,) array_like or dict of {hashable(2,) array_like} or xarray.Dataset

If tuple, the lower and upper bounds of the ROPE are the same for all variables. If dict, the keys are the variable names and the values are tuples with the lower and upper bounds of the ROPE. The keys must be in var_names.

var_nameslist of str, optional

Names of variables for which the ROPE should be computed. If None all variables are included.

filter_vars: {None, “like”, “regex”}, default None

Used for var_names only. If None (default), interpret var_names as the real variables names. If “like”, interpret var_names as substrings of the real variables names. If “regex”, interpret var_names as regular expressions on the real variables names.

group: str

Select a group to compute the ROPE. Defaults to “posterior”.

coordsdict, optional

Coordinates defining a subset over the selected group.

dimstr or sequence of hashable, optional

Defaults to rcParams["data.sample_dims"]

ci_probfloat, optional

Probability for the credible interval. Defaults to rcParams["stats.ci_prob"].

ci_kind{“hdi”, “eti”}, optional

Type of credible interval. Defaults to rcParams["stats.ci_kind"]. If kind is stats_median or all_median, ci_kind is forced to “eti”.

rope_dimstr, default “rope_dim”

Name for the dimension containing the ROPE values. Only used when rope is a Dataset

Returns:
xarray.Dataset

See also

arviz.summary

Compute summary statistics and or diagnostics.

arviz.hdi

Compute highest density interval (HDI).

arviz.eti

Compute equal tail interval (ETI).

References

[1]

Kruschke. Doing Bayesian Data Analysis, Second Edition: A Tutorial with R, JAGS, and Stan. Academic Press, 2014. ISBN 978-0-12-405888-0.

Examples

Apply the same ROPE to a subset of variables:

In [1]: from arviz_base import load_arviz_data
   ...: from arviz_stats import ci_in_rope
   ...: data = load_arviz_data("centered_eight")
   ...: ci_in_rope(data, var_names=["mu", "tau"], rope=(-0.5, 0.5))
   ...: 
Out[1]: 
<xarray.Dataset> Size: 16B
Dimensions:  ()
Data variables:
    mu       float64 8B 4.785
    tau      float64 8B 0.0

Apply different ROPEs to each variable:

In [2]: ci_in_rope(data, rope={"mu": (-0.5, 0.5), "tau": (0.1, 0.2), "theta": (-0.1, 0.1)})
Out[2]: 
<xarray.Dataset> Size: 592B
Dimensions:  (school: 8)
Coordinates:
  * school   (school) <U16 512B 'Choate' 'Deerfield' ... 'Mt. Hermon'
Data variables:
    mu       float64 8B 4.785
    theta    (school) float64 64B 0.9038 0.6911 0.5316 ... 1.17 0.7443 1.116
    tau      float64 8B 0.0