arviz_stats.mcse#
- arviz_stats.mcse(data, sample_dims=None, group='posterior', var_names=None, filter_vars=None, coords=None, method='mean', prob=None, chain_axis=0, draw_axis=1)[source]#
Calculate Markov Chain Standard Error statistic.
- 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
- 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 ESS.
- var_names
str
orlist
ofstr
, optional Names of the variables for which the mcse should be computed.
- filter_vars{
None
, “like”, “regex”}, defaultNone
- coords
dict
, optional Dictionary of dimension/index names to coordinate values defining a subset of the data for which to perform the computation.
- method
str
, default “mean” Valid methods are:
“mean”
“sd”
“median”
“quantile”
- prob
float
, ortuple
oftwo
floats
, optional Probability value “quantile”.
- 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,
- Returns:
ndarray
,xarray.DataArray
,xarray.Dataset
,xarray.DataTree
Requested mcse summary of the provided input
See also
arviz.ess
Compute autocovariance estimates for every lag for the input array.
arviz.summary
Create a data frame with summary statistics.
arviz_plots.plot_mcse
Plot quantile or local Monte Carlo Standard Error.
Examples
Calculate the Markov Chain Standard Error using the default arguments:
In [1]: from arviz_base import load_arviz_data ...: import arviz_stats as azs ...: data = load_arviz_data('non_centered_eight') ...: azs.mcse(data) ...: Out[1]: <xarray.DataTree 'posterior'> Group: /posterior Dimensions: (school: 8) Coordinates: * school (school) <U16 512B 'Choate' 'Deerfield' ... 'Mt. Hermon' Data variables: mu float64 8B 0.08102 theta_t (school) float64 64B 0.02339 0.01925 0.02092 ... 0.01931 0.01906 tau float64 8B 0.0791 theta (school) float64 64B 0.1285 0.103 0.1306 ... 0.1158 0.1193 0.1218
Calculate the Markov Chain Standard Error using the quantile method:
In [2]: azs.mcse(data, method="quantile", prob=0.7) Out[2]: <xarray.DataTree 'posterior'> Group: /posterior Dimensions: (school: 8) Coordinates: * school (school) <U16 512B 'Choate' 'Deerfield' ... 'Mt. Hermon' Data variables: mu float64 8B 0.1305 theta_t (school) float64 64B 0.034 0.02491 0.0319 ... 0.02363 0.03383 tau float64 8B 0.1145 theta (school) float64 64B 0.1776 0.1047 0.1426 ... 0.156 0.1508 0.1209