I wish to collaborate on sbc package. I have cmdstanr SBC code in here.

Usecases in for the codes are here with the following summary.

```
sbc_res_bern_lik <- sbc_new(mod, modelName, data = data, N = N, L = L, save_progress = delivDir)
ppc.sbc(sbc_res_bern_lik,modelName, data)
uniformity.sbc(sbc_res_bern_lik, modelName)
plot.sbc(sbc_res_bern_lik, modelName, data)
plot.sbc_ecdf(sbc_res_bern_lik, modelName)
```

Resulting plots could be found in this paper. Two things to note.

- Code for plotting ECDF is included
`plot.sbc_ecdf`

, but code for ECDF difference ( following plot) is needed.

- I felt the need for diverse measures for SBC other than chisq so I made
`uniformity.sbc`

to return Wasserstein and KM distance on top of chi-square p values.

```
MW1 <- function(bin_count){
bins <- length(bin_count)
unif <- rep(1/bins, bins)
M <- sum(bin_count)
tempf <- Vectorize(function(i) abs(bin_count[i]/M - unif[i]))
val <- integrate(tempf,1,bins, rel.tol=.Machine$double.eps^.05)$value
return(val)
}
MKM <- function(bin_count){
bins <- length(bin_count)
diff <- abs(mean(bin_count) - bin_count)
val <- diff[which.max(diff)] / mean(bin_count)
return(val)
}
MChisq <- function(bin_count){
return(chisq.test(bin_count)$p.value)
}
```