diff --git a/CHANGELOG.md b/CHANGELOG.md index ec23cde5f6..5bf536120f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ * Replaced `_fast_kde()` with `kde()` which now also supports circular variables via the argument `circular` ([1284](https://github.com/arviz-devs/arviz/pull/1284)). * Increased `from_pystan` attrs information content ([1353](https://github.com/arviz-devs/arviz/pull/1353)) * Allow `plot_trace` to return and accept axes ([#1361](https://github.com/arviz-devs/arviz/pull/1361)) +* Update diagnostics to be on par with posterior package ([#1366](https://github.com/arviz-devs/arviz/pull/1366)) ### Deprecation diff --git a/arviz/data/io_cmdstan.py b/arviz/data/io_cmdstan.py index 80920fabea..45e171d35a 100644 --- a/arviz/data/io_cmdstan.py +++ b/arviz/data/io_cmdstan.py @@ -626,7 +626,9 @@ def _read_output_file(path): comments.append(line.decode("utf-8").strip()) with open(path, "rb") as f_obj: - data = pd.read_csv(f_obj, comment="#") + data = pd.read_csv( + f_obj, comment="#", float_precision=rcParams["data.pandas_float_precision"] + ) return data, comments diff --git a/arviz/rcparams.py b/arviz/rcparams.py index b858cbb891..0e9f207eb1 100644 --- a/arviz/rcparams.py +++ b/arviz/rcparams.py @@ -228,6 +228,10 @@ def validate_iterable(value): "data.metagroups": (METAGROUPS, _validate_dict_of_lists), "data.index_origin": (0, _make_validate_choice({0, 1}, typeof=int)), "data.save_warmup": (False, _validate_boolean), + "data.pandas_float_precision": ( + "high", + _make_validate_choice({"high", "round_trip"}, allow_none=True), + ), "plot.backend": ("matplotlib", _make_validate_choice({"matplotlib", "bokeh"})), "plot.max_subplots": (40, _validate_positive_int_or_none), "plot.point_estimate": ( diff --git a/arviz/stats/diagnostics.py b/arviz/stats/diagnostics.py index ed3fe9cb0a..a70834b1c7 100644 --- a/arviz/stats/diagnostics.py +++ b/arviz/stats/diagnostics.py @@ -14,7 +14,6 @@ from .stats_utils import autocov as _autocov from .stats_utils import not_valid as _not_valid from .stats_utils import quantile as _quantile -from .stats_utils import rint as _rint from .stats_utils import stats_variance_2d as svar from .stats_utils import wrap_xarray_ufunc as _wrap_xarray_ufunc @@ -321,6 +320,7 @@ def mcse(data, *, var_names=None, method="mean", prob=None): Select mcse method. Valid methods are: - "mean" - "sd" + - "median" - "quantile" prob : float @@ -345,10 +345,15 @@ def mcse(data, *, var_names=None, method="mean", prob=None): .. ipython:: - In [1]: az.mcse(data, method="quantile", prob=.7) + In [1]: az.mcse(data, method="quantile", prob=0.7) """ - methods = {"mean": _mcse_mean, "sd": _mcse_sd, "quantile": _mcse_quantile} + methods = { + "mean": _mcse_mean, + "sd": _mcse_sd, + "median": _mcse_median, + "quantile": _mcse_quantile, + } if method not in methods: raise TypeError( "mcse method {} not found. Valid methods are:\n{}".format( @@ -530,6 +535,29 @@ def _bfmi(energy): return num / den +def _backtransform_ranks(arr, c=3 / 8): # pylint: disable=invalid-name + """Backtransformation of ranks. + + Parameters + ---------- + arr : np.ndarray + Ranks array + c : float + Fractional offset. Defaults to c = 3/8 as recommended by Blom (1958). + + Returns + ------- + np.ndarray + + References + ---------- + Blom, G. (1958). Statistical Estimates and Transformed Beta-Variables. Wiley; New York. + """ + arr = np.asarray(arr) + size = arr.size + return (arr - c) / (size - 2 * c + 1) + + def _z_scale(ary): """Calculate z_scale. @@ -542,9 +570,9 @@ def _z_scale(ary): np.ndarray """ ary = np.asarray(ary) - size = ary.size rank = stats.rankdata(ary, method="average") - z = stats.norm.ppf((rank - 0.5) / size) + rank = _backtransform_ranks(rank) + z = stats.norm.ppf(rank) z = z.reshape(ary.shape) return z @@ -811,26 +839,6 @@ def _ess_identity(ary, relative=False): return _ess(ary, relative=relative) -def _conv_quantile(ary, prob): - """Return mcse, Q05, Q95, Seff.""" - ary = np.asarray(ary) - if _not_valid(ary, shape_kwargs=dict(min_draws=4, min_chains=1)): - return np.nan, np.nan, np.nan, np.nan - ess = _ess_quantile(ary, prob) - probability = [0.1586553, 0.8413447, 0.05, 0.95] - with np.errstate(invalid="ignore"): - ppf = stats.beta.ppf(probability, ess * prob + 1, ess * (1 - prob) + 1) - sorted_ary = np.sort(ary.ravel()) - size = sorted_ary.size - ppf_size = ppf * size - 1 - th1 = sorted_ary[_rint(np.nanmax((ppf_size[0], 0)))] - th2 = sorted_ary[_rint(np.nanmin((ppf_size[1], size - 1)))] - mcse_quantile = (th2 - th1) / 2 - th1 = sorted_ary[_rint(np.nanmax((ppf_size[2], 0)))] - th2 = sorted_ary[_rint(np.nanmin((ppf_size[3], size - 1)))] - return mcse_quantile, th1, th2, ess - - def _mcse_mean(ary): """Compute the Markov Chain mean error.""" _numba_flag = Numba.numba_flag @@ -862,13 +870,26 @@ def _mcse_sd(ary): return mcse_sd_value +def _mcse_median(ary): + """Compute the Markov Chain median error.""" + return _mcse_quantile(ary, 0.5) + + def _mcse_quantile(ary, prob): """Compute the Markov Chain quantile error at quantile=prob.""" ary = np.asarray(ary) if _not_valid(ary, shape_kwargs=dict(min_draws=4, min_chains=1)): return np.nan - mcse_q, *_ = _conv_quantile(ary, prob) - return mcse_q + ess = _ess_quantile(ary, prob) + probability = [0.1586553, 0.8413447] + with np.errstate(invalid="ignore"): + ppf = stats.beta.ppf(probability, ess * prob + 1, ess * (1 - prob) + 1) + sorted_ary = np.sort(ary.ravel()) + size = sorted_ary.size + ppf_size = ppf * size - 1 + th1 = sorted_ary[int(np.floor(np.nanmax((ppf_size[0], 0))))] + th2 = sorted_ary[int(np.ceil(np.nanmin((ppf_size[1], size - 1))))] + return (th2 - th1) / 2 def _mc_error(ary, batches=5, circular=False): diff --git a/arviz/stats/stats_utils.py b/arviz/stats/stats_utils.py index 5af64f47e1..3020a46828 100644 --- a/arviz/stats/stats_utils.py +++ b/arviz/stats/stats_utils.py @@ -318,12 +318,6 @@ def logsumexp(ary, *, b=None, b_inv=None, axis=None, keepdims=False, out=None, c return out if out.shape else dtype(out) -def rint(num): - """Round and change to ingeter.""" - rnum = np.rint(num) # pylint: disable=assignment-from-no-return - return int(rnum) - - def quantile(ary, q, axis=None, limit=None): """Use same quantile function as R (Type 7).""" if limit is None: diff --git a/arviz/tests/base_tests/test_diagnostics.py b/arviz/tests/base_tests/test_diagnostics.py index 01b1f0d65f..a843fd8356 100644 --- a/arviz/tests/base_tests/test_diagnostics.py +++ b/arviz/tests/base_tests/test_diagnostics.py @@ -5,17 +5,17 @@ import numpy as np import pandas as pd import pytest -from numpy.testing import assert_almost_equal, assert_array_almost_equal +from numpy.testing import assert_almost_equal from ...data import from_cmdstan, load_arviz_data from ...plots.plot_utils import xarray_var_iter -from ...rcparams import rcParams +from ...rcparams import rc_context, rcParams from ...stats import bfmi, ess, geweke, mcse, rhat from ...stats.diagnostics import ( - _conv_quantile, _ess, _ess_quantile, _mc_error, + _mcse_quantile, _multichain_statistics, _rhat, _rhat_rank, @@ -54,38 +54,40 @@ def test_bfmi_dataset_bad(self): def test_deterministic(self): """ - Test algorithm against RStan monitor.R functions. - monitor.R : - https://github.com/stan-dev/rstan/blob/425d195565c4d9bcbcb8cccf513e140e6908ca62/rstan/rstan/R/monitor.R + Test algorithm against posterior (R) convergence functions. + + posterior: https://github.com/stan-dev/posterior R code: ``` - source('~/monitor.R') + library("posterior") data2 <- read.csv("blocker.2.csv", comment.char = "#") data1 <- read.csv("blocker.1.csv", comment.char = "#") - output <- matrix(ncol=15, nrow=length(names(data1))-4) + output <- matrix(ncol=17, nrow=length(names(data1))-4) j = 0 for (i in 1:length(names(data1))) { - name = names(data1)[i] - ary = matrix(c(data1[,name], data2[,name]), 1000, 2) - if (!endsWith(name, "__")) - j <- j + 1 - output[j,] <- c( - rhat(ary), - rhat_rfun(ary), - ess_bulk(ary), - ess_tail(ary), - ess_mean(ary), - ess_sd(ary), - ess_rfun(ary), - ess_quantile(ary, 0.01), - ess_quantile(ary, 0.1), - ess_quantile(ary, 0.3), - mcse_mean(ary), - mcse_sd(ary), - mcse_quantile(ary, prob=0.01), - mcse_quantile(ary, prob=0.1), - mcse_quantile(ary, prob=0.3)) - } + name = names(data1)[i] + ary = matrix(c(data1[,name], data2[,name]), 1000, 2) + if (!endsWith(name, "__")) + j <- j + 1 + output[j,] <- c( + posterior::rhat(ary), + posterior::rhat_basic(ary, FALSE), + posterior::ess_bulk(ary), + posterior::ess_tail(ary), + posterior::ess_mean(ary), + posterior::ess_sd(ary), + posterior::ess_median(ary), + posterior::ess_basic(ary, FALSE), + posterior::ess_quantile(ary, 0.01), + posterior::ess_quantile(ary, 0.1), + posterior::ess_quantile(ary, 0.3), + posterior::mcse_mean(ary), + posterior::mcse_sd(ary), + posterior::mcse_median(ary), + posterior::mcse_quantile(ary, prob=0.01), + posterior::mcse_quantile(ary, prob=0.1), + posterior::mcse_quantile(ary, prob=0.3)) + } df = data.frame(output, row.names = names(data1)[5:ncol(data1)]) colnames(df) <- c("rhat_rank", "rhat_raw", @@ -93,25 +95,38 @@ def test_deterministic(self): "ess_tail", "ess_mean", "ess_sd", + "ess_median", "ess_raw", "ess_quantile01", "ess_quantile10", "ess_quantile30", "mcse_mean", "mcse_sd", + "mcse_median", "mcse_quantile01", "mcse_quantile10", "mcse_quantile30") - write.csv(df, "reference_values.csv") + write.csv(df, "reference_posterior.csv") ``` + Reference file: + + Created: 2020-08-31 + System: Ubuntu 18.04.5 LTS + R version 4.0.2 (2020-06-22) + posterior 0.1.2 """ # download input files here = os.path.dirname(os.path.abspath(__file__)) data_directory = os.path.join(here, "..", "saved_models") path = os.path.join(data_directory, "stan_diagnostics", "blocker.[0-9].csv") - posterior = from_cmdstan(path) - reference_path = os.path.join(data_directory, "stan_diagnostics", "reference_values.csv") - reference = pd.read_csv(reference_path, index_col=0).sort_index(axis=1).sort_index(axis=0) + with rc_context(rc={"data.pandas_float_precision": "high"}): + posterior = from_cmdstan(path) + reference_path = os.path.join(data_directory, "stan_diagnostics", "reference_posterior.csv") + reference = ( + pd.read_csv(reference_path, index_col=0, float_precision="high") + .sort_index(axis=1) + .sort_index(axis=0) + ) # test arviz functions funcs = { "rhat_rank": lambda x: rhat(x, method="rank"), @@ -120,12 +135,14 @@ def test_deterministic(self): "ess_tail": lambda x: ess(x, method="tail"), "ess_mean": lambda x: ess(x, method="mean"), "ess_sd": lambda x: ess(x, method="sd"), + "ess_median": lambda x: ess(x, method="median"), "ess_raw": lambda x: ess(x, method="identity"), "ess_quantile01": lambda x: ess(x, method="quantile", prob=0.01), "ess_quantile10": lambda x: ess(x, method="quantile", prob=0.1), "ess_quantile30": lambda x: ess(x, method="quantile", prob=0.3), "mcse_mean": lambda x: mcse(x, method="mean"), "mcse_sd": lambda x: mcse(x, method="sd"), + "mcse_median": lambda x: mcse(x, method="median"), "mcse_quantile01": lambda x: mcse(x, method="quantile", prob=0.01), "mcse_quantile10": lambda x: mcse(x, method="quantile", prob=0.1), "mcse_quantile30": lambda x: mcse(x, method="quantile", prob=0.3), @@ -136,21 +153,19 @@ def test_deterministic(self): key = key + ".{}".format(list(coord_dict.values())[0] + 1) results[key] = {func_name: func(vals) for func_name, func in funcs.items()} arviz_data = pd.DataFrame.from_dict(results).T.sort_index(axis=1).sort_index(axis=0) + # check column names assert set(arviz_data.columns) == set(reference.columns) + # check parameter names assert set(arviz_data.index) == set(reference.index) - # check equality (rhat_rank has accuracy < 6e-5, atleast with this data, R vs Py) - # this is due to numerical accuracy in calculation leading to rankdata - # function, which scales minimal difference to larger scale - # test first with numpy - assert_array_almost_equal(reference, arviz_data, decimal=4) - # then test manually (more strict) - assert (abs(reference["rhat_rank"] - arviz_data["rhat_rank"]) < 6e-5).all(None) - assert abs(np.median(reference["rhat_rank"] - arviz_data["rhat_rank"]) < 1e-14).all(None) - not_rhat = [col for col in reference.columns if col != "rhat_rank"] - assert (abs((reference[not_rhat] - arviz_data[not_rhat])).values < 1e-8).all(None) - assert abs(np.median(reference[not_rhat] - arviz_data[not_rhat]) < 1e-14).all(None) + + # show print with pytests '-s' tag + np.set_printoptions(16) + print(abs(reference - arviz_data).max()) + + # test absolute accuracy + assert (abs(reference - arviz_data).values < 1e-8).all(None) @pytest.mark.parametrize("method", ("rank", "split", "folded", "z_scale", "identity")) @pytest.mark.parametrize("var_names", (None, "mu", ["mu", "tau"])) @@ -350,7 +365,7 @@ def test_effective_sample_size_dataset(self, data, method, var_names, relative): ess_hat = ess(data, var_names=var_names, method=method, relative=relative) assert np.all(ess_hat.mu.values > n_low) # This might break if the data is regenerated - @pytest.mark.parametrize("mcse_method", ("mean", "sd", "quantile")) + @pytest.mark.parametrize("mcse_method", ("mean", "sd", "median", "quantile")) def test_mcse_array(self, mcse_method): if mcse_method == "quantile": mcse_hat = mcse(np.random.randn(4, 100), method=mcse_method, prob=0.34) @@ -362,7 +377,7 @@ def test_mcse_ndarray(self): with pytest.raises(TypeError): mcse(np.random.randn(2, 300, 10)) - @pytest.mark.parametrize("mcse_method", ("mean", "sd", "quantile")) + @pytest.mark.parametrize("mcse_method", ("mean", "sd", "median", "quantile")) @pytest.mark.parametrize("var_names", (None, "mu", ["mu", "tau"])) def test_mcse_dataset(self, data, mcse_method, var_names): if mcse_method == "quantile": @@ -371,7 +386,7 @@ def test_mcse_dataset(self, data, mcse_method, var_names): mcse_hat = mcse(data, var_names=var_names, method=mcse_method) assert mcse_hat # This might break if the data is regenerated - @pytest.mark.parametrize("mcse_method", ("mean", "sd", "quantile")) + @pytest.mark.parametrize("mcse_method", ("mean", "sd", "median", "quantile")) @pytest.mark.parametrize("chain", (None, 1, 2)) @pytest.mark.parametrize("draw", (1, 2, 3, 4)) @pytest.mark.parametrize("use_nan", (True, False)) @@ -515,12 +530,12 @@ def test_mc_error_nan(self, size, ndim): else: assert np.isnan(_mc_error(x)) - @pytest.mark.parametrize("func", ("_conv_quantile", "_z_scale")) + @pytest.mark.parametrize("func", ("_mcse_quantile", "_z_scale")) def test_nan_behaviour(self, func): data = np.random.randn(100, 4) data[0, 0] = np.nan # pylint: disable=unsupported-assignment-operation - if func == "_conv_quantile": - assert np.isnan(_conv_quantile(data, 0.5)).all(None) + if func == "_mcse_quantile": + assert np.isnan(_mcse_quantile(data, 0.5)).all(None) else: assert not np.isnan(_z_scale(data)).all(None) assert not np.isnan(_z_scale(data)).any(None) diff --git a/arviz/tests/saved_models/stan_diagnostics/reference_posterior.csv b/arviz/tests/saved_models/stan_diagnostics/reference_posterior.csv new file mode 100644 index 0000000000..52059ba5ad --- /dev/null +++ b/arviz/tests/saved_models/stan_diagnostics/reference_posterior.csv @@ -0,0 +1,49 @@ +"","rhat_rank","rhat_raw","ess_bulk","ess_tail","ess_mean","ess_sd","ess_median","ess_raw","ess_quantile01","ess_quantile10","ess_quantile30","mcse_mean","mcse_sd","mcse_median","mcse_quantile01","mcse_quantile10","mcse_quantile30" +"d",1.00780272388603,1.0004168232094,465.136513484671,349.135270438316,467.84472286415,467.84472286415,311.806319792457,467.367576858138,1500.2193689464,754.211496074801,354.746981701936,0.00265985849234941,0.00188197776671187,0.005242,0.00812199999999999,0.003997,0.00375200000000001 +"sigmasq_delta",1.01090196780102,1.00035874354121,73.249623982678,48.5806371372426,134.497570910906,134.497570910906,132.049677080929,138.627800274732,33.1982442776445,63.6980562732759,98.6290985074029,0.00114848510125919,0.000813869235009484,0.00095392,0.0003001,0.00044662,0.00058668 +"mu.1",1.00731450966132,0.999545827128633,1231.30913527034,1119.63456276454,1189.5912192317,1137.76545007779,811.795584886629,1171.62891354699,1030.60309993778,465.95223908163,635.768730056618,0.0125124382036461,0.00904921314805709,0.022465,0.02589,0.0285949999999999,0.0175350000000001 +"mu.2",1.00332752771857,1.00046552033653,558.783738495551,920.913340029631,569.193418116839,569.193418116839,560.847913565582,543.893011358525,1250.00943663727,715.745937098207,603.702320409943,0.0100753323647403,0.00712798968840261,0.012035,0.0344149999999999,0.0169700000000002,0.0116750000000001 +"mu.3",1.00400884522485,1.00119273844036,545.006145537412,721.191572843273,525.001599973821,524.853529459804,409.25009203697,519.896707667091,980.123379207968,597.010589383932,776.855700473939,0.012221584083923,0.00864799158514802,0.0182549999999999,0.0148200000000001,0.0200100000000001,0.015765 +"mu.4",1.00992230528499,1.00088653210741,582.054899011997,475.118727680651,572.691571673006,572.691571673006,453.404375352865,590.532677591646,1150.49950736189,1061.12497686928,297.464682466101,0.00338150237488137,0.00239230207501219,0.00423499999999999,0.00789000000000017,0.0046250000000001,0.00692500000000007 +"mu.5",1.00733922911401,1.00017537414794,754.786642573516,1073.96515350853,763.910100475586,763.910100475586,762.522622136922,764.757297566194,1601.95897581453,823.748224208616,602.971885735321,0.00535619470645841,0.0037888485986391,0.00728499999999999,0.01271,0.0105449999999998,0.00721499999999997 +"mu.6",1.0063264651477,1.00019046380718,681.62514557434,841.509646646211,710.977179062472,710.977179062472,469.426815292446,690.219361038972,496.664104993923,854.423772463052,799.11107396604,0.0128934361623842,0.00912077887401999,0.02196,0.0800150000000002,0.0284499999999999,0.015415 +"mu.7",1.0009508247325,1.00226228815332,338.501572250893,798.174111097497,338.298033186001,336.342131243366,271.172024542225,326.217452597384,925.997070900362,842.297594532647,322.156375656936,0.00461535071570276,0.00327586361996432,0.00647500000000001,0.00655499999999998,0.00410999999999995,0.00627499999999992 +"mu.8",1.0090643975564,0.999538833472528,500.370209497559,578.884594887594,493.348188663339,493.348188663339,313.922618265292,505.50985231336,1386.39640838638,640.804896232492,697.131902186388,0.00532227304880204,0.00376564253357891,0.00929000000000002,0.0093049999999999,0.0109100000000002,0.00605499999999992 +"mu.9",1.01019493017765,0.999603164368487,340.342755003858,946.607791310506,333.492896973282,317.156110862577,484.326477329234,356.445106502136,1562.99962092251,56.5180669671026,220.186644019022,0.00778879135503874,0.00565277446712757,0.00825999999999993,0.0133449999999999,0.0254349999999999,0.014645 +"mu.10",1.00075487572724,0.999511473112951,583.991419920615,471.41183217468,588.283043747639,588.283043747639,477.481294770335,590.14928532837,799.772115109561,906.418393458689,311.515150979097,0.00276260856418602,0.00195442858016026,0.00405000000000011,0.011425,0.00260499999999997,0.00502000000000002 +"mu.11",1.00595414640273,1.00237422670742,635.15097952383,800.479933058152,665.620410175752,660.540967368931,519.624529420413,655.71371952012,945.861386301234,586.20076491672,408.369416259054,0.00431255652753725,0.00306249301583716,0.00705500000000003,0.0158449999999999,0.01007,0.0102799999999998 +"mu.12",1.0047268539977,1.00514527883668,496.929163495088,531.044721860628,504.262711368638,498.71991830265,319.158390701001,480.727694997398,1853.86082845226,572.398861171123,317.880247530293,0.0057037756397616,0.0040579031206402,0.00858499999999995,0.0151549999999999,0.01154,0.00814000000000004 +"mu.13",1.008945349242,1.0056573986565,183.23984965215,350.35095755959,187.049324363394,187.049324363394,475.166782427048,178.745879678592,719.678538769825,371.680213864137,532.208029969556,0.0173131687638012,0.0122613993208749,0.00905,0.0248349999999999,0.0225550000000001,0.013755 +"mu.14",1.01304235232272,0.999571875876497,146.455619305836,905.20577806428,156.913168025411,156.913168025411,326.757781606977,184.871406789517,1501.15708995927,275.031545588726,379.47949263356,0.0112582926739193,0.00797565952859592,0.00992499999999996,0.00940499999999989,0.012775,0.00852999999999993 +"mu.15",1.00166475852766,1.00098644134086,647.052787106276,631.753828191276,650.018161664313,650.018161664313,658.62198403898,643.855640478447,836.543429989515,760.283671777858,375.926738510082,0.0060179931852768,0.00425727465663249,0.00807999999999998,0.0173800000000001,0.0116149999999999,0.00492999999999999 +"mu.16",1.00740317948224,1.00853464974225,499.036519568152,746.05300433263,501.454892472435,487.572301780466,485.396752318049,472.13048627122,1341.97413184728,277.102847934913,609.721215668554,0.00640986388102947,0.00459928387444533,0.00609499999999996,0.014005,0.0172800000000001,0.00823499999999999 +"mu.17",1.00235785729279,1.00079863526808,568.525190685684,577.67526711659,570.160744519767,570.160744519767,549.959891120856,563.848255834083,1431.69084406391,747.739233140895,581.929203983128,0.00753372166353053,0.00532987316400548,0.00883,0.02302,0.0112099999999999,0.011695 +"mu.18",1.0058815147689,0.999605048059416,542.537401212283,553.368100868642,550.366452404361,550.366452404361,433.167272775349,584.744508829451,1341.05872361933,720.895449370801,422.716253311391,0.0122763089002585,0.00868526574623527,0.01478,0.0384899999999999,0.0162549999999999,0.02017 +"mu.19",1.00414368524188,1.00060208238245,449.416857063488,739.485184107347,446.219468477619,446.219468477619,345.725868771874,449.137074366437,1561.55711641925,544.69861487889,419.996836681418,0.0160809134566196,0.0113783637269282,0.02644,0.0399750000000001,0.0198449999999999,0.02633 +"mu.20",1.00303319392542,1.00045657842583,429.352356666043,667.698241600053,408.218014375817,391.527783333572,416.536296772659,400.23475139616,1563.70741553559,133.612813080646,279.606683576796,0.00693974335849805,0.00501437741069646,0.00812000000000002,0.015245,0.012025,0.010345 +"mu.21",1.00975536911073,1.01022808966214,374.47529790908,470.815645795366,364.204306828113,362.753916792411,336.118912328005,339.216837731465,1055.53653994431,585.531004662949,181.680640103669,0.00699623341543813,0.00496095516705718,0.00904500000000019,0.0112399999999999,0.00910499999999992,0.0165649999999999 +"mu.22",1.00294755213814,0.999600478698527,674.597258384371,600.678471867714,678.699385312521,676.074215660601,324.316517855015,680.605387522155,908.437133488286,764.541352392027,383.852018821601,0.00533742583176886,0.00378308286397595,0.0127699999999999,0.010505,0.007185,0.00717499999999993 +"delta.1",1.00193273557651,1.00110042421068,1172.74856393641,974.786547170996,1419.23404652728,730.513415976935,649.830820193221,1410.38271694321,977.529406338044,782.300515662223,668.284695026047,0.0038676938490309,0.00381349766950887,0.0048955,0.0203195,0.00914400000000001,0.00684599999999999 +"delta.2",1.00439696727112,0.999671764127513,757.273755729389,1041.21641448256,841.741917392082,727.465871898432,440.437505212779,836.017025076283,910.440957531096,819.510207777999,444.090052381873,0.004732095521024,0.00360077411885722,0.0056435,0.0389715,0.013379,0.00763449999999999 +"delta.3",1.0048779262348,0.999733784057189,854.667318035899,601.21846326955,881.923285826473,626.48555548841,667.795651854425,871.389790934645,1030.78267333512,610.820032214856,543.056438051934,0.00483645532470362,0.00405951695827326,0.00615350000000001,0.0424825,0.0080035,0.00698349999999998 +"delta.4",1.00178244152549,0.999578735499239,933.614899067375,750.167856320662,960.420142222955,851.271396005864,466.804294420143,952.265093307421,1562.99962092251,808.248888293026,848.385826906282,0.00286776827314079,0.00215463906107671,0.00450449999999999,0.016153,0.00641250000000002,0.00339400000000001 +"delta.5",1.01081774716755,1.00241813072529,586.411691467462,943.409653768766,610.921485388949,610.921485388949,493.500353919725,620.944209858451,1396.11137524087,958.339509742365,773.928892663521,0.00509922346905432,0.00360741832991934,0.008062,0.020229,0.007526,0.00504300000000002 +"delta.6",1.00190020811646,1.00213136770008,933.591422341378,680.772965157487,917.641844958604,554.312744743189,466.105251245502,869.978957461908,1019.34979665739,615.944560171407,464.449517690915,0.00467404005100357,0.00425466396526783,0.00564049999999999,0.042385,0.0136695,0.00843949999999999 +"delta.7",1.00412724855361,1.00244365868817,229.195505938696,203.70063395052,239.599032907495,239.599032907495,258.226892482532,235.167900306928,1298.99528753311,469.228350866314,335.674635373719,0.00738452488138673,0.00522801720999206,0.00690850000000001,0.00962150000000001,0.011208,0.00955349999999999 +"delta.8",1.01302686669844,0.999978104471402,767.371699778806,1069.01390989025,773.726493231428,773.726493231428,524.725055273805,788.520229384147,1617.62037766705,1228.32563592793,321.895527707361,0.00418005595173392,0.00295686083398161,0.0074535,0.0110275,0.00659949999999998,0.0072275 +"delta.9",1.00240486051678,0.999686448177722,967.147813834466,805.14293480976,921.332318713367,788.822348916106,714.971441907896,911.348066015492,1181.60609792208,988.399569707274,453.575392453051,0.00390437482860046,0.00298480324159655,0.00506200000000001,0.0135795,0.00882050000000001,0.00756899999999999 +"delta.10",1.01148346905793,1.00079092738233,221.58398760916,512.070682182092,227.340028184212,227.340028184212,321.202034626446,234.227618555189,1552.55702598724,1158.43349854518,502.709517349779,0.00558111846776516,0.0039515209209377,0.006744,0.010841,0.00319900000000001,0.00472249999999999 +"delta.11",1.00436479181684,0.999546010444357,865.224447923886,936.150395054657,900.81898633316,900.81898633316,420.212037985204,909.208813980858,1856.30870029447,998.186312144878,432.595765534901,0.00353200967338314,0.00249831707951844,0.005305,0.0114425,0.00684750000000001,0.00582550000000001 +"delta.12",1.0051455786984,1.00090228472677,746.592500353552,819.359175324269,748.477550571627,748.477550571627,464.352491232897,748.709658864382,1622.75285471028,1154.40505296934,436.170801499081,0.00438862230801511,0.00310443466209018,0.005106,0.00893000000000002,0.00667599999999999,0.003271 +"delta.13",1.00712064755481,1.00136237270726,783.642427498241,702.762955320348,727.365240511934,563.476817227379,590.519739539685,722.362255781916,891.110531194617,594.203121864699,517.190497501428,0.00513748338041085,0.00412951090024318,0.005607,0.068738,0.0169845,0.00620400000000002 +"delta.14",1.00889674194067,1.00288110313765,235.105098167192,295.2486556867,184.948807956383,184.948807956383,261.769361538789,196.761686493461,1563.56576720135,508.292867142042,241.656603953636,0.0136025602147262,0.00963367190477341,0.0116275,0.0037885,0.00726100000000002,0.014438 +"delta.15",1.002224994901,1.00035977797783,866.084170529215,924.630560015452,948.425424421911,871.685667634157,585.465279369756,945.741384752513,1304.47140508689,986.025789385592,547.648223875118,0.00373367946357549,0.0027547934909225,0.00571149999999998,0.0226165,0.005799,0.00572149999999999 +"delta.16",1.00118003375548,0.999889392269564,755.774599660567,582.770014668784,776.030216190205,767.983236719523,483.546077965929,768.797014600277,1695.47768547515,739.326289777271,748.420238399519,0.00430530869948785,0.0030613836428987,0.00664550000000001,0.0131295,0.0092825,0.00629549999999998 +"delta.17",1.00380769102248,1.00076796399963,741.233121810086,962.832809052428,735.27919044424,735.27919044424,459.696957867442,725.527316156038,1299.209055217,1095.53838527224,626.271526768023,0.00469314819989086,0.00331987419547531,0.007065,0.0208985,0.0060105,0.00402949999999999 +"delta.18",1.00282616625804,0.999971769662763,947.860153722702,1023.23760607047,1077.17739932404,960.41746283251,487.717830067959,1078.46726259807,1497.18404611291,1201.49370767278,421.965090431785,0.00447069886378408,0.00334892907742204,0.007466,0.024036,0.00412000000000001,0.0032065 +"delta.19",1.00187580387435,1.001941742794,735.893087934427,371.764051856208,475.25192234922,475.25192234922,750.537309072572,471.569878282543,1696.8877681804,951.551381547666,536.673613756548,0.0071125986704165,0.00503245655434581,0.00451449999999999,0.011247,0.00719049999999999,0.00651800000000002 +"delta.20",1.00225051797168,0.999717822530123,915.344392247887,1001.50462372747,955.28139954216,905.261615031298,494.374876093356,956.356734742678,1079.60736139358,1042.06407315138,476.08812586776,0.0036538376539592,0.00265492854523789,0.004577,0.018725,0.00770850000000001,0.00630150000000002 +"delta.21",1.00334854286192,1.00257449161737,486.571699178618,1107.14145806569,503.045495460339,503.045495460339,307.419511508529,498.194977586284,1554.67632672808,722.008102896109,430.97692940852,0.00574577160547241,0.0040652320571379,0.0082565,0.024096,0.0126775,0.0101385 +"delta.22",1.00133416957847,1.00108924163034,610.268446055575,549.42853808316,591.912890331767,543.751208180864,476.866844366229,582.663245138487,1296.27868963479,862.348127263938,400.797188229444,0.00514852849282924,0.00380040612331141,0.00678100000000001,0.0247445,0.010288,0.00797699999999998 +"delta_new",1.00208610605722,1.00004179219059,917.51606421515,591.868599290851,715.969590769736,395.934298346054,690.543958491752,696.850690503065,411.457471234125,461.972146449706,317.003585824348,0.00625781442705714,0.00595475115703907,0.00437649999999998,0.075263,0.0152875,0.0082045 +"sigma_delta",1.01090190553445,0.999554581904689,73.2498471698009,48.5806371372426,95.5938079021703,95.5938079021703,132.049677080929,99.783539352302,33.1982442776445,63.6980562732759,98.6290985074029,0.00508027514881166,0.00360331482662139,0.0054414,0.0041236,0.00481375,0.0043662 diff --git a/arviz/tests/saved_models/stan_diagnostics/reference_values.csv b/arviz/tests/saved_models/stan_diagnostics/reference_values.csv deleted file mode 100644 index 94e520e136..0000000000 --- a/arviz/tests/saved_models/stan_diagnostics/reference_values.csv +++ /dev/null @@ -1,49 +0,0 @@ -"","rhat_rank","rhat_raw","ess_bulk","ess_tail","ess_mean","ess_sd","ess_raw","ess_quantile01","ess_quantile10","ess_quantile30","mcse_mean","mcse_sd","mcse_quantile01","mcse_quantile10","mcse_quantile30" -"d",1.00779361098424,1.0004168232094,465.391581378332,349.135270438316,467.84472286415,467.84472286415,467.367576858138,1500.2193689464,754.211496074801,354.746981701936,0.00265985849234941,0.00188197776671187,0.00812199999999999,0.003997,0.00375149999999999 -"sigmasq_delta",1.01091082728449,1.00035874354121,73.2716401371213,48.5806371372426,134.497570910906,134.497570910906,138.627800274732,33.1982442776445,63.6980562732759,98.6290985074029,0.00114848510125919,0.000813869235009484,0.0003001,0.000438635,0.00058668 -"mu.1",1.0073107078497,0.999545827128633,1230.5708136875,1119.63456276454,1189.5912192317,1137.76545007779,1171.62891354699,1030.60309993778,465.95223908163,635.768730056618,0.0125124382036461,0.00904921314805709,0.02589,0.0275399999999999,0.01709 -"mu.2",1.00332373036262,1.00046552033653,558.768435521813,920.913340029631,569.193418116839,569.193418116839,543.893011358525,1250.00943663727,715.745937098207,603.702320409943,0.0100753323647403,0.00712798968840261,0.02033,0.016305,0.0116750000000001 -"mu.3",1.00400419900774,1.00119273844036,545.85705475195,721.191572843273,525.001599973821,524.853529459804,519.896707667091,980.123379207968,597.010589383932,776.855700473939,0.012221584083923,0.00864799158514802,0.0148200000000001,0.01973,0.015765 -"mu.4",1.00990060868465,1.00088653210741,582.648733768269,475.118727680651,572.691571673006,572.691571673006,590.532677591646,1150.49950736189,1061.12497686928,297.464682466101,0.00338150237488137,0.00239230207501219,0.00622500000000015,0.0046250000000001,0.00668000000000002 -"mu.5",1.00733905101729,1.00017537414794,754.855859150779,1073.96515350853,763.910100475586,763.910100475586,764.757297566194,1601.95897581453,823.748224208616,602.971885735321,0.00535619470645841,0.0037888485986391,0.01271,0.0105,0.00721499999999997 -"mu.6",1.00632090915266,1.00019046380718,681.970486000608,841.509646646211,710.977179062472,710.977179062472,690.219361038972,496.664104993923,854.423772463052,799.11107396604,0.0128934361623842,0.00912077887401999,0.0800150000000002,0.02684,0.0149650000000001 -"mu.7",1.00094777831602,1.00226228815332,338.616926999257,798.174111097497,338.298033186001,336.342131243366,326.217452597384,925.997070900362,842.297594532647,322.156375656936,0.00461535071570276,0.00327586361996432,0.00655499999999998,0.00410999999999995,0.00593500000000002 -"mu.8",1.00906001078208,0.999538833472528,500.891650489241,578.884594887594,493.348188663339,493.348188663339,505.50985231336,1386.39640838638,640.804896232492,697.131902186388,0.00532227304880204,0.00376564253357891,0.00877499999999998,0.0100150000000001,0.00605499999999992 -"mu.9",1.01017385237,0.999603164368487,340.849435246069,946.607791310506,333.492896973282,317.156110862577,356.445106502136,1562.99962092251,56.5180669671026,220.186644019022,0.00778879135503874,0.00565277446712757,0.0127849999999998,0.02515,0.0144250000000001 -"mu.10",1.00075313108429,0.999511473112951,583.897502845417,471.41183217468,588.283043747639,588.283043747639,590.14928532837,799.772115109561,906.418393458689,311.515150979097,0.00276260856418602,0.00195442858016026,0.011425,0.00253499999999995,0.00500000000000012 -"mu.11",1.00594929513708,1.00237422670742,635.758182106944,800.479933058152,665.620410175752,660.540967368931,655.71371952012,945.861386301234,586.20076491672,408.369416259054,0.00431255652753725,0.00306249301583716,0.0158449999999999,0.0100099999999999,0.010265 -"mu.12",1.00472104919084,1.00514527883668,497.744253496126,531.044721860628,504.262711368638,498.71991830265,480.727694997398,1853.86082845226,572.398861171123,317.880247530293,0.0057037756397616,0.0040579031206402,0.0151549999999999,0.01154,0.00814000000000004 -"mu.13",1.00894658249289,1.0056573986565,183.251542821753,350.35095755959,187.049324363394,187.049324363394,178.745879678592,719.678538769825,371.680213864137,532.208029969556,0.0173131687638012,0.0122613993208749,0.022095,0.0225550000000001,0.0136500000000002 -"mu.14",1.0130237000943,0.999571875876497,146.557079442522,905.20577806428,156.913168025411,156.913168025411,184.871406789517,1501.15708995927,275.031545588726,379.47949263356,0.0112582926739193,0.00797565952859592,0.00940499999999989,0.012615,0.00852499999999989 -"mu.15",1.00167141524218,1.00098644134086,647.342751567988,631.753828191276,650.018161664313,650.018161664313,643.855640478447,836.543429989515,760.283671777858,375.926738510082,0.0060179931852768,0.00425727465663249,0.01539,0.0116149999999999,0.00479499999999999 -"mu.16",1.00739380163025,1.00853464974225,499.449978953057,746.05300433263,501.454892472435,487.572301780466,472.13048627122,1341.97413184728,277.102847934913,609.721215668554,0.00640986388102947,0.00459928387444533,0.0127149999999999,0.01651,0.00815999999999995 -"mu.17",1.00235390296506,1.00079863526808,568.792874437069,577.67526711659,570.160744519767,570.160744519767,563.848255834083,1431.69084406391,747.739233140895,581.929203983128,0.00753372166353053,0.00532987316400548,0.01444,0.01085,0.0110950000000001 -"mu.18",1.00588067042551,0.999605048059416,542.846720849199,553.368100868642,550.366452404361,550.366452404361,584.744508829451,1341.05872361933,720.895449370801,422.716253311391,0.0122763089002585,0.00868526574623527,0.0289649999999999,0.0162549999999999,0.020165 -"mu.19",1.00415033107819,1.00060208238245,449.511272771219,739.485184107347,446.219468477619,446.219468477619,449.137074366437,1561.55711641925,544.69861487889,419.996836681418,0.0160809134566196,0.0113783637269282,0.034605,0.0198449999999999,0.02633 -"mu.20",1.00303204643207,1.00045657842583,429.664299205849,667.698241600053,408.218014375817,391.527783333572,400.23475139616,1563.70741553559,133.612813080646,279.606683576796,0.00693974335849805,0.00501437741069646,0.0132599999999999,0.011845,0.010345 -"mu.21",1.00975896453342,1.01022808966214,374.668248619665,470.815645795366,364.204306828113,362.753916792411,339.216837731465,1055.53653994431,585.531004662949,181.680640103669,0.00699623341543813,0.00496095516705718,0.00838000000000005,0.00910499999999992,0.01654 -"mu.22",1.00294808619807,0.999600478698527,674.893910816753,600.678471867714,678.699385312521,676.074215660601,680.605387522155,908.437133488286,764.541352392027,383.852018821601,0.00533742583176886,0.00378308286397595,0.010505,0.007185,0.00717499999999993 -"delta.1",1.00193287182838,1.00110042421068,1172.60830715263,974.786547170996,1419.23404652728,730.513415976935,1410.38271694321,977.529406338044,782.300515662223,668.284695026047,0.0038676938490309,0.00381349766950887,0.0203195,0.008855,0.00675300000000001 -"delta.2",1.00440372618099,0.999671764127513,758.167164624955,1041.21641448256,841.741917392082,727.465871898432,836.017025076283,910.440957531096,819.510207777999,444.090052381873,0.004732095521024,0.00360077411885722,0.0389715,0.012482,0.007438 -"delta.3",1.00487967730361,0.999733784057189,855.367882698641,601.21846326955,881.923285826473,626.48555548841,871.389790934645,1030.78267333512,610.820032214856,543.056438051934,0.00483645532470362,0.00405951695827326,0.026668,0.0080035,0.00698349999999998 -"delta.4",1.00178244211503,0.999578735499239,933.762713299032,750.167856320662,960.420142222955,851.271396005864,952.265093307421,1562.99962092251,808.248888293026,848.385826906282,0.00286776827314079,0.00215463906107671,0.015692,0.00632949999999999,0.0033465 -"delta.5",1.01081423687836,1.00241813072529,586.638919259683,943.409653768766,610.921485388949,610.921485388949,620.944209858451,1396.11137524087,958.339509742365,773.928892663521,0.00509922346905432,0.00360741832991934,0.020114,0.00727900000000001,0.00504300000000002 -"delta.6",1.00189676437543,1.00213136770008,933.858237578928,680.772965157487,917.641844958604,554.312744743189,869.978957461908,1019.34979665739,615.944560171407,464.449517690915,0.00467404005100357,0.00425466396526783,0.031053,0.0136695,0.00831199999999999 -"delta.7",1.00412405666732,1.00244365868817,229.313942618182,203.70063395052,239.599032907495,239.599032907495,235.167900306928,1298.99528753311,469.228350866314,335.674635373719,0.00738452488138673,0.00522801720999206,0.00822149999999999,0.010542,0.00947900000000002 -"delta.8",1.01301342508601,0.999978104471402,767.819052313474,1069.01390989025,773.726493231428,773.726493231428,788.520229384147,1617.62037766705,1228.32563592793,321.895527707361,0.00418005595173392,0.00295686083398161,0.00915500000000002,0.00626649999999998,0.007163 -"delta.9",1.00240866105571,0.999686448177722,967.019710843146,805.14293480976,921.332318713367,788.822348916106,911.348066015492,1181.60609792208,988.399569707274,453.575392453051,0.00390437482860046,0.00298480324159655,0.00871450000000001,0.00872800000000001,0.00748149999999997 -"delta.10",1.01149479755491,1.00079092738233,221.748765135302,512.070682182092,227.340028184212,227.340028184212,234.227618555189,1552.55702598724,1158.43349854518,502.709517349779,0.00558111846776516,0.0039515209209377,0.010333,0.0030895,0.00457949999999999 -"delta.11",1.00436909828894,0.999546010444357,865.397198655323,936.150395054657,900.81898633316,900.81898633316,909.208813980858,1856.30870029447,998.186312144878,432.595765534901,0.00353200967338314,0.00249831707951844,0.0114425,0.00665399999999999,0.00577749999999999 -"delta.12",1.00513856522513,1.00090228472677,747.43024544793,819.359175324269,748.477550571627,748.477550571627,748.709658864382,1622.75285471028,1154.40505296934,436.170801499081,0.00438862230801511,0.00310443466209018,0.00618050000000001,0.0065615,0.003271 -"delta.13",1.0071228453549,1.00136237270726,783.329487572603,702.762955320348,727.365240511934,563.476817227379,722.362255781916,891.110531194617,594.203121864699,517.190497501428,0.00513748338041085,0.00412951090024318,0.0660655,0.0168595,0.00620400000000002 -"delta.14",1.0088854165393,1.00288110313765,235.323742861501,295.2486556867,184.948807956383,184.948807956383,196.761686493461,1563.56576720135,508.292867142042,241.656603953636,0.0136025602147262,0.00963367190477341,0.0037885,0.00726100000000002,0.0141405 -"delta.15",1.00222251147504,1.00035977797783,866.697641846641,924.630560015452,948.425424421911,871.685667634157,945.741384752513,1304.47140508689,986.025789385592,547.648223875118,0.00373367946357549,0.0027547934909225,0.0198205,0.005799,0.00572149999999999 -"delta.16",1.00117097566735,0.999889392269564,756.075221862548,582.770014668784,776.030216190205,767.983236719523,768.797014600277,1695.47768547515,739.326289777271,748.420238399519,0.00430530869948785,0.0030613836428987,0.0131295,0.0088675,0.006189 -"delta.17",1.00380442428859,1.00076796399963,741.413313208893,962.832809052428,735.27919044424,735.27919044424,725.527316156038,1299.209055217,1095.53838527224,626.271526768023,0.00469314819989086,0.00331987419547531,0.0202375,0.0060105,0.00398999999999999 -"delta.18",1.00282542725116,0.999971769662763,949.154491333636,1023.23760607047,1077.17739932404,960.41746283251,1078.46726259807,1497.18404611291,1201.49370767278,421.965090431785,0.00447069886378408,0.00334892907742204,0.024036,0.00412000000000001,0.00317600000000001 -"delta.19",1.00187252720121,1.001941742794,735.755754286384,371.764051856208,475.25192234922,475.25192234922,471.569878282543,1696.8877681804,951.551381547666,536.673613756548,0.0071125986704165,0.00503245655434581,0.0105465,0.00716999999999998,0.00651800000000002 -"delta.20",1.00224195001419,0.999717822530123,915.523575402071,1001.50462372747,955.28139954216,905.261615031298,956.356734742678,1079.60736139358,1042.06407315138,476.08812586776,0.0036538376539592,0.00265492854523789,0.0173415,0.00713650000000002,0.00628049999999999 -"delta.21",1.0033504882547,1.00257449161737,487.133267118229,1107.14145806569,503.045495460339,503.045495460339,498.194977586284,1554.67632672808,722.008102896109,430.97692940852,0.00574577160547241,0.0040652320571379,0.0207135,0.0123465,0.00991050000000002 -"delta.22",1.00132619804709,1.00108924163034,611.231305918471,549.42853808316,591.912890331767,543.751208180864,582.663245138487,1296.27868963479,862.348127263938,400.797188229444,0.00514852849282924,0.00380040612331141,0.0229695,0.010137,0.00797699999999998 -"delta_new",1.00209278850047,1.00004179219059,916.055451985339,591.868599290851,715.969590769736,395.934298346054,696.850690503065,411.457471234125,461.972146449706,317.003585824348,0.00625781442705714,0.00595475115703907,0.0751555,0.0150905,0.0082045 -"sigma_delta",1.01091076457991,0.999554581904689,73.2718637441743,48.5806371372426,95.5938079021703,95.5938079021703,99.783539352302,33.1982442776445,63.6980562732759,98.6290985074029,0.00508027514881166,0.00360331482662139,0.0041236,0.00473565,0.0043662 diff --git a/arvizrc.template b/arvizrc.template index bab7d16a78..691a400644 100644 --- a/arvizrc.template +++ b/arvizrc.template @@ -15,6 +15,7 @@ data.metagroups : { observed_vars: posterior_predictive, observed_data, prior_predictive } data.save_warmup : false # save warmup iterations, one of "true", "false" +data.pandas_float_precision : high # pandas csv_reader float_precision, one of "high", None, "round_trip" ### PLOT ### # rcParams related with plotting functions diff --git a/doc/sphinxext/gallery_generator.py b/doc/sphinxext/gallery_generator.py index bedc96eabd..d610c54902 100644 --- a/doc/sphinxext/gallery_generator.py +++ b/doc/sphinxext/gallery_generator.py @@ -254,8 +254,7 @@ def pagetitle(self): return self.docstring.strip().split("\n")[0].strip() def extract_docstring(self): - """ Extract a module-level docstring - """ + """Extract a module-level docstring""" lines = open(self.filename).readlines() start_row = 0 if lines[0].startswith("#!"):