Skip to contents

Inspects a NIMBLE model produced by build_fn() to:

  • count stochastic vs. deterministic nodes (optionally including data),

  • parse the model code to detect non-differentiable functions and BUGS-style truncation,

  • rebuild a per-node table with distribution, support, and bounds,

  • tag HMC showstoppers (for example discrete latents, simplex constraints, truncation, non-differentiable deterministic operations feeding latents),

  • optionally attempt a short HMC/NUTS run (via nimbleHMC) to check practical feasibility.

Usage

run_structure_and_hmc_test(
  build_fn,
  include_data = FALSE,
  try_hmc = TRUE,
  niter = 50L,
  nburnin = 10L,
  seed = 1L
)

Arguments

build_fn

A zero-arg function returning a list with at least model (nimbleModel); optional elements: cmodel, monitors, code_text (or code) used to strengthen non-differentiability detection.

include_data

Logical; include data nodes in counts and scans. Default FALSE.

try_hmc

Logical; if TRUE, attempt a brief HMC/NUTS run. Default TRUE.

niter

Integer; total iterations for the HMC test. Default 50L.

nburnin

Integer; burn-in for the HMC test. Default 10L.

seed

Integer; RNG seed for the HMC run. Default 1L.

Value

An invisible list with components:

  • diag: list with nodes (data.frame of node metadata and HMC showstopper tags), nondiff_signals, code_scan, hmc_globally_ok.

  • hmc: list describing the HMC trial (ok, error, details).

Details

Compared to diagnose_model_structure(), this function does not filter nodes by ignore patterns or explicit removals and does not compute dependency fan-out. Its emphasis is HMC suitability rather than structural load.

Examples

if (FALSE) { # \dontrun{
out <- run_structure_and_hmc_test(my_builder, include_data = FALSE, try_hmc = TRUE)
if (!out$hmc$ok) message("HMC not feasible: ", out$hmc$error)
} # }