General Dynamic Parameter Models via Reference Anchoring
Overview
Implements a unified predictive framework in which individual parameters are decomposed as theta_i equal to theta_ref plus Delta(x_i, theta_ref), with theta_ref a population reference and Delta an explicit deviation function. The decomposition follows the Additive-Multiplicative-Modulated canonical form and is estimated through three complementary paths: hierarchical Bayesian inference via 'Stan', varying-coefficient models via penalized splines, and amortized inference via hypernetworks in 'torch'. The package provides identifiability diagnostics, validity tests for the population reference, and benchmarks against canonical zero-inflated count datasets and avian abundance data from the eBird Status and Trends project. The framework and its estimation paths are described in Gomez Julian (2026) doi:10.5281/zenodo.21046269.
First public release of gdpar. It implements the General Dynamic Parameter
framework, in which each unit's parameter is decomposed as
theta_i = theta_ref + Delta(x_i, theta_ref) around a population reference, with
Delta following the canonical Additive--Multiplicative--Modulated (AMM) form
a(x) + b(x) * theta + W(theta) x. Estimation is via Path 1 (hierarchical
Bayesian inference through 'Stan' / 'cmdstanr'); Paths 2 (varying-coefficient)
and 3 (hypernetwork) are specified at reference grade and queued for future
versions.
Packaging note (pre-CRAN correction): the fitting entry points now run all
input validation before the optional cmdstanr dependency is required, which
is checked only immediately before it is used. The package and its full test
suite therefore work on machines where the Suggests package cmdstanr is not
Show all changes in 0.1.0Hide the rest of the changes in 0.1.0
installed. This is a packaging-only change with no effect on results when
cmdstanr is available.
This release consolidates the development cycles documented in detail below
(Sessions 8.3--8.6, the Block 8.4 audit, and the Block 9 re-validation):
- **Distributional regression,
K >= 1slots.** Gaussian, Student-t, Gamma, Beta, Tweedie, Poisson, negative-binomial, zero-inflated and hurdle families, plus heterogeneous per-slot families, with B-splineWbases and arbitrary covariate dimensionp. - **Empirical-Bayes and full-Bayes estimation**, with EB-vs-FB comparators (marginal total variation and joint KSD) and a unified Path C bit-exact comparator for the
K > 1andp > 1regime. - **Causal positioning.** A T-learner CATE/ITE bridge on the AMM side and an external meta-learner comparator (grf, EconML via reticulate).
- **Geometric-robustness sampling engine (Block RG).** An opt-in, default-bit-identical Riemannian / sub-Riemannian / Finsler metric stack with a certifying orchestrator and a learned expected-Fisher metric, for stiff and near-deterministic posteriors.
- **Dependence-robust inference (Block 9, Axis 2).** Diagnostics (lag-1 / Durbin-Watson; Moran's I) and block-bootstrap robust standard errors for temporally and spatially dependent data, with a data-driven (Politis-White) block length, on both the Empirical-Bayes and full-Bayes paths.
gdpardoes not model the dependence; only its inference is made robust to it. - **Identifiability diagnostics and validity tests** for the population reference, residual diagnostics (Dunn-Smyth quantile residuals; G1/G2/G3), and a golden-regression test suite.
**Validation.** Block 9 closed adversarial internal re-validation, a synthetic
recovery benchmark against mgcv / brms / INLA / rstanarm with known ground truth
(3200 cells), and an organic eBird benchmark (80 cells). gdpar leads on the
distributional structure it models (heavy-tail quantiles, zero-inflated count
means, heteroscedastic scale), is statistically indistinguishable from the
strongest competitor (mgcv) on generic predictive accuracy, is robust where it
makes no modelling claim (e.g. autocorrelation), and is the most computationally
expensive method in the roster. Reports under inst/benchmarks/results/.
Detailed per-session development notes follow.
Axis 2 — full-Bayes dependence-robust inference (Session B9.39, 2026-06-26; D102)
- **The dependence diagnostics and the block-bootstrap robust standard errors now accept a scalar full-Bayes fit (
gdpar_fit), not only a scalar Empirical-Bayes fit (gdpar_eb_fit).**gdpar_dependence_diagnostic(),gdpar_dependence_robust(),gdpar_spatial_dependence_diagnostic()andgdpar_spatial_dependence_robust()are unchanged in name and signature; they simply work on either path now, closing the EB/FB asymmetry left open at the start of Axis 2. The K > 1 / p > 1 paths remain deferred on both EB and FB. - **One shared engine, three class-dispatched touchpoints.** The refit loop, the Politis-White / spatial block-length selectors, the temporal and spatial diagnostics and the honesty contract are path-agnostic; only the per-fit extraction of the point estimate, the model SE and the Dunn-Smyth residuals is dispatched by object class. The Empirical-Bayes code paths are byte-identical, so the existing bit-exact EB regression gate is preserved.
- **Full-Bayes point estimate / model SE = posterior mean / posterior SD** of each AMM coefficient (
theta_ref,a_coef,b_coef,W_raw, the last on its raw scale, for parity with the Empirical-Bayes extractor; thetheta_refhyperparameters are excluded).robust_seis the block-bootstrap SD of the per-refit posterior means andse_ratio = robust_se / model_seremains a like-for-like (SD-vs-SD) ratio. Each refit re-runs the full HMC and is markedly more expensive than an Empirical-Bayes refit (the opt-in cost message says so). - **Per-refit convergence accounting** (new
refit_diagnosticsfield on the robust result:max_rhat,min_ess_bulk,n_divergent_refits,n_high_rhat_refits). Refits are never excluded or down-weighted (that would be a non-random, biasing screen); a single informational note is emitted only when a refit's R-hat clearly exceeds 1.05. This applies to both paths. - **Documented full-Bayes caveats:** the finite-iteration Monte-Carlo error of each refit's posterior mean conservatively (slightly) inflates
robust_se; under an informative priorse_ratio < 1is benign prior regularization, not an overstated model SE; and the Empirical-Bayestheta_refpoint estimate (the Laplace mode) and the full-Bayes one (the posterior mean) are different estimands that coincide only asymptotically. A bagged / widened posterior (BayesBag) is recorded as a deferred lateral, not adopted. The full-Bayes design was cross-lineage-reviewed; the review's concrete proposals (a hard minimum-ESS abort, an estimator-replacing bag) were audited and **not** adopted in favour of the more robust informational accounting, while its documentation findings (these_ratio < 1and mode-vs-mean subtleties) were adopted.
Axis 2 — data-driven block length (Session B9.38, 2026-06-26; D101)
- **
gdpar_dependence_robust()andgdpar_spatial_dependence_robust()gain an opt-in data-driven block size,block_length = "auto"/block_size = "auto".** The default behaviour is unchanged (the rate-onlyn^(1/3)/n^(1/4));"auto"replaces the rate's *constant* with a value selected from the fitted residuals, with no extra Stan refit, and the rate as the fallback. Both functions also gainresidual_type/randomize_seed, used only to feed the"auto"selector. The chosen value and method are reported (block_length/block_sizeand the newblock_length_method/block_size_method). - **Temporal: the canonical Politis & White (2004) selector** (with the Patton, Politis & White 2009 correction), hand-rolled in base R (no **np** dependency): the adaptive flat-top spectral estimate of the residual autocovariances gives
b_opt = (2 ghat^2 / D)^(1/3) n^(1/3)with the overlapping moving/circular-block constantD = (4/3) spec^2; longer dependence yields a longer block, white noise yields unit blocks, and a degenerate series falls back to the rate. Ap << ncaveat is documented. - **Spatial: a data-driven calibration over the cell grid** (Politis & White has no established spatial plug-in). For each candidate
g, cheap (no-refit) spatial block resamples give the bootstrap variance of the design-weighted residual functionals (the coefficient's influence directions);gminimises an empirical mean-squared error — squared bias anchored at the *largest* blocks (least biased) plus a1/n_tilessampling-variance term (Lahiri 2003). A decorrelating cross-lineage review supplied the MSE skeleton; two of its choices were corrected after an audit and empirical validation (the bias anchor, and the variance term), because the proposed forms would have made the selector either anticonservative or non-adaptive. A single isotropicgis used (anisotropy is a documented, deferred limitation).
Axis 2 — spatial dependence-robust inference (Session B9.37, 2026-06-26; D100)
- **
gdpar_spatial_dependence_diagnostic()(new, exported) — Moran's I for the residuals of a scalar Empirical-Bayes fit.** The spatial sibling ofgdpar_dependence_diagnostic(): it builds a row-standardized spatial weight matrix (defaultk-nearest-neighbour, the data-drivenk = max(4, min(round( log n), n - 1)); or a distance band; or a user-suppliedWcarrying domain knowledge), hand-rolls Moran's I in base R (no **spdep** / **sf** dependency), and reports a significance test — a two-sided permutation test by default (robust to non-normal Dunn-Smyth residuals and asymmetric weights), or the cheaper analytic Cliff-Ord normal approximation (which warns under an asymmetricW). Guards cover isolated locations (zero-weight rows warn and returnNA), duplicate coordinates (permitted), smalln(hard/soft warnings), and the lon/lat (project-first) and model-misspecification caveats are documented. gdpar does **not** model the spatial dependence; this only makes the violation visible. - **
gdpar_spatial_dependence_robust()(new, exported) — spatial block-bootstrap-by-refit standard errors.** Refits the model onBspatial block-bootstrap resamples and reports bootstrap SEs and percentile intervals alongside the model-based ones, in the working-independence + robust-variance spirit of Liang & Zeger (1986) (point estimates unchanged). Default scheme is non-overlapping **tiled** blocks with a **randomized grid origin** per replicate (Politis-Romano-Lahiri), plus an opt-in overlapping **moving** scheme. The default block side isg = max(2, round(n^(1/4)))cells per axis, thed = 2case of the variance-MSE-optimal rateM ~ n^(d/(d+2))points per block, which reduces **exactly** to the temporaln^(1/3)block length atd = 1(derivation and the registered cross-lineage dissent towardn^(1/6)are in?gdpar_spatial_dependence_robust). Collinear coordinates abort; a single-cell collapse warns. - **Internal refactor (regression-gated).** The temporal
gdpar_dependence_ robust()and the new spatial function share one extracted engine (.gdpar_dependence_robust_engine) and one residual extractor (.gdpar_dependence_residuals); the temporal path is verified **bit-identical** pre/post refactor by a fixed-seed regression gate (a frozen pre-refactor copy vs. the live engine-backed function, same robust-SE table) plus a Stan-free golden that locks the engine's RNG-consumption order. No change to the temporal API or output.
Bloque RG — RG.7 (step 4): the automated Laplace fallback (Session B9.35, 2026-06-25; D99)
- **
gdpar_geom_laplace()(new, exported) — the Laplace approximation as a first-class capability.** Given agdpar_geom_target, it climbs to the posterior mode (L-BFGS-B warm start + a modified-Newton polish when an exact Hessian is exposed, reading the **same** target and gradient the sampler uses), forms the precisionM = -Hessian (the observed information, exact cmdstan Hessian or finite differences), reports its covarianceM^{-1}, optional iid drawsmode + M^{-1/2} z, and — crucially — a **fidelity diagnostic** of the Gaussian against the true posterior over the same draws: the importance-sampling ESS, the PSIS Pareto-k(when **loo** is installed), and the mean/max log-density drop against its Gaussian expectationd/2. These are distilled into a single scalar label"good"/"poor"/"very_poor"so the approximation is never mistaken for exact MCMC. The **un-floored** condition number is reported and a saddle (non-positive-definite curvature) is flagged loudly. This promotes the validated extractor core of RG.7 (inst/benchmarks/scripts/rg7_laplace_elpd.R) intoR/. - **
gdpar_geom_orchestrate()andgdpar_geom_fit()gainlaplace_fallback = FALSE(opt-in) andlaplace_draws = 0L.** When opted in and a run ends in a **certified limit** (the genuinely non-Gaussian canyon the geometry ladder cannot sample — RG.7's eBird Tweedie count), the orchestrator attaches the Laplace approximation ($laplace) and relabels the status"certified_limit_laplace": the sampling limit still stands **and** a labelled, fidelity-diagnosed Laplace posterior is provided — exactly the mgcv/REML and INLA/Laplace competitor-parity regime. On the out-of-scope path the fallback is attached only when the curvature at the mode is genuinely positive-definite (status"out_of_scope_laplace"); otherwise the certificate is left untouched (no overreach). **The defaultFALSEleaves the output bit-identical** (no$laplace, the original status set), so the goldens stay bit-identical.
Bloque RG — RG.6 (part ii): integration of the geometry-adaptive orchestrator + the pedagogical vignette (Session B9.31, 2026-06-03)
- **
gdpar_geom_bridge()(new, exported) — the durable, path-agnostic core.** Turns an already-fittedgdparobject into the inputs the geometry-adaptive controllergdpar_geom_orchestrate()consumes, **without touchinggdpar()**. It reads the fit's compiledcmdstanmodel and Stan data, exposes the standalonelog_prob/grad_log_prob/hessianmethods, derives the unconstrained dimension and a posterior-mean warm-start, and returns a(target, geom_target, fisher, reference)tuple. Because the diagnostic needs a *re-samplable* model and aCmdStanMCMCobject cannot be re-sampled, the bridge recompiles one from the fit's own Stan source ($code(), with the standalone methods; cmdstanr's content-hash cache makes it a cache hit), while the engine target reuses the fitted object directly. The Hessian compilation is **best-effort**: if higher-order autodiff will not compile (models with custom densities, the Tweedielpdfbeing the case RG.7 targets), it falls back to gradient-only methods, which still serve the Euclidean, dense and sub-Riemannian (expected-Fisher) levels. This is the tool RG.7 points at the real Tweedie count of benchmark 9.2.O. - **
gdpar_geom_fit()(new, exported) — the one-call ergonomic entry.** A *sister* ofgdpar()(not an internal branch) for the K-individual path: it builds and compiles the model through the **shared seam.gdpar_K_build()**, then runs the orchestrator instead of the default NUTS fit, returning a richgdpar_geom_fitobject. Print methods for both new classes are provided. - **
.gdpar_K_build()(internal) extracted from.gdpar_K().** A behaviour-preserving refactor of the model-building phase (everything up to but not includingcs_model$sample):.gdpar_K()andgdpar_geom_fit()now share a **single source** (no duplication, no throwaway computation). The default branch (compile_model_methods = FALSE) issues the byte-identicalcmdstanr::cmdstan_model(stan_path)call used before, so the K-path goldens stay bit-identical (verified: the K=2 Gaussian golden re-fits withmax|delta| = 0);gdpar_geom_fit()passescompile_model_methods = TRUEto expose the standalone methods. - **Pedagogical vignette
vop08_geometric_robustness.Rmd(new).** An abundant, two-level narrative of the whole Block RG (RG.0 → RG.6): the conceptual bridge to the user's geometry manuscript (with an organic critical reading of its §12 hierarchy and its §14 "future statistical line", and of the ORPHEUS §16.3 demonstrated-vs-conjectured honesty), the diagnostic with size-invariant signals, the five sampler levels, the orchestrator with its armour and its certified limit, Option A, and the integration. The **evaluated** chunks are cheap (suite metadata, the budget/criteria/thresholds, and the geometry engine on pure-R closure targets — no Stan); the heavycmdstan-backed runs are shown witheval = FALSEand reproduced end to end by the gated scriptinst/scripts/geometry_pilots_deep.R(GDPAR_RUN_GEOMETRY_PILOTS=1). Opt-in throughout: the defaultgdpar()fit path is untouched, so the goldens remain bit-identical (canonized as **D97**, session B9.31).
Bloque RG — RG.6 (part 1): Option A folded in — sigma_a_k
The NEWS section is longer than shown here.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK5 OK2026-07-16
Documentation
- Help pages
- 132 (3 internal)includes a package overview page
- Examples that run
- 65%40 run in a plain check · 22 only when donttest examples are enabled (R CMD check --as-cran)
- Exported functions with examples
- 94%
- Documented parameters
- 93%
- Return-value docs
- 100%
- Help pages citing references
- 16%
- AMM Sub-phases 8.3.1 to 8.3.10 -- Theoretical Canonization
- Arbitrary p: Operational Cookbook for Multivariate Fits
- Asymptotic Theory for Path 1 (Hierarchical Bayesian)
- Asymptotic Theory for Path 2 (Varying-Coefficient via Penalized Splines)
- Asymptotic Theory for Path 3 (Hypernetwork)
- Cognitive Motivation: From Driver Prediction to Reference-Anchored Individuation
- Comparing the AMM-side T-learner against External Meta-learners
- Dependence-Robust Inference in gdpar (Axis 2)
- Distributional Regression K > 1 and Residual Diagnostics with DHARMa
- Empirical Bayes vs. Fully Bayes -- Multivariate Extension
Show 15 moreHide 15 vignettes
- Empirical Bayes vs. Fully Bayes Treatment of the Population Reference
- Geometric Robustness of Sampling (Block RG)
- Gnoseological Validity Conditions for the Population Reference
- Intermediate AMM Specifications: B-spline W Bases and Heterogeneous Families per Slot
- Parametrization Toggle: Operational Guide
- Per-group hierarchical anchors: Operational Guide
- Positioning AMM relative to the CATE / ITE Literature
- Predictive Models with Dynamic Individual Parameters: A Unifying Conceptual Framework
- Quickstart: A First Fit in Five Minutes
- Regression Testing of MCMC Outputs (Experimental)
- Standard Predictive Models as Formal Special Cases of the AMM
- The AMM Canonical Form and Identifiability Conditions
- The Empirical-Bayes Workflow in gdpar
- The T-learner AMM-side Causal Bridge
- Theoretical Addendum 8.5.B: Comparison against External Meta-learners
Downloads
Repository
Commits over time
2 development-tooling and community-health practices detected across 2 families in the upstream repository
Checks run against github.com/isadorenabi/gdpar on 2026-10-21.
Dependencies
Code & Tests
People & History
- 0.1.0Latest2026-07-15 · current release
- RR 4.6.0 released · 2026-04-24
Package metadata
- First published
- 2026-07-15
- Total releases
- 1 / 1 yrs
- License
- GPL (>= 3) OSI
- Additional repositories
- stan-dev.r-universe.dev, inla.r-inla-download.org
- Minimum R
- ≥ 4.2.0
- Download size
- 3.5 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("gdpar")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-25, which the citation names so these numbers can be found later. More on citing and the projects behind them.