Skip to contents

ate_rmean() is a convenience wrapper for restricted-mean treatment effects when the ordinary mean is unstable or undefined.

Usage

ate_rmean(
  fit,
  newdata = NULL,
  cutoff,
  interval = "credible",
  level = 0.95,
  nsim_mean = 200L,
  show_progress = TRUE
)

Arguments

fit

A "causalmixgpd_causal_fit" object from run_mcmc_causal().

newdata

Optional data.frame or matrix of covariates for prediction. If NULL, uses the training covariates stored in fit.

cutoff

Finite numeric cutoff for the restricted mean.

interval

Character or NULL; type of credible interval:

  • NULL: no interval

  • "credible" (default): equal-tailed quantile intervals

  • "hpd": highest posterior density intervals

level

Numeric credible level for intervals (default 0.95 for 95 percent CI).

nsim_mean

Number of posterior predictive draws used by simulation-based mean targets. Ignored for analytical ordinary means.

show_progress

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

Value

A "causalmixgpd_ate" object computed via ate for unconditional fits or cate for conditional fits. The returned object includes a top-level $fit_df data frame for direct extraction.

Details

The restricted-mean estimand replaces \(Y(a)\) by \(\min\{Y(a), c\}\), so the contrast remains finite even when the fitted GPD tail implies \(\xi \ge 1\).

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",
                         GPD = TRUE, components = 3,
                         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
ate_rm <- ate_rmean(fit, cutoff = 10, interval = "credible")
#> [cate] Preparing CATE inputs
#> [cate] Preparing propensity-score adjustment
#> [cate] Predicting treated-arm effects
#> [cate] Predicting control-arm effects
#> [cate] Aggregating CATE estimates
# }