This report documents the results of a simulation based calibration (SBC) run for RBesT
. The calibration data will be generated whenever relevant changes to the gMAP
function were made. The calibration runs are performed for typical use cases of gMAP
. These include the three likelihoods (binomial, gaussian & Poisson), a sparse (\(2\) trials) and dense (\(10\) trials) data situation and finally a run with a very/less conservative prior choice for between-trial heterogeniety parameter.
The calibration data presented here has been generated at and with the RBesT
git version as:
## Created: 2019-09-09 09:16:25 UTC
## git hash: f85c162edea51c918f223293ffad076fbc26dc6f
## MD5: 50ca8fb6ca274d2ace9a66818b44cec3
The MD5 hash of the calibration data file presented here must match the above listed MD5:
## calibration.rds
## "50ca8fb6ca274d2ace9a66818b44cec3"
Simulation based calibration (SBC) is a necessary condition which must be met for any Bayesian analysis with proper priors. The details are presented in Talts, et. al (see https://arxiv.org/abs/1804.06788).
Self-consistency of any Bayesian analysis with a proper prior:
\[ p(\theta) = \iint \mbox{d}\tilde{y} \, \mbox{d}\tilde{\theta} \, p(\theta|\tilde{y}) \, p(\tilde{y}|\tilde{\theta}) \, p(\tilde{\theta}) \] \[ \Leftrightarrow p(\theta) = \iint \mbox{d}\tilde{y} \, \mbox{d}\tilde{\theta} \, p(\theta,\tilde{y},\tilde{\theta}) \]
SBC procedure:
Repeat \(s=1, ..., S\) times:
Sample from the prior \[\tilde{\theta} \sim p(\theta)\]
Sample fake data \[\tilde{y} \sim p(y|\tilde{\theta})\]
Obtain \(L\) posterior samples \[\{\theta_1, ..., \theta_L\} \sim p(\tilde{\theta}|\tilde{y})\]
Calculate the rank \(r_s\) of the prior draw \(\tilde{\theta}\) wrt to the posterior sample \(\{\theta_1, ..., \theta_L\} \sim p(\tilde{\theta}|\tilde{y})\) which falls into the range \([0,L]\) out of the possible \(L+1\) ranks. The rank is calculated as \[r_s = \sum_{l=1}^L \mathbb{I}[ \theta_l < \tilde{\theta}]\]
The \(S\) ranks then form a uniform \(0-1\) density and the count in each bin has a binomial distribution with probability of \[p(r \in \mbox{Any Bin}) =\frac{(L+1)}{S}.\]
Likelihood:
Hierarchical prior:
\[ g(\theta_j)|\mu,\tau \sim \mbox{Normal}(\mu, \tau^2)\]
\[\mu \sim \mbox{Normal}(m_\mu, s^2_\mu)\] \[\tau \sim \mbox{Normal}^+(0, s^2_\tau)\]
The fake data simulation function returns for binomial and Poisson data the sum of the responses while for normal the mean summary is used. Please refer to the sbc_tools.R
and make_reference_rankhist.R
R programs for the implementation details.
The reference runs are created with \(L=1023\) posterior draws for each replication and a total of \(S=10^4\) replications are run per case. For the evaluation here the results are reduced to \(B=L'+1=64\) bins to ensure a sufficiently large sample size per bin.
problem | likelihood | sd_tau | statistic | df | p.value |
---|---|---|---|---|---|
dense | binomial | 0.5 | 46.886 | 63 | 0.936 |
dense | binomial | 1 | 64.717 | 63 | 0.416 |
dense | gaussian | 0.5 | 74.099 | 63 | 0.160 |
dense | gaussian | 1 | 46.170 | 63 | 0.945 |
dense | poisson | 0.5 | 44.467 | 63 | 0.963 |
dense | poisson | 1 | 57.254 | 63 | 0.680 |
sparse | binomial | 0.5 | 43.994 | 63 | 0.967 |
sparse | binomial | 1 | 53.734 | 63 | 0.791 |
sparse | gaussian | 0.5 | 50.266 | 63 | 0.877 |
sparse | gaussian | 1 | 57.446 | 63 | 0.674 |
sparse | poisson | 0.5 | 62.502 | 63 | 0.494 |
sparse | poisson | 1 | 70.490 | 63 | 0.242 |
problem | likelihood | sd_tau | statistic | df | p.value |
---|---|---|---|---|---|
dense | binomial | 0.5 | 56.141 | 63 | 0.717 |
dense | binomial | 1 | 69.568 | 63 | 0.266 |
dense | gaussian | 0.5 | 67.635 | 63 | 0.322 |
dense | gaussian | 1 | 61.056 | 63 | 0.546 |
dense | poisson | 0.5 | 73.741 | 63 | 0.167 |
dense | poisson | 1 | 54.080 | 63 | 0.781 |
sparse | binomial | 0.5 | 66.790 | 63 | 0.348 |
sparse | binomial | 1 | 69.734 | 63 | 0.261 |
sparse | gaussian | 0.5 | 53.363 | 63 | 0.801 |
sparse | gaussian | 1 | 61.069 | 63 | 0.545 |
sparse | poisson | 0.5 | 56.627 | 63 | 0.701 |
sparse | poisson | 1 | 65.331 | 63 | 0.396 |
## R version 3.5.2 (2018-12-20)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS Mojave 10.14.6
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
##
## locale:
## [1] C/UTF-8/C/C/C/C
##
## attached base packages:
## [1] tools stats graphics grDevices datasets utils methods
## [8] base
##
## other attached packages:
## [1] rstan_2.19.2 StanHeaders_2.19.0 RBesT_1.5-4
## [4] testthat_2.2.1 Rcpp_1.0.2 devtools_2.2.1
## [7] usethis_1.5.1 ggplot2_3.2.1 broom_0.5.2
## [10] tidyr_1.0.0 dplyr_0.8.3 assertthat_0.2.1
## [13] knitr_1.25 rmarkdown_1.16
##
## loaded via a namespace (and not attached):
## [1] mvtnorm_1.0-11 lattice_0.20-38 prettyunits_1.0.2
## [4] ps_1.3.0 zeallot_0.1.0 rprojroot_1.3-2
## [7] digest_0.6.21 plyr_1.8.4 R6_2.4.0
## [10] ggridges_0.5.1 backports_1.1.5 stats4_3.5.2
## [13] evaluate_0.14 highr_0.8 pillar_1.4.2
## [16] rlang_0.4.0 lazyeval_0.2.2 rstudioapi_0.10
## [19] callr_3.3.2 checkmate_1.9.4 labeling_0.3
## [22] desc_1.2.0 stringr_1.4.0 loo_2.1.0
## [25] munsell_0.5.0 compiler_3.5.2 xfun_0.10
## [28] pkgconfig_2.0.3 pkgbuild_1.0.6 htmltools_0.4.0
## [31] tidyselect_0.2.5 tibble_2.1.3 gridExtra_2.3
## [34] codetools_0.2-15 matrixStats_0.55.0 crayon_1.3.4
## [37] withr_2.1.2 grid_3.5.2 nlme_3.1-137
## [40] gtable_0.3.0 lifecycle_0.1.0 magrittr_1.5
## [43] scales_1.0.0 cli_1.1.0 stringi_1.4.3
## [46] reshape2_1.4.3 fs_1.3.1 remotes_2.1.0
## [49] ellipsis_0.3.0 generics_0.0.2 vctrs_0.2.0
## [52] Formula_1.2-3 glue_1.3.1 purrr_0.3.3
## [55] processx_3.4.1 pkgload_1.0.2 parallel_3.5.2
## [58] yaml_2.2.0 inline_0.3.15 colorspace_1.4-1
## [61] sessioninfo_1.1.1 bayesplot_1.7.0 memoise_1.1.0