Skip to contents

Generate multiple simulated datasets for simulation-based calibration (SBC). Each dataset is generated with parameters drawn from the prior.

Usage

sim_ratiod_sbc(
  n_sims = 100,
  n = 100,
  family = ratiod_negbin_negbin(),
  priors = NULL,
  n_groups = 10,
  seed = NULL
)

Arguments

n_sims

Number of simulations to run.

n

Number of observations per simulation.

family

A tulpaRatio family object.

priors

Prior specification for parameter generation.

n_groups

Number of random effect groups.

seed

Random seed.

Value

A list of ratiod_simdata objects.

See also

sim_ratiod() for single dataset simulation

Examples

# Generate datasets for SBC (returns immediately)
sims <- sim_ratiod_sbc(
  n_sims = 3,
  n = 30,
  family = ratiod_negbin_negbin(),
  seed = 42
)
print(sims)
#> tulpaRatio SBC simulations
#> =====================
#> 
#> Simulations: 3 
#> Family: negbin_negbin 
#> Observations per sim: 30 
#> Groups per sim: 10 
#> 
#> Use lapply() to fit models to each simulation

# \donttest{
# Fit model to each simulation (slow, not run on CRAN)
# ranks <- lapply(sims, function(sim) {
#   fit <- tratio(y_num | y_denom ~ x1 + (1 | group),
#                data = sim$data,
#                family = ratiod_negbin_negbin(),
#                control = list(iter = 200, warmup = 100, chains = 1))
#   sum(as.matrix(fit$draws)[, "beta_num[1]"] < sim$true_params$beta_num[1])
# })
# }