Skip to contents

dpmix.causal() fits a causal model with separate treated and control outcome mixtures and, when requested, a propensity score block. It is the bulk-only companion to dpmgpd.causal.

Usage

dpmix.causal(
  y = NULL,
  X = NULL,
  treat = NULL,
  data = NULL,
  mcmc = list(),
  formula = NULL,
  ...
)

Arguments

y

Either a response vector or a causal bundle object.

X

Optional design matrix/data.frame.

treat

Binary treatment indicator.

data

Optional data.frame used with formula.

mcmc

Named list of run arguments passed to mcmc() (including optional performance controls such as parallel_arms, workers, timing, and z_update_every).

formula

Optional formula.

...

Additional build arguments passed to build_causal_bundle.

Value

A fitted object of class "causalmixgpd_causal_fit".

Details

The resulting fit supports conditional outcome prediction \(F_a(y \mid x)\) for \(a \in \{0,1\}\), followed by causal functionals such as ate, qte, cate, and cqte.

Examples

# \donttest{
N <- 30
X <- data.frame(x1 = stats::rnorm(N), x2 = stats::runif(N))
A <- stats::rbinom(N, 1, 0.5)
y <- abs(stats::rnorm(N) + A + 0.5 * X$x1) + 0.1
mcmc_small <- list(niter = 100, nburnin = 50, thin = 1, nchains = 1, seed = 1)

fit <- dpmix.causal(
  y = y, X = X, treat = A,
  backend = "sb", kernel = "normal",
  components = 3, mcmc = mcmc_small
)
#> [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
summary(fit)
#> Timing (sec): total =   NA | PS =   NA | control =   NA | treated =   NA  
#> 
#> -- PS fit --
#> CausalMixGPD PS fit summary
#> model: logit 
#> n = 30 | predictors = 3
#> Monitors: beta 
#> 
#> Summary table
#>  parameter   mean    sd q0.025 q0.500 q0.975
#>    beta[1] -1.071 0.708 -2.425 -1.123  0.411
#>    beta[2]  0.137 0.375 -0.635  0.132  0.814
#>    beta[3]  2.233 1.143 -0.247  2.293  4.426
#> 
#> -- Outcome fits --
#> [control]
#> MixGPD summary | backend: Stick-Breaking Process | kernel: Normal Distribution | GPD tail: FALSE | epsilon: 0.025
#> n = 14 | components = 3
#> Summary
#> Initial components: 3 | Components after truncation: 1
#> 
#> Summary table
#>       parameter  mean    sd q0.025 q0.500 q0.975
#>      weights[1] 0.918 0.095  0.711  0.954      1
#>           alpha 0.673 0.344  0.178  0.766  1.385
#>           sd[1] 3.061 1.094   1.41  2.984  5.417
#>  beta_mean[1,1] 0.164 0.088 -0.097  0.192  0.192
#>  beta_mean[1,2] 2.592 0.061  2.411  2.612  2.612
#> 
#> [treated]
#> MixGPD summary | backend: Stick-Breaking Process | kernel: Normal Distribution | GPD tail: FALSE | epsilon: 0.025
#> n = 16 | components = 3
#> Summary
#> Initial components: 3 | Components after truncation: 2
#> 
#> Summary table
#>       parameter  mean    sd q0.025 q0.500 q0.975
#>      weights[1] 0.682 0.082  0.558  0.723  0.775
#>      weights[2] 0.297 0.096  0.193  0.247  0.442
#>           alpha 1.802 0.773  0.455  1.779  3.324
#>           sd[1] 1.571 0.629  0.625  1.395  2.603
#>           sd[2] 2.282 1.246   0.37  2.167  4.361
#>  beta_mean[1,1] 0.038 0.493 -0.439 -0.231  0.653
#>  beta_mean[1,2] 2.064 0.108  1.987  1.987  2.215
#>  beta_mean[2,1] 0.242 0.708 -0.346 -0.261  1.136
#>  beta_mean[2,2] 2.025 0.429  1.357  2.173  2.381
ate(fit, show_progress = FALSE)
#> ATE (Average Treatment Effect)
#>   Prediction points: 1
#>   Conditional (covariates): NO
#>   Propensity score used: YES
#>   PS scale: logit
#>   Credible interval: credible (95%)
#> 
#> ATE estimates (treated - control):
#>    mean  lower upper
#>  -0.292 -0.463  -0.2
# }