arviz_stats.psense#
- arviz_stats.psense(data, var_names=None, filter_vars=None, group='prior', coords=None, sample_dims=None, alphas=(0.99, 1.01), group_var_names=None, group_coords=None)[source]#
Compute power-scaling sensitivity values.
- Parameters:
- data
xarray.DataTreeorInferenceData Input data. It should contain the posterior and the log_likelihood and/or log_prior groups.
- var_names
listofstr, optional Names of posterior variables to include in the power scaling sensitivity diagnostic
- 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{“prior”, “likelihood”}, default “prior”
If “likelihood”, the pointsize log likelihood values are retrieved from the
log_likelihoodgroup and added together. If “prior”, the log prior values are retrieved from thelog_priorgroup.- coords
dict, optional Coordinates defining a subset over the posterior. Only these variables will be used when computing the prior sensitivity.
- sample_dims
stror sequence ofhashable, optional Dimensions to reduce. Defaults to
rcParams["data.sample_dims"]- alphas
tuple Lower and upper alpha values for gradient calculation. Defaults to (0.99, 1.01).
- group_var_names
str, optional Name of the prior or log likelihood variables to use
- group_coords
dict, optional Coordinates defining a subset over the group element for which to compute the prior sensitivity diagnostic.
- data
- Returns:
xarray.DataTreeReturns dataTree of power-scaling sensitivity diagnostic values. Higher sensitivity values indicate greater sensitivity. Prior sensitivity above 0.05 indicates informative prior. Likelihood sensitivity below 0.05 indicates weak or non-informative likelihood.
Notes
The diagnostic is computed by power-scaling either the prior or likelihood and determining the degree to which the posterior changes as described in [1]. It uses Pareto-smoothed importance sampling to avoid refitting the model.
References
[1]Kallioinen et al, Detecting and diagnosing prior and likelihood sensitivity with power-scaling, Stat Comput 34, 57 (2024), https://doi.org/10.1007/s11222-023-10366-5