Skip to contents

run_mcmc_causal() executes the PS block (when enabled) and the two arm-specific outcome models prepared by build_causal_bundle, then returns a single "causalmixgpd_causal_fit" object.

Usage

run_mcmc_causal(
  bundle,
  show_progress = TRUE,
  quiet = FALSE,
  parallel_arms = FALSE,
  workers = NULL,
  timing = FALSE,
  z_update_every = NULL
)

Arguments

bundle

A "causalmixgpd_causal_bundle" from build_causal_bundle().

show_progress

Logical; if TRUE, print step messages and render progress where supported.

quiet

Logical; if TRUE, suppress step messages and progress display.

parallel_arms

Logical; if TRUE, run control and treated outcome arms in parallel.

workers

Optional integer workers for parallel arm execution.

timing

Logical; if TRUE, return arm and total timings in $timing.

z_update_every

Integer >= 1 passed to arm-level outcome MCMC.

Value

A list of class "causalmixgpd_causal_fit" containing the fitted treated/control outcome models, optional PS fit, the original bundle, and timing metadata when requested.

Details

The fitted object contains the posterior draws needed to evaluate arm-level predictive distributions \(F_1(y \mid x)\) and \(F_0(y \mid x)\), followed by marginal or conditional causal contrasts. When PS = FALSE in the bundle, the PS block is skipped and outcome prediction uses only the original covariates.

Examples

# \donttest{
N <- 25
X <- data.frame(x1 = stats::rnorm(N))
A <- stats::rbinom(N, 1, 0.5)
y <- abs(stats::rnorm(N)) + 0.1
mcmc_small <- list(niter = 100, nburnin = 50, thin = 1, nchains = 1, seed = 1)
cb <- build_causal_bundle(y = y, X = X, A = A, backend = "sb", kernel = "normal",
                         mcmc_outcome = mcmc_small, mcmc_ps = mcmc_small)
fit <- run_mcmc_causal(cb)
#> [causal] Validating causal MCMC configuration
#> [causal] Running propensity score block
#> [ps] Validating PS MCMC inputs
#> [ps] Building PS NIMBLE model
#> [ps] Compiling PS model
#> [ps] Running PS MCMC
#> [ps] Assembling PS fit
#> [causal] Validating outcome-arm bundles
#> [causal] Running control-arm outcome MCMC
#> [mixgpd] Validating configuration
#> [mixgpd] Checking build/compile cache
#> [mixgpd] Building model and MCMC configuration
#> [mixgpd] Compiling NIMBLE model
#> [mixgpd] Initializing chains
#> [mixgpd] Running MCMC
#> [mixgpd] Finalizing WAIC and diagnostics
#> [mixgpd] Assembling fit object
#> [causal] Running treated-arm outcome MCMC
#> [mixgpd] Validating configuration
#> [mixgpd] Checking build/compile cache
#> [mixgpd] Building model and MCMC configuration
#> [mixgpd] Compiling NIMBLE model
#> [mixgpd] Initializing chains
#> [mixgpd] Running MCMC
#> [mixgpd] Finalizing WAIC and diagnostics
#> [mixgpd] Assembling fit object
#> [causal] Assembling causal fit object
# }