## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  echo = TRUE,
  message = FALSE,
  warning = FALSE
)

## ----contract-adapter, eval = FALSE-------------------------------------------
# gdpar_meta_learner_adapter(
#   name,            # character scalar, unique within a comparison
#   fit_predict_fun, # mandatory closure
#   predict_fun,     # optional closure (default NULL)
#   requires_r,      # character vector of R packages needed
#   requires_py,     # character vector of Python modules needed
#   native_ci,       # logical scalar
#   description      # optional character scalar
# )

## ----mre, eval = FALSE--------------------------------------------------------
# library(gdpar)
# if (requireNamespace("grf", quietly = TRUE) &&
#     requireNamespace("cmdstanr", quietly = TRUE)) {
# 
#   set.seed(2026L)
#   n <- 300L
#   df <- data.frame(x1 = rnorm(2L * n))
#   df$arm <- rep(c("treat", "ctrl"), each = n)
#   df$y <- with(df, ifelse(arm == "treat", 0.5, 0) +
#                    0.8 * x1 +
#                    rnorm(2L * n, sd = 0.5))
#   df_t <- subset(df, arm == "treat"); df_t$arm <- NULL
#   df_c <- subset(df, arm == "ctrl");  df_c$arm <- NULL
# 
#   fit_t <- gdpar(y ~ x1, amm = amm_spec(a = ~ x1), data = df_t,
#                  iter_warmup = 300, iter_sampling = 300, chains = 2)
#   fit_c <- gdpar(y ~ x1, amm = amm_spec(a = ~ x1), data = df_c,
#                  iter_warmup = 300, iter_sampling = 300, chains = 2)
#   newdata <- data.frame(x1 = seq(-2, 2, length.out = 21L))
#   bridge <- gdpar_causal_bridge(fit_t, fit_c, newdata = newdata)
# 
#   cmp <- gdpar_compare_meta_learners(
#     bridge,
#     methods = list(grf = gdpar_adapter_grf(num_trees = 500L,
#                                             seed = 2026L))
#   )
#   print(cmp)
#   summary(cmp)
# }

