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

## ----dgp, eval = FALSE--------------------------------------------------------
# library(gdpar)
# set.seed(20260524)
# n_per_arm <- 300L
# beta0 <- 0.2; beta1 <- 0.8
# tau0  <- 1.0; tau1  <- 0.5  # true CATE: tau(x) = tau0 + tau1 * x
# df_treat <- data.frame(
#   x1 = rnorm(n_per_arm),
#   y  = NA_real_
# )
# df_treat$y <- (beta0 + tau0) +
#   (beta1 + tau1) * df_treat$x1 + rnorm(n_per_arm, sd = 0.4)
# df_ctrl <- data.frame(
#   x1 = rnorm(n_per_arm),
#   y  = NA_real_
# )
# df_ctrl$y <- beta0 + beta1 * df_ctrl$x1 + rnorm(n_per_arm, sd = 0.4)

## ----fits, eval = FALSE-------------------------------------------------------
# fit_treat <- gdpar(
#   formula       = y ~ x1,
#   family        = gdpar_family("gaussian"),
#   amm           = amm_spec(a = ~ x1),
#   data          = df_treat,
#   chains        = 2L,
#   iter_warmup   = 500L,
#   iter_sampling = 500L,
#   refresh       = 0L,
#   verbose       = FALSE
# )
# fit_ctrl <- gdpar(
#   formula       = y ~ x1,
#   family        = gdpar_family("gaussian"),
#   amm           = amm_spec(a = ~ x1),
#   data          = df_ctrl,
#   chains        = 2L,
#   iter_warmup   = 500L,
#   iter_sampling = 500L,
#   refresh       = 0L,
#   verbose       = FALSE
# )

## ----bridge, eval = FALSE-----------------------------------------------------
# grid <- data.frame(x1 = seq(-2, 2, length.out = 21L))
# bridge <- gdpar_causal_bridge(fit_treat, fit_ctrl, newdata = grid)
# print(bridge)
# summary(bridge)

## ----repredict, eval = FALSE--------------------------------------------------
# grid2 <- data.frame(x1 = seq(-1, 1, length.out = 11L))
# re <- predict(bridge, newdata = grid2)
# str(re, max.level = 1L)

