Compute leave one out (PSIS-LOO) probability integral transform (PIT) values.
arviz.InferenceData
object.
Observed data. If str, idata
must be present and contain the observed data group
Posterior predictive samples for y
. It must have the same shape as y plus an extra dimension at the end of size n_samples (chains and draws stacked). If str or None, idata
must contain the posterior predictive group. If None, y_hat is taken equal to y, thus, y must be str too.
Smoothed log_weights. It must have the same shape as y_hat
dict
, optional
Dask related kwargs passed to wrap_xarray_ufunc()
.
array
or DataArray
Value of the LOO-PIT at each observed data point.
See also
plot_loo_pit
Plot Leave-One-Out probability integral transformation (PIT) predictive checks.
loo
Compute Pareto-smoothed importance sampling leave-one-out cross-validation (PSIS-LOO-CV).
plot_elpd
Plot pointwise elpd differences between two or more models.
plot_khat
Plot Pareto tail indices for diagnosing convergence.
Examples
Calculate LOO-PIT values using as test quantity the observed values themselves.
In [1]: import arviz as az ...: data = az.load_arviz_data("centered_eight") ...: az.loo_pit(idata=data, y="obs") ...: Out[1]: array([0.94352797, 0.63801356, 0.31667941, 0.58227349, 0.29532521, 0.40245764, 0.90248636, 0.65535457])
Calculate LOO-PIT values using as test quantity the square of the difference between each observation and mu
. Both y
and y_hat
inputs will be array-like, but idata
will still be passed in order to calculate the log_weights
from there.
In [2]: T = data.observed_data.obs - data.posterior.mu.median(dim=("chain", "draw")) ...: T_hat = data.posterior_predictive.obs - data.posterior.mu ...: T_hat = T_hat.stack(__sample__=("chain", "draw")) ...: az.loo_pit(idata=data, y=T**2, y_hat=T_hat**2) ...: Out[2]: <xarray.DataArray (school: 8)> Size: 64B array([0.87363113, 0.2437218 , 0.3574724 , 0.14990431, 0.4352044 , 0.22133633, 0.77501652, 0.29666341]) Coordinates: * school (school) <U16 512B 'Choate' 'Deerfield' ... 'Mt. Hermon'
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4