I was comparing rstan sbc.R and stan user manual(+paper) and had some questions:

**1. Rank consistency**

vignettes has: `int ranks_[1] = {pi > pi_};`

but user manual and original paper, Validating Bayesian Inference Algorithms with Simulation-Based Calibration, uses

Would it be better to use `int ranks_[1] = {pi < pi_};`

as the paper shows diagnostic techniques, which depend on the inequality direction.

**2. M, N**

stan manual explains:

- M: the number of posterior draws per simulated data set
- N: total number of simulated data sets and fits

How many times of stan fit is supposed to happen in sbc? MN or N?

If the answer is N, does M in code, correspond to N in user guide, as M times of sampling is happening?

**3. n_eff consideration**

Considering n_eff, suggested by the above paper, would the following code improvement be o.k? `if(n_eff/M >= 1-n_eff_reltol && n_eff/M <= 1+n_eff_reltol)`

is what @avehtari suggested here.

- question: can M substituted as
`iter_sampling`

? - concern:
`n_eff/iter_sampling`

might have different value, once thinned. However, in current frame, thinning is not happening because of anesthetic chain as @bgoodri suggested here.

original

```
out <- sampling(stanmodel, data, pars = c("ranks_", if (has_log_lik) "log_lik"), include = TRUE,
chains = 1L, cores = 1L, seed = S, save_warmup = FALSE, thin = 1L, ...)
```

with n_eff (cmdstanr code)

```
iter_sampling = 1000
while(TRUE){
out <- stanmodel$sample(data, chains = 1, iter_sampling = iter_sampling, seed = floor(S), parallel_chains = 1, save_warmup = FALSE, thin = 1)
n_eff <- out$summary("lp__") %>% pull("ess_bulk")
if(n_eff/iter_sampling >= 1-n_eff_reltol && n_eff/iter_sampling <= 1+n_eff_reltol) break
iter_sampling = 2 * iter_sampling
}
```

.