Build the explicit one-arm NIMBLE bundle
build_nimble_bundle.Rdbuild_nimble_bundle() is the detailed constructor behind
bundle for one-arm models. It compiles the modeling plan into a
self-contained object holding code-generation inputs, initialization rules,
monitor policy, and stored MCMC defaults.
Usage
build_nimble_bundle(
y,
X = NULL,
ps = NULL,
backend = c("sb", "crp", "spliced"),
kernel,
GPD = FALSE,
components = NULL,
param_specs = NULL,
mcmc = list(niter = 2000, nburnin = 500, thin = 1, nchains = 1, seed = 1),
epsilon = 0.025,
alpha_random = TRUE,
monitor = c("core", "full"),
monitor_latent = FALSE,
monitor_v = FALSE
)Arguments
- y
Numeric outcome vector.
- X
Optional design matrix/data.frame (N x p) for conditional variants.
- ps
Optional numeric vector (length N) of propensity scores. When provided, augments the design matrix for PS-adjusted outcome modeling.
- backend
Character; the Dirichlet process representation:
"sb": stick-breaking truncation"crp": Chinese Restaurant Process
- kernel
Character kernel name (must exist in
get_kernel_registry()).- GPD
Logical; whether a GPD tail is requested.
- components
Integer >= 2. Single user-facing truncation parameter:
SB: number of mixture components used in stick-breaking truncation
CRP: maximum number of clusters represented in the finite NIMBLE model
- param_specs
Optional list with entries
bulkandtailto override defaults.- mcmc
Named list of MCMC settings (niter, nburnin, thin, nchains, seed). Stored in bundle.
- epsilon
Numeric in [0,1). For downstream summaries/plots/prediction we keep the smaller k defined by either (i) cumulative mass >= 1 - epsilon or (ii) per-component weights >= epsilon, then renormalize.
- alpha_random
Logical; whether the DP concentration parameter \(\kappa\) is stochastic.
- monitor
Character monitor profile:
"core"(default): monitors only the essential model parameters"full": monitors all model nodes
- monitor_latent
Logical; if TRUE, include latent cluster labels (
z) in monitors.- monitor_v
Logical; if TRUE and backend is SB, include stick breaks (
v) in monitors.
Value
A named list of class "causalmixgpd_bundle". Its primary
components are spec, code, constants,
dimensions, data, inits, monitors, and stored
mcmc settings.
Details
The returned bundle encodes a finite approximation to a Dirichlet process
mixture using either a stick-breaking ("sb") or Chinese restaurant
process / spliced ("crp" / "spliced") representation.
For the bulk-only model, the target likelihood is the DPM predictive law
$$f(y \mid x) = \sum_{k=1}^{K} w_k(x) f_k(y \mid x, \theta_k).$$
When GPD = TRUE, the bundle augments the bulk model with a threshold
\(u(x)\) and generalized Pareto tail above that threshold, producing the
spliced predictive distribution described in the manuscript vignette.
This function intentionally stops before model compilation and sampling.
Use run_mcmc_bundle_manual or mcmc to execute the
stored model definition.
The object contains:
compiled model
specnimbleCodemodel codeconstants,data, explicitdimensionsinitialization function
inits(stored as a function)monitor specification
MCMC settings list (stored but not used for code generation)