-
Notifications
You must be signed in to change notification settings - Fork 1
/
prior_sensitivity.Rmd
459 lines (411 loc) · 17.8 KB
/
prior_sensitivity.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
---
title: "DNAm Hierarchical Model - Prior Sensitivity Analysis "
author: "Kevin Murgas"
date: "`r Sys.Date()`"
output:
pdf_document:
fig_caption: true
number_section: true
toc: true
---
\newpage
Prior sensitivity is assessed by looking at Stan fit results of different sets of priors, each with an increasing level of variance relaxation. Current data: 1x (original), 2x, 3x, and 5x.
\newline Priors are assessed by 3 metrics: n_eff and Rhat to assess Stan MCMC convergence, and Kullback-Leibler divergence to assess prior constraints.
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(knitr)
#library(gtools)
library(emdist)
library(ggpubr)
# set working directory
setwd("/Users/kevinmurgas/Documents/Data+ project/EPIC data")
library(here)
select <- dplyr::select
rename <- dplyr::rename
filter <- dplyr::filter
slice <- dplyr::slice
```
```{r prior_dataAndFits, echo=FALSE, comment=NA}
# load TCGA-based 450K array estimates (see estimateTCGApriors.R for data+fits)
load("/Users/kevinmurgas/Documents/Data+ project/TCGA data/estimates_allpats.Rdata")
# remove all zeros, and take square root of variance (stored variable) to get sigma/stdev
sigmaP_ests <- sqrt(sigmaP_ests[which(!!sigmaP_ests)])
sigmaPT_ests <- sqrt(sigmaPT_ests[which(!!sigmaPT_ests)])
sigmaT_ests <- sqrt(sigmaT_ests[which(!!sigmaT_ests)])
mu_ests <- mu_ests[which(!!mu_ests)]
nu_ests <- nu_ests[which(!!nu_ests)]
gg_color_hue <- function(n) {
hues = seq(15, 375, length = n + 1)
hcl(h = hues, l = 65, c = 100)[1:n]
}
cols = gg_color_hue(4)
# ggplot histograms, with fit overlays
# mu
# 1x: 0.35570*normal(-3.0675,0.75214) + 0.64430*normal(1.1290, 1.3920)
# 2x: 0.35570*normal(-3.0675, 1.0637) + 0.64430*normal(1.1290, 1.9685)
# 3x: 0.35570*normal(-3.0675, 1.3027) + 0.64430*normal(1.1290, 2.4110)
# 5x: 0.35570*normal(-3.0675, 1.6818) + 0.64430*normal(1.1290, 3.1125)
f <- function(x, a, m1, s1, m2, s2) a*dnorm(x,m1,s1) + (1-a)*dnorm(x,m2,s2)
p1 <- ggplot(data.frame(p=mu_ests), aes(x=p)) + geom_histogram(binwidth=0.1,aes(y=..density..),fill="lightgray") + theme_classic() +
#labs(x=expression(mu)) +
xlim(-6,6) +
stat_function(fun=function(x) f(x,0.3557,-3.0675, 0.75214,1.1290, 1.39197),geom="line",color=cols[1]) +
stat_function(fun=function(x) f(x,0.3557,-3.0675, 1.0637,1.1290, 1.9685),geom="line",color=cols[2]) +
stat_function(fun=function(x) f(x,0.3557,-3.0675, 1.3027,1.1290, 2.4110),geom="line",color=cols[3]) +
stat_function(fun=function(x) f(x,0.3557,-3.0675, 1.6818,1.1290, 3.1125),geom="line",color=cols[4])
# nu
# 1x: Cauchy(-0.04051, 0.19330)
# 2x: Cauchy(-0.04051, 0.38660)
# 3x: Cauchy(-0.04051, 0.57990)
# 5x: Cauchy(-0.04051, 0.96650)
p2 <- ggplot(data.frame(p=nu_ests), aes(x=p)) + geom_histogram(binwidth=0.1,aes(y=..density..),fill="lightgray") + theme_classic() +
#labs(x=expression(nu)) +
xlim(-5,5) +
stat_function(fun=function(x) dcauchy(x,-0.04051, 0.19330),geom="line",color=cols[1]) +
stat_function(fun=function(x) dcauchy(x,-0.04051, 0.38660),geom="line",color=cols[2]) +
stat_function(fun=function(x) dcauchy(x,-0.04051, 0.57990),geom="line",color=cols[3]) +
stat_function(fun=function(x) dcauchy(x,-0.04051, 0.96650),geom="line",color=cols[4])
# sigmaE: all gamma(2,2)
p3 <- ggplot() + stat_function(fun=function(x) dgamma(x,2,2),geom="line",color="black") + xlim(0,2) + theme_classic() + labs(x=expression(sigma[E]))
# sigmaP
# 1x: gamma(5.1989, 16.6192)
# 2x: gamma(3.4016, 9.5057)
# 3x: gamma(2.7693, 7.0029)
# 5x: gamma(2.2298, 4.8674)
p4 <- ggplot(data.frame(p=sigmaP_ests), aes(x=p)) + geom_histogram(binwidth=0.02,aes(y=..density..),fill="lightgray") + theme_classic() +
#labs(x=expression(sigma[P])) +
xlim(0,2) +
stat_function(fun=function(x) dgamma(x,5.1989, 16.6192),geom="line",color=cols[1]) +
stat_function(fun=function(x) dgamma(x,3.4016, 9.5057),geom="line",color=cols[2]) +
stat_function(fun=function(x) dgamma(x,2.7693, 7.0029),geom="line",color=cols[3]) +
stat_function(fun=function(x) dgamma(x,2.2298, 4.8674),geom="line",color=cols[4])
# sigmaPT
# 1x: gamma(3.5539, 5.5324)
# 2x: gamma(2.5210, 3.2948)
# 3x: gamma(2.1457, 2.4819)
# 5x: gamma(1.8166, 1.7689)
p5 <- ggplot(data.frame(p=sigmaPT_ests), aes(x=p)) + geom_histogram(binwidth=0.02,aes(y=..density..),fill="lightgray") + theme_classic() +
#labs(x=expression(sigma[PT])) +
xlim(0,2) +
stat_function(fun=function(x) dgamma(x,3.5539, 5.5324),geom="line",color=cols[1]) +
stat_function(fun=function(x) dgamma(x,2.5210, 3.2948),geom="line",color=cols[2]) +
stat_function(fun=function(x) dgamma(x,2.1457, 2.4819),geom="line",color=cols[3]) +
stat_function(fun=function(x) dgamma(x,1.8166, 1.7689),geom="line",color=cols[4])
# sigmaT
# 1x: gamma(6.8383, 25.7560)
# 2x: gamma(4.2574, 14.370)
# 3x: gamma(3.3643, 10.430)
# 5x: gamma(2.6144, 7.1221)
p6 <- ggplot(data.frame(p=sigmaT_ests), aes(x=p)) + geom_histogram(binwidth=0.02,aes(y=..density..),fill="lightgray") + theme_classic() +
xlim(0,2) +
#labs(x=expression(sigma[T])) +
stat_function(fun=function(x) dgamma(x,6.8383, 25.7560),geom="line",color=cols[1]) +
stat_function(fun=function(x) dgamma(x,4.2574, 14.370),geom="line",color=cols[2]) +
stat_function(fun=function(x) dgamma(x,3.3643, 10.430),geom="line",color=cols[3]) +
stat_function(fun=function(x) dgamma(x,2.6144, 7.1221),geom="line",color=cols[4])
p_all <- ggarrange(p1,p2,p3,p4,p5,p6)
# ggsave("prior_fits_all.svg",p_all,height=3,width=5.53,dpi=300)
```
```{r prior_sensitivity, echo=FALSE, comment=NA}
n_eff_mat <- data.frame(Params=c("mu","nu","sigmaP","sigmaPT","sigmaT","sigmaE","lp"))
Rhat_mat <- n_eff_mat
KLdiv_mat <- n_eff_mat %>% slice(1:6)
BCdist_mat <- KLdiv_mat
EMdist_mat <- KLdiv_mat
for (i in c(1:4)) {
stanFile = "FullResultsTCGA_relaxgamma3.Rdata"
stanFile = switch(i,
"FullResultsTCGA_gamma.Rdata",
"FullResultsTCGA_relaxgamma2.Rdata",
"FullResultsTCGA_relaxgamma3.Rdata",
"FullResultsTCGA_relaxgamma5.Rdata")
print(stanFile)
load(here(stanFile))
print("loaded")
n_eff_temp <-
data.frame(
mu = mu_full$n_eff,
nu = nu_full$n_eff,
sigmaP = sigmaP_full$n_eff,
sigmaPT = sigmaPT_full$n_eff,
sigmaT = sigmaT_full$n_eff,
sigmaE = sigmaE_full$n_eff,
lp = lp_full$n_eff
) %>% gather(param,value,mu:lp) %>% group_by(param) %>% summarize(
mean = mean(value),
.groups = "drop"
) %>% arrange(match(.$param,c("mu","nu","sigmaP","sigmaPT","sigmaT","sigmaE","lp")))
Rhat_temp <-
data.frame(
mu = mu_full$Rhat,
nu = nu_full$Rhat,
sigmaP = sigmaP_full$Rhat,
sigmaPT = sigmaPT_full$Rhat,
sigmaT = sigmaT_full$Rhat,
sigmaE = sigmaE_full$Rhat,
lp = lp_full$Rhat
) %>% gather(param,value,mu:lp) %>% group_by(param) %>% summarize(
mean = mean(value),
.groups = "drop"
) %>% arrange(match(.$param,c("mu","nu","sigmaP","sigmaPT","sigmaT","sigmaE","lp")))
# KL divergence
# formula: KL(P||Q) = sum(P(i) * log( P(i)/Q(i) )), where P(i),Q(i) = density
KL_temp <- numeric(6)
#Bhattacharya distance
# formula: BC = sum( sqrt(P(i)*Q(i)) )
BC_temp <- numeric(6)
# Earth-movers (Wasserstein) distance
EM_temp <- numeric(6)
for (j in c(1:6)) {
# choose parameter
data <- switch(j,
mu_full$p50,
nu_full$p50,
sigmaP_full$p50,
sigmaPT_full$p50,
sigmaT_full$p50,
sigmaE_full$p50)
breaks <- switch(j,
seq(-5,5,0.1),
seq(-6,6,0.12), #5.5,.11
seq(0,3,0.03), #2.6
seq(0,3,0.03),
seq(0,3,0.03), #1.2
seq(0,3,0.03)) #2.5
P <- hist(data, plot=FALSE, breaks=101) # run hist to get density and midpoints
x <- P$mids
# define prior density by pre-defined priors at P midpoints
if (i==1){ # non relaxed (1x)
priordens <- switch(j,
0.3557*dnorm(x, -3.0675, 0.75214) + 0.6443*dnorm(x, 1.1290, 1.3920),
dcauchy(x, -0.04051, 0.19330),
dgamma(x, 5.1989, 16.6192),
dgamma(x, 3.5539, 5.5324),
dgamma(x, 6.8383, 25.7560),
dgamma(x,2,2))
} else if (i==2) { # 2x relaxed
priordens <- switch(j,
0.3557*dnorm(x, -3.0675, 1.0637) + 0.6443*dnorm(x, 1.1290, 1.9685),
dcauchy(x,-0.04051, 0.38660),
dgamma(x, 3.4016, 9.5057),
dgamma(x, 2.5210, 3.2948),
dgamma(x, 4.2574, 14.370),
dgamma(x,2,2))
} else if (i==3) { # 3x relaxed
priordens <- switch(j,
0.3557*dnorm(x, -3.0675, 1.3027) + 0.6443*dnorm(x, 1.1290, 2.4110),
dcauchy(x,-0.04051, 0.5799),
dgamma(x, 2.7693, 7.0029),
dgamma(x, 2.1457, 2.4819),
dgamma(x, 3.3643, 10.430),
dgamma(x,2,2))
} else if (i==4) { # 5x relaxed
priordens <- switch(j,
0.3557*dnorm(x, -3.0675, 1.6818) + 0.6443*dnorm(x, 1.1290, 3.1125),
dcauchy(x,-0.04051, 0.96650),
dgamma(x, 2.2298, 4.8674),
dgamma(x, 1.8166, 1.7689),
dgamma(x, 2.6144, 7.1221),
dgamma(x,2,2))
}
Pi <- P$density[which(P$density>0)]
Qi <- priordens[which(P$density>0)]
KL_temp[j] = sum(Pi * log(Pi/Qi))
# BCD
dx <- x[2]-x[1]
BC_temp[j] = -log(sum(sqrt(P$density*priordens)*dx))
# EMD
A = cbind(P$density,P$mids)
B = cbind(priordens,P$mids)
EM_temp[j] = emd(A,B)
# code below is for plotting data vs priors
#Q <- P
#Q$density <- priordens
#Q$counts <- Q$density*866091*(Q$breaks[2]-Q$breaks[1])
#c1 <- rgb(173,216,230,max = 255, alpha = 80, names = "lt.blue")
#c2 <- rgb(255,192,203, max = 255, alpha = 80, names = "lt.pink")
#plot(P,col=c1, main=paste("i=",i,", j=",j))
#plot(Q,col=c2,add=TRUE)
}
varname = switch(i, "1x", "2x", "3x", "5x")
n_eff_mat <- n_eff_mat %>% mutate(!!varname := n_eff_temp$mean)
Rhat_mat <- Rhat_mat %>% mutate(!!varname := Rhat_temp$mean)
KLdiv_mat <- KLdiv_mat %>% mutate(!!varname := KL_temp)
BCdist_mat <- BCdist_mat %>% mutate(!!varname := BC_temp)
EMdist_mat <- EMdist_mat %>% mutate(!!varname := EM_temp)
}
print("N_eff")
kable(n_eff_mat, digits=2)
print("Rhat")
kable(Rhat_mat, digits=3)
print("KLdiv")
kable(KLdiv_mat, digits=3)
cat("\n")
print("BCdist")
kable(BCdist_mat, digits=3)
print("EMdist")
kable(EMdist_mat, digits=3)
```
\newpage
Plots
```{r plots, echo=FALSE, comment=NA}
# goal here is to just get the distributions of parameters for each prior set
# store histogram density, and KDE
# plot histogram with side-by-side bar plots
# plot KDE's as line plots
mu_allprior <- data.frame(x1=numeric(866091),
x2=numeric(866091),
x3=numeric(866091),
x5=numeric(866091))
nu_allprior <- mu_allprior
sigmaP_allprior <- mu_allprior
sigmaPT_allprior <- mu_allprior
sigmaT_allprior <- mu_allprior
sigmaE_allprior <- mu_allprior
for (i in c(1:4)) {
stanFile = "FullResultsTCGA_relaxgamma3.Rdata"
stanFile = switch(i,
"FullResultsTCGA_gamma.Rdata",
"FullResultsTCGA_relaxgamma2.Rdata",
"FullResultsTCGA_relaxgamma3.Rdata",
"FullResultsTCGA_relaxgamma5.Rdata")
print(stanFile)
load(here(stanFile))
print("loaded")
mu_allprior[,i] <- mu_full$p50
nu_allprior[,i] <- nu_full$p50
sigmaP_allprior[,i] <- sigmaP_full$p50
sigmaPT_allprior[,i] <- sigmaPT_full$p50
sigmaT_allprior[,i] <- sigmaT_full$p50
sigmaE_allprior[,i] <- sigmaE_full$p50
}
cat("Posterior estimates for varying prior relaxation")
pM <- mu_allprior %>% gather("relax","val",1:4) %>% ggplot(aes(x=val,y=..density..,color=relax)) + geom_density() + xlim(-6,6) + ggtitle("Mu") + theme_classic() + theme(legend.position = "none")
pN <- nu_allprior %>% gather("relax","val",1:4) %>% ggplot(aes(x=val,y=..density..,color=relax)) + geom_density() + xlim(-5,5) + ggtitle("Nu") + theme_classic() + theme(legend.position = "none")
pP <- sigmaP_allprior %>% gather("relax","val",1:4) %>% ggplot(aes(x=val,y=..density..,color=relax)) + geom_density() + xlim(0,2) + ggtitle("sigmaP") + theme_classic() + theme(legend.position = "none")
pPT <- sigmaPT_allprior %>% gather("relax","val",1:4) %>% ggplot(aes(x=val,y=..density..,color=relax)) + geom_density() + xlim(0,2) + ggtitle("sigmaPT") + theme_classic() + theme(legend.position = "none")
pT <- sigmaT_allprior %>% gather("relax","val",1:4) %>% ggplot(aes(x=val,y=..density..,color=relax)) + geom_density() + xlim(0,2) + ggtitle("sigmaT") + theme_classic() + theme(legend.position = "none")
pE <- sigmaE_allprior %>% gather("relax","val",1:4) %>% ggplot(aes(x=val,y=..density..,color=relax)) + geom_density() + xlim(0,2) + ggtitle("sigmaE") + theme_classic() + theme(legend.position = "none")
pLP <- sigmaP_allprior %>% gather("relax","val",1:4) %>% mutate(val=log(val)) %>% ggplot(aes(x=val,y=..density..,color=relax)) + geom_density() + xlim(-4,1) + ggtitle("log(sigmaP)") + theme_classic() + theme(legend.position = "none")
pLPT <- sigmaPT_allprior %>% gather("relax","val",1:4) %>% mutate(val=log(val)) %>% ggplot(aes(x=val,y=..density..,color=relax)) + geom_density() + xlim(-4,1) + ggtitle("log(sigmaPT)") + theme_classic() + theme(legend.position = "none")
pLT <- sigmaT_allprior %>% gather("relax","val",1:4) %>% mutate(val=log(val)) %>% ggplot(aes(x=val,y=..density..,color=relax)) + geom_density() + xlim(-4,1) + ggtitle("log(sigmaT)") + theme_classic() + theme(legend.position = "none")
p_all<- ggarrange(pM, pN, pE, pP, pPT, pT, pLP, pLPT, pLT, nrow=3, ncol=3)
print(p_all)
# ggsave("prior_sens_kdes.svg",p1)
```
```{r posterior_sensitivity, echo=FALSE, comment=NA}
n_eff_mat <- data.frame(Params=c("mu","nu","sigmaP","sigmaPT","sigmaT","sigmaE","lp"))
Rhat_mat <- n_eff_mat
KLdiv_mat <- n_eff_mat %>% slice(1:6)
BCdist_mat <- KLdiv_mat
EMdist_mat <- KLdiv_mat
stanFile = "FullResultsTCGA_relaxgamma3.Rdata"
load(here(stanFile))
mu_ref <- mu_full
nu_ref <- nu_full
sigmaP_ref <- sigmaP_full
sigmaPT_ref <- sigmaPT_full
sigmaT_ref <- sigmaT_full
sigmaE_ref <- sigmaE_full
for (i in c(1:4)) {
stanFile = switch(i,
"FullResultsTCGA_gamma.Rdata",
"FullResultsTCGA_relaxgamma2.Rdata",
"FullResultsTCGA_relaxgamma3.Rdata",
"FullResultsTCGA_relaxgamma5.Rdata")
print(stanFile)
load(here(stanFile))
print("loaded")
n_eff_temp <-
data.frame(
mu = mu_full$n_eff,
nu = nu_full$n_eff,
sigmaP = sigmaP_full$n_eff,
sigmaPT = sigmaPT_full$n_eff,
sigmaT = sigmaT_full$n_eff,
sigmaE = sigmaE_full$n_eff,
lp = lp_full$n_eff
) %>% gather(param,value,mu:lp) %>% group_by(param) %>% summarize(
mean = mean(value),
.groups = "drop"
) %>% arrange(match(.$param,c("mu","nu","sigmaP","sigmaPT","sigmaT","sigmaE","lp")))
Rhat_temp <-
data.frame(
mu = mu_full$Rhat,
nu = nu_full$Rhat,
sigmaP = sigmaP_full$Rhat,
sigmaPT = sigmaPT_full$Rhat,
sigmaT = sigmaT_full$Rhat,
sigmaE = sigmaE_full$Rhat,
lp = lp_full$Rhat
) %>% gather(param,value,mu:lp) %>% group_by(param) %>% summarize(
mean = mean(value),
.groups = "drop"
) %>% arrange(match(.$param,c("mu","nu","sigmaP","sigmaPT","sigmaT","sigmaE","lp")))
# KL divergence
# formula: KL(P||Q) = sum(P(i) * log( P(i)/Q(i) )), where P(i),Q(i) = density
KL_temp <- numeric(6)
#Bhattacharya distance
# formula: BC = sum( sqrt(P(i)*Q(i)) )
BC_temp <- numeric(6)
# Earth-movers (Wasserstein) distance
EM_temp <- numeric(6)
for (j in c(1:6)) {
# choose parameter (first get reference dist (3x), then prior relaxed dist)
breaks <- switch(j,
seq(-5,5,0.1),
seq(-6,6,0.12), #5.5,.11
seq(0,3,0.03), #2.6
seq(0,3,0.03),
seq(0,3,0.03), #1.2
seq(0,3,0.03)) #2.5
refdata <- switch(j,
mu_ref$p50,
nu_ref$p50,
sigmaP_ref$p50,
sigmaPT_ref$p50,
sigmaT_ref$p50,
sigmaE_ref$p50)
Q <- hist(refdata, plot=FALSE, breaks=breaks) # run hist to get density and midpoints
x <- Q$mids
data <- switch(j,
mu_full$p50,
nu_full$p50,
sigmaP_full$p50,
sigmaPT_full$p50,
sigmaT_full$p50,
sigmaE_full$p50)
P <- hist(data, plot=FALSE, breaks=breaks) # run hist to get density and midpoints
Pi <- P$density[which(P$density>0 & Q$density>0)]
Qi <- Q$density[which(P$density>0 & Q$density>0)]
KL_temp[j] = sum(Pi * log(Pi/Qi))
# BCD
dx <- x[2]-x[1]
BC_temp[j] = -log(sum(sqrt(P$density*Q$density)*dx))
# EMD
A = cbind(P$density,P$mids)
B = cbind(Q$density,Q$mids)
EM_temp[j] = emd(A,B)
# code below is for plotting data vs priors
#Q <- P
#Q$density <- priordens
#Q$counts <- Q$density*866091*(Q$breaks[2]-Q$breaks[1])
#c1 <- rgb(173,216,230,max = 255, alpha = 80, names = "lt.blue")
#c2 <- rgb(255,192,203, max = 255, alpha = 80, names = "lt.pink")
#plot(P,col=c1, main=paste("i=",i,", j=",j))
#plot(Q,col=c2,add=TRUE)
}
varname = switch(i, "1x", "2x", "3x", "5x")
n_eff_mat <- n_eff_mat %>% mutate(!!varname := n_eff_temp$mean)
Rhat_mat <- Rhat_mat %>% mutate(!!varname := Rhat_temp$mean)
KLdiv_mat <- KLdiv_mat %>% mutate(!!varname := KL_temp)
BCdist_mat <- BCdist_mat %>% mutate(!!varname := BC_temp)
EMdist_mat <- EMdist_mat %>% mutate(!!varname := EM_temp)
}
print("N_eff")
kable(n_eff_mat, digits=2)
print("Rhat")
kable(Rhat_mat, digits=3)
print("KLdiv");kable(KLdiv_mat, digits=3);print("BCdist");kable(BCdist_mat, digits=3);print("EMdist"); kable(EMdist_mat, digits=3)
```