Conditional average treatment effects
cate.causalmixgpd_causal_fit.Rdcate() evaluates treated-minus-control predictive means, or restricted
means, at user-supplied covariate rows.
Usage
# S3 method for class 'causalmixgpd_causal_fit'
cate(
fit,
newdata = NULL,
type = c("mean", "rmean"),
cutoff = NULL,
interval = "credible",
level = 0.95,
nsim_mean = 200L,
show_progress = TRUE
)Arguments
- fit
A
"causalmixgpd_causal_fit"object fromrun_mcmc_causal().- newdata
Optional data.frame or matrix of covariates for prediction. If
NULL, uses the training covariates stored infit.- type
Character; type of mean treatment effect:
"mean"(default): ordinary mean CATE"rmean": restricted-mean CATE (requirescutoff)
- cutoff
Finite numeric cutoff for restricted mean; required for
type = "rmean", ignored otherwise.- 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
An object of class "causalmixgpd_ate" containing the CATE
summary, optional intervals, and the treated/control prediction objects used
to construct the effect. The returned object includes a top-level
$fit_df data frame for direct extraction.
Details
For each prediction row \(x\), the conditional average treatment effect is $$\mathrm{CATE}(x) = E\{Y(1) \mid x\} - E\{Y(0) \mid x\}.$$
With type = "rmean", the estimand becomes the conditional restricted
mean contrast
$$E\{\min(Y(1), c) \mid x\} -
E\{\min(Y(0), c) \mid x\},$$
which remains finite even when the ordinary mean is unstable under a heavy
GPD tail.
For outcome kernels with a finite analytical mean, the ordinary mean path is
analytical within each posterior draw; rmean remains a separate
simulation-based estimand.
This estimand is available only for conditional causal models with
covariates. For marginal mean contrasts, use ate or
att.
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",
components = 3, mcmc_outcome = mcmc_small, mcmc_ps = mcmc_small)
fit <- run_mcmc_causal(cb, show_progress = FALSE)
#> Defining model
#> 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: beta
#> ===== Samplers =====
#> RW sampler (2)
#> - beta[] (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.
#> running chain 1...
#> Defining model
#> 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, beta_mean, beta_ps_mean, sd, w
#> ===== Samplers =====
#> conjugate sampler (3)
#> - sd[] (3 elements)
#> categorical sampler (15)
#> - z[] (15 elements)
#> RW sampler (9)
#> - alpha
#> - beta_mean[] (3 elements)
#> - beta_ps_mean[] (3 elements)
#> - v[] (2 elements)
#> [Note] Assigning an RW_block sampler to nodes with very different scales can result in low MCMC efficiency. If all nodes assigned to RW_block are not on a similar scale, we recommend providing an informed value for the "propCov" control list argument, or using the "barker" sampler instead.
#> 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...
#> Defining model
#> 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, beta_mean, beta_ps_mean, sd, w
#> ===== Samplers =====
#> conjugate sampler (3)
#> - sd[] (3 elements)
#> categorical sampler (10)
#> - z[] (10 elements)
#> RW sampler (9)
#> - alpha
#> - beta_mean[] (3 elements)
#> - beta_ps_mean[] (3 elements)
#> - v[] (2 elements)
#> [Note] Assigning an RW_block sampler to nodes with very different scales can result in low MCMC efficiency. If all nodes assigned to RW_block are not on a similar scale, we recommend providing an informed value for the "propCov" control list argument, or using the "barker" sampler instead.
#> 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...
cate(fit, newdata = X[1:5, , drop = FALSE])
#> [cate] Preparing CATE inputs
#> [cate] Preparing propensity-score adjustment
#> [cate] Predicting treated-arm effects
#> [cate] Predicting control-arm effects
#> [cate] Aggregating CATE estimates
#> CATE (Conditional Average Treatment Effect)
#> Prediction points: 5
#> Conditional (covariates): YES
#> Propensity score used: YES
#> PS scale: logit
#> Credible interval: credible (95%)
#>
#> CATE estimates (treated - control):
#> profile mean lower upper
#> Profile 1 -0.1 -0.348 0.053
#> Profile 2 -0.089 -0.307 0.047
#> Profile 3 0.078 -0.041 0.27
#> Profile 4 0.295 -0.155 1.02
#> Profile 5 0.062 -0.033 0.215
cate(fit, interval = "credible", level = 0.90) # 90% CI
#> [cate] Preparing CATE inputs
#> [cate] Preparing propensity-score adjustment
#> [cate] Predicting treated-arm effects
#> [cate] Predicting control-arm effects
#> [cate] Aggregating CATE estimates
#> CATE (Conditional Average Treatment Effect)
#> Prediction points: 25
#> Conditional (covariates): YES
#> Propensity score used: YES
#> PS scale: logit
#> Credible interval: credible (90%)
#>
#> CATE estimates (treated - control):
#> id mean lower upper
#> 1 -0.1 -0.284 0.053
#> 2 -0.089 -0.251 0.047
#> 3 0.078 -0.041 0.221
#> 4 0.295 -0.155 0.834
#> 5 0.062 -0.033 0.176
#> 6 -0.142 -0.403 0.075
#> ... (19 more rows)
cate(fit, interval = "hpd") # HPD intervals
#> [cate] Preparing CATE inputs
#> [cate] Preparing propensity-score adjustment
#> [cate] Predicting treated-arm effects
#> [cate] Predicting control-arm effects
#> [cate] Aggregating CATE estimates
#> CATE (Conditional Average Treatment Effect)
#> Prediction points: 25
#> Conditional (covariates): YES
#> Propensity score used: YES
#> PS scale: logit
#> Credible interval: hpd
#>
#> CATE estimates (treated - control):
#> id mean lower upper
#> 1 -0.1 -0.366 0.053
#> 2 -0.089 -0.323 0.047
#> 3 0.078 -0.041 0.284
#> 4 0.295 -0.155 1.074
#> 5 0.062 -0.033 0.227
#> 6 -0.142 -0.519 0.075
#> ... (19 more rows)
cate(fit, interval = NULL) # No intervals
#> [cate] Preparing CATE inputs
#> [cate] Preparing propensity-score adjustment
#> [cate] Predicting treated-arm effects
#> [cate] Predicting control-arm effects
#> [cate] Aggregating CATE estimates
#> CATE (Conditional Average Treatment Effect)
#> Prediction points: 25
#> Conditional (covariates): YES
#> Propensity score used: YES
#> PS scale: logit
#> Credible interval: none
#>
#> CATE estimates (treated - control):
#> id mean lower upper
#> 1 -0.1 NA NA
#> 2 -0.089 NA NA
#> 3 0.078 NA NA
#> 4 0.295 NA NA
#> 5 0.062 NA NA
#> 6 -0.142 NA NA
#> ... (19 more rows)
# }