Validate a multisite simulation design
Source:R/class-multisitedgp_design.R
validate_multisitedgp_design.RdReplay the multisitedgp_design() constructor contract on an
existing design object. Useful as a sanity check after a non-trivial
update_multisitedgp_design, or before passing a design
that has been deserialized from disk into
sim_multisite or sim_meta.
Details
Validation enforces every constraint the constructor enforces — for
example, the Decision-C contract (engine A1 with non-trivial
precision dependence is rejected), the eight-shape true_dist
allowlist, the theta_G per-shape required keys, and the unit-
variance convention. Errors are emitted with full
message + info + fix hints from the typed-error catalog (see
R/00-errors-validation.R).
On success, returns the original design invisibly so the function
chains naturally with |>.
References
Lee, J., Che, J., Rabe-Hesketh, S., Feller, A., & Miratrix, L. (2025). Improving the estimation of site-specific effects and their distribution in multisite trials. Journal of Educational and Behavioral Statistics, 50(5), 731–764. doi:10.3102/10769986241254286 .
See also
multisitedgp_design for the constructor;
update_multisitedgp_design for functional updates
(each automatically re-validates);
is_multisitedgp_design for the predicate test.
Other family-design:
as_tibble.multisitedgp_data(),
design_grid(),
is_multisitedgp_data(),
is_multisitedgp_design(),
multisitedgp_design(),
print.multisitedgp_data(),
summary.multisitedgp_data(),
update_multisitedgp_design()
Examples
design <- multisitedgp_design(J = 20L, sigma_tau = 0.20)
validate_multisitedgp_design(design) # silent; returns design invisibly
# Chain-friendly with the pipe.
design |> validate_multisitedgp_design() |> sim_multisite(seed = 1L)
#> # A multisitedgp_data: 20 sites, paradigm = "site_size"
#> # Realized vs intended:
#> # I: realized=0.312 (no target)
#> # R: realized=4.625 (no target)
#> # sigma_tau: target=0.200, realized=0.183, WARN
#> # rho_S: target=0.000, realized=-0.213, PASS
#> # rho_S_marg: realized=-0.213 (no target)
#> # Feasibility: WARN (n_eff=6.357)
#> # A tibble: 20 × 7
#> site_index z_j tau_j tau_j_hat se_j se2_j n_j
#> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 1 -0.626 -0.125 -0.189 0.385 0.148 27
#> 2 2 0.184 0.0367 -0.0455 0.324 0.105 38
#> 3 3 -0.836 -0.167 0.0874 0.365 0.133 30
#> 4 4 1.60 0.319 0.489 0.305 0.0930 43
#> 5 5 0.330 0.0659 -0.142 0.302 0.0909 44
#> 6 6 -0.820 -0.164 -0.422 0.365 0.133 30
#> # ℹ 14 more rows
#> # Use summary(df) for the full diagnostic report.