-
Notifications
You must be signed in to change notification settings - Fork 0
Part III Computational Architecture
← Part II — Mathematical Foundations · gdpar Wiki Home · Part IV — Exhaustive Function Reference (1/7) →
This part is the map of how a model flows from a user call to posterior summaries. Every function named here is documented in full in Part IV; the Stan templates in Part V.
A call to gdpar(formula, family, amm, data, group = NULL, path = "bayesian", ...) proceeds through:
-
Specification resolution. The response/formula is parsed; the AMM design is built. The user may supply the AMM three ways: a single
amm_spec()(scalar/coord-wise), a named list of specs, or agdpar_formula_set()/gdpar_bf()(abrms-like multi-slot formula DSL parsed by.gdpar_parse_amm_formula).dims_spec(dimwise/override/resolve_dims_spec) declares per-coordinate ($p>1$ ) component formulas. The family is resolved (gdpar_family/gdpar_family_multi/heterogeneous) into the per-slotgdpar_param_speclist, and the resolved$(K,p)$ pair determines the path regime. -
Design construction.
build_amm_design(and.build_amm_design_multi,.build_amm_design_K) assemble the centered design matrices$Z_a,Z_b$ (enforcing (C2)/(C3) by column-centering) and the modulating design$X$ with theWbasis materialized. -
Identifiability pre-flight.
gdpar_check_identifiability()runs the Gram-matrix check (Prop. 1C), the C4-bis cross-component check for$p>1$ (check_C4_bis_per_k), the per-slot checks for$K>1$ , and — whengroupis set — the C7 anti-aliasing check (.check_group_aliasing_c7). Failure aborts withgdpar_identifiability_errorunlessskip_id_check = TRUE. -
Parametrization pre-flight. The CP/NCP/(linear) decision is taken data-drivenly (§II.6) via
preflight_parametrization*→resolve_parametrization*. -
Code generation.
R/stan_codegen.Rassembles the Stan program string for the resolved$(K,p,\text{family},W,\text{parametrization},\text{group})$ from the canonical Stan pieces, then compiles viacmdstanr. -
Sampling. HMC runs (optionally through the geometry engine, §II.9). For
$K=1,p=1$ the path isgdpar()proper;$p>1$ dispatches to.gdpar_multi,$K>1$ to.gdpar_K/.gdpar_K_build. -
Diagnostics + packaging.
compute_diagnosticscollects$\widehat R$ , ESS, divergences (with the all-NA$\to-\infty$ +warning guard of D77);diagnostics()exposes them; the result is agdpar_fitobject.
gdpar_eb() replaces steps 5–7 with the three-step EB recipe (§II.3): Laplace marginal-likelihood maximization for
R/stan_codegen.R is a string-assembly compiler: it does not ship one monolithic Stan file per case but composes a program from canonical pieces under inst/stan/_canonical_pieces/ (helpers, the stan_id), the chosen W evaluation (W_type_id: polynomial / Stan-side Cox–de Boor B-spline / differenced anchoring), the parametrization toggle (CP/NCP/linear
-
R/gdpar.R— the orchestrator:gdpar()(entry),.gdpar_multi($p>1$ ),.gdpar_K/.gdpar_K_build($K>1$ ), anchor resolution,compute_diagnostics,dedup_message_blocks(clean console output). -
R/eb.R— the Empirical-Bayes engine (largest file, 3196 lines): the four-regime marginal/conditional fit drivers, the Laplace anti-fragility machinery, the EBgdpar_eb_fitpackaging. -
R/families.R— the family/codegen-facing layer: param-spec construction, link factory, per-slot scope promotion, heterogeneous-family resolution, inverse-link-id computation per slot. -
R/geometry_*.R— the geometry engine, orchestrator, suite, bridge, Laplace, diagnostic (§II.9). -
R/dependence_robust.R— the dependence-robust inference engine (§II.10).
The user-facing objects and their methods (full list in NAMESPACE; detail in Part IV):
-
gdpar_fit:print,summary,predict(with the$p>1$ array path and$K>1$ per-slot inverse-link path, plus grouped/newdata variants),coef(→gdpar_coef),residuals(Dunn–Smyth / deviance / quantile, with DHARMa integration),pp_check,gdpar_loo,gdpar_posterior_predict,gdpar_dharma_object. -
gdpar_eb_fit:print,summary,coef,predict. -
gdpar_coef:print,summary,format,as.data.frame. - causal/comparison:
gdpar_causal_bridge,gdpar_meta_learner_comparison,gdpar_eb_fb_comparisoneach withprint/summary/predictas applicable. - specs/reports:
amm_spec,amm_builder,W_basis,dims_spec,gdpar_family(_multi),gdpar_formula_set,gdpar_param_spec, and the diagnostic reports (gdpar_identifiability_report,gdpar_preflight_report,gdpar_contraction_report,gdpar_bvm_report,gdpar_dependence_diagnostic,gdpar_spatial_dependence_*,gdpar_ksd_joint,gdpar_geometry_diagnostic, geometry certificates) all carryprint(and where usefulsummary/format/as.data.frame).
-
R/amm_serialize.R—amm_save_spec/amm_load_spec(a text round-trip of an AMM spec: formula/char/numeric/W-record (de)serializers);gdpar_snapshot_fitsnapshots a fit. -
R/golden_compare.R,R/golden_helpers.R— the golden-regression machinery (manifest, roster, structural/discrete/continuous/sanity comparators, code-hash + toolchain-version stamping) underpinning the test tiers of §VI.3. -
R/ksd_joint.R— a kernelized Stein discrepancy joint diagnostic;R/bvm_check.R— the Bernstein–von Mises calibration check (§II.2.1);R/contraction_diagnostic.R— empirical contraction (§II.6.3);R/gdpar_loo.R— PSIS-LOO aggregation;R/preflight*.R— the parametrization pre-flight (§II.6);R/utils-*.R— condition system (gdpar_abort/warn/inform,require_suggested) and input validators (assert_*).
← Part II — Mathematical Foundations · gdpar Wiki Home · Part IV — Exhaustive Function Reference (1/7) →
- Part I — Conceptual Framework
- Part II — Mathematical Foundations
- Part III — Computational Architecture
- Part IV — Exhaustive Function Reference (1/7)
- Part IV — Exhaustive Function Reference (2/7)
- Part IV — Exhaustive Function Reference (3/7)
- Part IV — Exhaustive Function Reference (4/7)
- Part IV — Exhaustive Function Reference (5/7)
- Part IV — Exhaustive Function Reference (6/7)
- Part IV — Exhaustive Function Reference (7/7)
- Part V — Stan Templates (1/3)
- Part V — Stan Templates (2/3)
- Part V — Stan Templates (3/3)
- Part VI — Data, Benchmarks, Tests & References