Run posterior sampling for a prepared one-arm bundle
run_mcmc_bundle_manual.Rdrun_mcmc_bundle_manual() is the explicit runner for objects created by
build_nimble_bundle. It compiles the stored NIMBLE code,
executes MCMC, and returns a "mixgpd_fit" object.
Usage
run_mcmc_bundle_manual(
bundle,
show_progress = TRUE,
quiet = FALSE,
parallel_chains = FALSE,
workers = NULL,
timing = FALSE,
z_update_every = NULL
)Arguments
- bundle
A
causalmixgpd_bundlefrombuild_nimble_bundle().- show_progress
Logical; if TRUE, print step messages and render progress where supported.
- quiet
Logical; if TRUE, suppress console status messages. Set to FALSE to see progress messages during MCMC setup and execution.
- parallel_chains
Logical; run chains concurrently when
nchains > 1.- workers
Optional integer number of workers for parallel execution.
- timing
Logical; if TRUE, include stage timings (
build,compile,mcmc) infit$timing.- z_update_every
Integer >= 1 controlling latent cluster-label update cadence.
Value
A fitted object of class "mixgpd_fit" containing posterior
draws, model metadata, and cached objects used by downstream S3 methods.
Details
The resulting fit supports posterior summaries of the model parameters as well as posterior predictive functionals such as \(f(y \mid x)\), \(S(y \mid x)\), \(Q(\tau \mid x)\), and restricted means.
If parallel_chains = TRUE, chains are run concurrently when the stored
MCMC configuration uses more than one chain. If the bundle was built with
latent cluster labels monitored, the z_update_every argument controls how
frequently those latent indicators are refreshed during sampling.
Examples
# \donttest{
library(nimble)
y <- abs(rnorm(25)) + 0.1
bundle <- build_nimble_bundle(
y = y,
backend = "sb",
kernel = "normal",
GPD = FALSE,
components = 3,
mcmc = list(niter = 100, nburnin = 50, thin = 1, nchains = 1, seed = 1)
)
fit <- run_mcmc_bundle_manual(bundle, show_progress = FALSE)
#> Defining model
#> [Note] 'P' is provided in 'constants' but not used in the model code and is being ignored.
#> Building model
#> Setting data and initial values
#> Checking model sizes and dimensions
#> [Note] This model is not fully initialized. This is not an error.
#> To see which variables are not initialized, use model$initializeInfo().
#> For more information on model initialization, see help(modelInitialization).
#> ===== Monitors =====
#> thin = 1: alpha, mean, sd, w
#> ===== Samplers =====
#> conjugate sampler (6)
#> - mean[] (3 elements)
#> - sd[] (3 elements)
#> categorical sampler (25)
#> - z[] (25 elements)
#> RW sampler (3)
#> - alpha
#> - v[] (2 elements)
#> Compiling
#> [Note] This may take a minute.
#> [Note] Use 'showCompilerOutput = TRUE' to see C++ compilation details.
#> Compiling
#> [Note] This may take a minute.
#> [Note] Use 'showCompilerOutput = TRUE' to see C++ compilation details.
#> [Warning] To calculate WAIC, set 'WAIC = TRUE', in addition to having enabled WAIC in building the MCMC.
#> running chain 1...
fit
#> MixGPD fit | backend: Stick-Breaking Process | kernel: Normal Distribution | GPD tail: FALSE
#> n = 25 | components = 3 | epsilon = 0.025
#> MCMC: niter=100, nburnin=50, thin=1, nchains=1
#> Fit
#> Use summary() for posterior summaries; plot() for diagnostics; predict() for predictions.
# }