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:  2023-01-20 14:52:50 UTC
## git hash: 424ac41daf27a33095f2b646e563943682542324
## MD5:      63b1ec912316b1e89a89475af2e27d7c

The MD5 hash of the calibration data file presented here must match the above listed MD5:

## /gitlab-runner/builds/53wtLnsi/0/SMC/BesT/inst/sbc/calibration.rds 
##                                 "63b1ec912316b1e89a89475af2e27d7c"

Introduction

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:

  1. Sample from the prior \[\tilde{\theta} \sim p(\theta)\]

  2. Sample fake data \[\tilde{y} \sim p(y|\tilde{\theta})\]

  3. Obtain \(L\) posterior samples \[\{\theta_1, ..., \theta_L\} \sim p(\tilde{\theta}|\tilde{y})\]

  4. 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}.\]

Hierarchical intercept only (random-effects intercept) model for binomial, gaussian and Poisson likelihood

Likelihood:

  • Binary \[y_i|\theta_{j} \sim \mbox{Bernoulli}(\theta_j), \] \[g(\theta) = \mbox{logit}(\theta)\]
  • Normal \[y_i|\theta_{j} \sim \mbox{Normal}(\theta_j, \sigma^2), \] \[g(\theta) = \theta\]
  • Poisson \[y_i|\theta_{j} \sim \mbox{Poisson}(\theta_j), \] \[g(\theta) = \log(\theta)\]

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.

SBC results

Sampler Diagnostics Overview

family data_scenario sd_tau N total_divergent total_divergent_sim_fraction min_ess max_Rhat total_large_Rhat min_lp_ess_bulk min_lp_ess_tail
binomial dense 0.5 10000 40 0.004 550 1.009 0 228 120
binomial dense 1.0 10000 50 0.004 349 1.018 0 161 174
binomial sparse 0.5 10000 1 0.000 487 1.012 0 186 81
binomial sparse 1.0 10000 3 0.000 196 1.016 0 144 118
gaussian dense 0.5 10000 96 0.008 172 1.026 0 204 103
gaussian dense 1.0 10000 82 0.006 99 1.032 0 147 171
gaussian sparse 0.5 10000 446 0.022 10 1.250 1 15 67
gaussian sparse 1.0 10000 909 0.043 25 1.108 0 81 142
poisson dense 0.5 10000 122 0.011 223 1.024 0 54 140
poisson dense 1.0 10000 156 0.011 16 1.236 1 46 116
poisson sparse 0.5 10000 723 0.035 16 1.071 0 132 141
poisson sparse 1.0 10000 2319 0.044 2 13.834 1 4 22

Note: Large Rhat is defined as exceeding 1.2.

Summary Statistics

\(\chi^2\) Statistic, \(\mu\)

data_scenario likelihood sd_tau parameter statistic df p.value
1 dense binomial 0.5 mu 57.830 63 0.661
13 dense binomial 1 mu 63.245 63 0.468
25 dense gaussian 0.5 mu 73.638 63 0.169
37 dense gaussian 1 mu 58.752 63 0.628
49 dense poisson 0.5 mu 76.122 63 0.124
61 dense poisson 1 mu 79.680 63 0.076
73 sparse binomial 0.5 mu 61.837 63 0.518
78 sparse binomial 1 mu 62.528 63 0.493
83 sparse gaussian 0.5 mu 77.248 63 0.107
88 sparse gaussian 1 mu 73.165 63 0.179
93 sparse poisson 0.5 mu 56.333 63 0.711
98 sparse poisson 1 mu 86.195 63 0.028

\(\chi^2\) Statistic, \(\tau\)

data_scenario likelihood sd_tau parameter statistic df p.value
2 dense binomial 0.5 tau 97.242 63 0.004
14 dense binomial 1 tau 59.533 63 0.601
26 dense gaussian 0.5 tau 70.963 63 0.230
38 dense gaussian 1 tau 72.166 63 0.201
50 dense poisson 0.5 tau 67.712 63 0.320
62 dense poisson 1 tau 65.843 63 0.379
74 sparse binomial 0.5 tau 79.066 63 0.083
79 sparse binomial 1 tau 48.640 63 0.908
84 sparse gaussian 0.5 tau 71.334 63 0.220
89 sparse gaussian 1 tau 76.621 63 0.116
94 sparse poisson 0.5 tau 78.938 63 0.085
99 sparse poisson 1 tau 74.470 63 0.153

\(\chi^2\) Statistic, group estimates \(\theta\)

data_scenario likelihood sd_tau parameter statistic df p.value
3 dense binomial 0.5 theta\[1\] 75.930 63 0.127
4 dense binomial 0.5 theta\[10\] 43.533 63 0.971
5 dense binomial 0.5 theta\[2\] 68.800 63 0.288
6 dense binomial 0.5 theta\[3\] 60.992 63 0.548
7 dense binomial 0.5 theta\[4\] 64.026 63 0.440
8 dense binomial 0.5 theta\[5\] 58.701 63 0.630
9 dense binomial 0.5 theta\[6\] 41.280 63 0.984
10 dense binomial 0.5 theta\[7\] 78.208 63 0.094
11 dense binomial 0.5 theta\[8\] 55.270 63 0.745
12 dense binomial 0.5 theta\[9\] 72.154 63 0.201
15 dense binomial 1 theta\[1\] 72.358 63 0.196
16 dense binomial 1 theta\[10\] 54.515 63 0.768
17 dense binomial 1 theta\[2\] 85.619 63 0.031
18 dense binomial 1 theta\[3\] 55.219 63 0.747
19 dense binomial 1 theta\[4\] 71.629 63 0.213
20 dense binomial 1 theta\[5\] 61.811 63 0.519
21 dense binomial 1 theta\[6\] 52.890 63 0.814
22 dense binomial 1 theta\[7\] 64.448 63 0.426
23 dense binomial 1 theta\[8\] 50.202 63 0.879
24 dense binomial 1 theta\[9\] 58.918 63 0.622
27 dense gaussian 0.5 theta\[1\] 60.390 63 0.570
28 dense gaussian 0.5 theta\[10\] 59.789 63 0.591
29 dense gaussian 0.5 theta\[2\] 64.154 63 0.436
30 dense gaussian 0.5 theta\[3\] 58.842 63 0.625
31 dense gaussian 0.5 theta\[4\] 48.077 63 0.918
32 dense gaussian 0.5 theta\[5\] 67.085 63 0.339
33 dense gaussian 0.5 theta\[6\] 71.731 63 0.211
34 dense gaussian 0.5 theta\[7\] 83.059 63 0.046
35 dense gaussian 0.5 theta\[8\] 58.048 63 0.653
36 dense gaussian 0.5 theta\[9\] 69.197 63 0.276
39 dense gaussian 1 theta\[1\] 70.157 63 0.250
40 dense gaussian 1 theta\[10\] 83.136 63 0.046
41 dense gaussian 1 theta\[2\] 66.688 63 0.351
42 dense gaussian 1 theta\[3\] 61.914 63 0.515
43 dense gaussian 1 theta\[4\] 38.413 63 0.994
44 dense gaussian 1 theta\[5\] 73.254 63 0.177
45 dense gaussian 1 theta\[6\] 82.611 63 0.049
46 dense gaussian 1 theta\[7\] 43.866 63 0.968
47 dense gaussian 1 theta\[8\] 71.501 63 0.216
48 dense gaussian 1 theta\[9\] 70.362 63 0.245
51 dense poisson 0.5 theta\[1\] 68.493 63 0.296
52 dense poisson 0.5 theta\[10\] 50.598 63 0.870
53 dense poisson 0.5 theta\[2\] 61.875 63 0.516
54 dense poisson 0.5 theta\[3\] 76.480 63 0.118
55 dense poisson 0.5 theta\[4\] 64.589 63 0.421
56 dense poisson 0.5 theta\[5\] 47.027 63 0.934
57 dense poisson 0.5 theta\[6\] 74.547 63 0.151
58 dense poisson 0.5 theta\[7\] 58.534 63 0.636
59 dense poisson 0.5 theta\[8\] 72.448 63 0.194
60 dense poisson 0.5 theta\[9\] 65.920 63 0.376
63 dense poisson 1 theta\[1\] 69.235 63 0.275
64 dense poisson 1 theta\[10\] 57.101 63 0.685
65 dense poisson 1 theta\[2\] 36.467 63 0.997
66 dense poisson 1 theta\[3\] 54.771 63 0.760
67 dense poisson 1 theta\[4\] 69.414 63 0.270
68 dense poisson 1 theta\[5\] 62.605 63 0.490
69 dense poisson 1 theta\[6\] 47.910 63 0.921
70 dense poisson 1 theta\[7\] 46.451 63 0.941
71 dense poisson 1 theta\[8\] 61.734 63 0.522
72 dense poisson 1 theta\[9\] 45.888 63 0.948
75 sparse binomial 0.5 theta\[1\] 53.760 63 0.790
76 sparse binomial 0.5 theta\[2\] 93.286 63 0.008
77 sparse binomial 0.5 theta\[3\] 53.850 63 0.788
80 sparse binomial 1 theta\[1\] 67.635 63 0.322
81 sparse binomial 1 theta\[2\] 59.008 63 0.619
82 sparse binomial 1 theta\[3\] 73.792 63 0.166
85 sparse gaussian 0.5 theta\[1\] 65.254 63 0.398
86 sparse gaussian 0.5 theta\[2\] 57.152 63 0.684
87 sparse gaussian 0.5 theta\[3\] 68.378 63 0.300
90 sparse gaussian 1 theta\[1\] 76.544 63 0.117
91 sparse gaussian 1 theta\[2\] 60.621 63 0.562
92 sparse gaussian 1 theta\[3\] 74.714 63 0.148
95 sparse poisson 0.5 theta\[1\] 91.174 63 0.012
96 sparse poisson 0.5 theta\[2\] 79.283 63 0.081
97 sparse poisson 0.5 theta\[3\] 75.110 63 0.141
100 sparse poisson 1 theta\[1\] 63.578 63 0.456
101 sparse poisson 1 theta\[2\] 54.541 63 0.767
102 sparse poisson 1 theta\[3\] 82.368 63 0.051

Session Info

## R version 4.1.0 (2021-05-18)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.5 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] tools     stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] purrr_0.3.4          rstan_2.21.2         StanHeaders_2.21.0-7
##  [4] here_1.0.1           ggplot2_3.3.5        broom_0.7.9         
##  [7] tidyr_1.1.3          dplyr_1.0.8          assertthat_0.2.1    
## [10] knitr_1.33          
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_1.1.1   xfun_0.25          V8_3.4.2           colorspace_2.0-2  
##  [5] vctrs_0.3.8        generics_0.1.0     htmltools_0.5.2    stats4_4.1.0      
##  [9] loo_2.4.1          yaml_2.2.1         utf8_1.2.2         rlang_1.0.1       
## [13] pkgbuild_1.2.0     pillar_1.6.2       glue_1.6.1         withr_2.4.3       
## [17] DBI_1.1.2          matrixStats_0.60.1 lifecycle_1.0.1    stringr_1.4.0     
## [21] munsell_0.5.0      gtable_0.3.0       codetools_0.2-18   evaluate_0.14     
## [25] inline_0.3.19      callr_3.7.0        fastmap_1.1.0      ps_1.6.0          
## [29] parallel_4.1.0     curl_4.3.2         fansi_0.5.0        highr_0.9         
## [33] Rcpp_1.0.7         scales_1.1.1       backports_1.2.1    RcppParallel_5.1.4
## [37] jsonlite_1.7.2     gridExtra_2.3      digest_0.6.29      stringi_1.7.3     
## [41] processx_3.5.2     grid_4.1.0         rprojroot_2.0.2    cli_3.1.1         
## [45] magrittr_2.0.1     tibble_3.1.3       crayon_1.4.2       pkgconfig_2.0.3   
## [49] ellipsis_0.3.2     prettyunits_1.1.1  rmarkdown_2.11     R6_2.5.1          
## [53] compiler_4.1.0