| validate_inla_vs_brms | R Documentation |
Generates a small number of synthetic datasets using the same internal
data-generator as brms_inla_power(), fits each dataset with both INLA
(as the package does) and brms::brm() (via Stan), and compares the
posterior mean, posterior SD, and 95 % credible-interval bounds for the
primary effect parameter.
This is a qualitative spot-check, not a formal equivalence test. Differences are expected due to the Laplace approximation used by INLA versus full MCMC in Stan, and will vary across models and priors.
validate_inla_vs_brms(
formula,
family = gaussian(),
priors = NULL,
data_generator = NULL,
effect_name,
effect_value = 0.5,
sample_size = 100L,
n_check = 5L,
brms_iter = 2000L,
brms_chains = 4L,
tolerance = NULL,
seed = 42L,
error_sd = 1,
group_sd = 0.5,
obs_per_group = 10,
predictor_means = NULL,
predictor_sds = NULL,
family_args = list(),
inla_num_threads = NULL
)
formula |
Model formula (same as |
family |
GLM family object (default |
priors |
A |
data_generator |
Optional function |
effect_name |
Character vector of fixed-effect names (same as
|
effect_value |
Numeric value (or named vector) of the true effect
size used when generating data for the comparison. Default |
sample_size |
Integer sample size for each comparison dataset.
Default |
n_check |
Number of independent datasets to compare. Default |
brms_iter |
Total MCMC iterations per chain passed to
|
brms_chains |
Number of MCMC chains. Default |
tolerance |
Numeric threshold: the flag is set to |
seed |
Integer random seed. Default |
error_sd, group_sd, obs_per_group, predictor_means, predictor_sds, family_args |
Passed to the automatic data generator when |
inla_num_threads |
INLA threading string (e.g. |
A list with components:
comparisonsData frame with one row per dataset and columns
sim, inla_ok, brms_ok, inla_mean, brms_mean, diff_mean,
inla_sd, brms_sd, inla_ci_lower, inla_ci_upper,
brms_ci_lower, brms_ci_upper.
flagTRUE if any |diff_mean| exceeds tolerance.
max_abs_diffMaximum observed |diff_mean|.
toleranceThe tolerance value actually used.
settingsList of key settings for reproducibility.
This function runs n_check full brms/Stan fits. Even with
brms_chains = 2 and brms_iter = 1000, this can take several minutes
for non-trivial models. Use n_check = 3 and brms_chains = 2 for
quick sanity checks.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.