Code
# Load packaged data
data("nc_pos200_k3")
y <- nc_pos200_k3$y
# Direct call
bundle_direct <- bundle(
y = y,
kernel = "gamma",
backend = "crp",
GPD = FALSE,
components = 5,
mcmc = mcmc
)Website workflow note. This page reflects the current exported API and recommended wrapper-first usage. Last updated: 2026-02-19.
For the full package narrative, see the main package vignettes (basic, unconditional, conditional, and causal).
CausalMixGPD supports a wrapper-first workflow for most users:
dpmix() or dpmgpd().summary(), plot(), and predict().The lower-level bundle route (bundle() then mcmc()) remains available for advanced control.
Purpose: Generate NIMBLE model code, compile sampler, prepare for MCMC execution.
For the underlying model math (GPD threshold exceedances, DPM bulk regression, and the spliced quantile construction), see Theory: GPD tails + DPM bulk + splicing.
[1] "causalmixgpd_bundle"
[1] "spec" "code" "constants" "dimensions"
[5] "data" "inits" "monitors" "monitor_policy"
[9] "mcmc" "epsilon"
NULL
Purpose: Run posterior sampling from the compiled bundle.
MixGPD summary | backend: Chinese Restaurant Process | kernel: Gamma Distribution | GPD tail: FALSE | epsilon: 0.025
n = 200 | components = 5
Summary
Initial components: 5 | Components after truncation: 2
WAIC: 946.601
lppd: -425.102 | pWAIC: 48.198
Summary table
parameter mean sd q0.025 q0.500 q0.975 ess
weights[1] 0.686 0.11 0.464 0.698 0.891 12.71
weights[2] 0.281 0.096 0.093 0.275 0.461 18.124
alpha 0.518 0.34 0.069 0.44 1.364 58.839
shape[1] 1.574 0.25 1.281 1.525 2.23 7.387
shape[2] 1.549 0.252 1.009 1.547 2.033 18.653
scale[1] 0.295 0.061 0.232 0.285 0.427 29.112
scale[2] 1.232 0.47 0.437 1.166 2.333 29.485
Posterior mean parameters
$alpha
[1] 0.5175
$w
[1] 0.6862 0.2813
$shape
[1] 1.574 1.549
$scale
[1] 0.2955 1.2320
=== traceplot ===

=== running ===

=== autocorrelation ===

# Load packaged data
data("nc_pos200_k3")
y_data <- nc_pos200_k3$y
# PHASE 1: Bundle
bundle_final <- bundle(
y = y_data,
kernel = "gamma",
backend = "crp",
GPD = FALSE,
components = 5,
mcmc = mcmc
)
# PHASE 2: MCMC
fit_final <- load_or_fit("quickstart-basic-model-compile-run-fit_final", dpmix(bundle_final, mcmc = list(show_progress = FALSE)))
summary(fit_final)MixGPD summary | backend: Chinese Restaurant Process | kernel: Gamma Distribution | GPD tail: FALSE | epsilon: 0.025
n = 200 | components = 5
Summary
Initial components: 5 | Components after truncation: 2
WAIC: 920.54
lppd: -398.762 | pWAIC: 61.508
Summary table
parameter mean sd q0.025 q0.500 q0.975 ess
weights[1] 0.595 0.098 0.464 0.58 0.831 15.934
weights[2] 0.359 0.101 0.126 0.372 0.496 13.749
alpha 0.557 0.335 0.088 0.508 1.431 47.5
shape[1] 1.892 0.478 1.363 1.822 3.247 22.224
shape[2] 2.241 0.792 1.291 1.914 3.779 7.634
scale[1] 0.579 0.306 0.27 0.383 1.258 6.476
scale[2] 0.938 0.625 0.278 0.934 1.974 12.255
[1] "gamma" "lognormal" "normal" "laplace" "invgauss" "amoroso"
[7] "cauchy"
# Data with tail behavior
data("nc_pos_tail200_k4")
y_tail <- nc_pos_tail200_k4$y
# Build with GPD
bundle_gpd <- bundle(
y = y_tail,
kernel = "gamma",
backend = "sb",
GPD = TRUE,
components = 6,
mcmc = mcmc
)
fit_gpd <- load_or_fit("quickstart-basic-model-compile-run-fit_gpd", dpmgpd(bundle_gpd, mcmc = list(show_progress = FALSE)))
summary(fit_gpd)MixGPD summary | backend: Stick-Breaking Process | kernel: Gamma Distribution | GPD tail: TRUE | epsilon: 0.025
n = 200 | components = 6
Summary
Initial components: 6 | Components after truncation: 2
Summary table
parameter mean sd q0.025 q0.500 q0.975 ess
weights[1] 0.59 0.075 0.463 0.572 0.734 4.464
weights[2] 0.314 0.07 0.205 0.28 0.444 5.817
alpha 0.952 0.821 0.175 0.615 2.981 3.838
tail_scale 1.763 0.355 1.136 1.747 2.458 77.733
tail_shape 0.215 0.117 -0.006 0.202 0.457 59.637
threshold 2.934 0.371 2.101 2.944 3.762 17.482
shape[1] 5.105 1.01 2.76 5.128 7.097 8.91
shape[2] 2.621 1.234 1.311 2.41 6.855 11.842
scale[1] 0.292 0.217 0.165 0.234 1.143 19.113
scale[2] 2.191 1.139 0.151 1.988 4.898 19.684
| Phase | Function | Input | Output |
|---|---|---|---|
| 1. Fit (bulk only) | dpmix() |
y, X (optional), kernel, backend, components, mcmc | mixgpd_fit |
| 2. Fit (bulk + tail) | dpmgpd() |
y, X (optional), kernel, backend, components, mcmc | mixgpd_fit |
profile niter nburnin nchains
1 Quick test 500 100 1
2 Standard 1000 250 2
3 Production 1000 250 3