View source: R/dina_subgroup_bootstrap.R
| dina_subgroup_bootstrap | R Documentation |
Performs selection-adjusted inference for the harm subgroup discovered
by dina_subgroup(). For each of n_boot bootstrap resamples of the
input data frame, the function refits DINA via dina() and re-runs
the subgroup search via dina_subgroup(), then reports three classes
of output:
dina_subgroup_bootstrap(
df,
outcome,
treatment,
covariates,
family = c("gaussian", "binomial", "poisson", "cox"),
status = NULL,
m_diff,
n_min = 60L,
n_min.frac = 0.1,
direction = c("both", "left", "right"),
sg_focus = "maxSG",
effect_neighborhood = 0.1,
alpha = 0.05,
n_boot = 200L,
parallel = c("none", "boots"),
seed = NULL,
verbose = FALSE,
fit = NULL,
sg = NULL,
refit = TRUE,
refit_strata = NULL,
refit_confounders = "none",
...
)
df |
data frame containing the outcome, treatment, and covariate columns. |
outcome |
character(1); name of the response column in |
treatment |
character(1); name of the binary treatment indicator column. |
covariates |
character vector; names of the covariate columns to search over. All must be numeric. |
family |
one of |
status |
character(1) or |
m_diff |
scalar harm threshold on the natural-parameter scale. |
n_min |
positive integer, or |
n_min.frac |
numeric in (0, 1); fraction of |
direction |
one of |
sg_focus |
character; subgroup selection criterion, forwarded to
|
effect_neighborhood |
numeric in |
alpha |
confidence level for the percentile CI. Default |
n_boot |
positive integer; number of bootstrap iterations.
Default |
parallel |
one of |
seed |
optional integer seed for reproducibility of the
bootstrap indices. Default |
verbose |
logical; if |
fit |
optional precomputed DINA fit ( |
sg |
optional precomputed |
refit |
logical; if |
refit_strata |
|
refit_confounders |
adjustment set for the within-subgroup
model: |
... |
further arguments forwarded to |
An effect CI on a*^T beta_b, where a* = (1, x_bar_S) is
held FIXED from the original-data subgroup S* and beta_b is
each iteration's DINA coefficient vector. This is the
bootstrap analog of the Wald CI returned by
dina_subgroup() – conditional on the discovered subgroup
definition, with width reflecting sampling variance of
beta-hat.
Stability CIs on the bootstrap-selected n_subgroup and
threshold, restricted to iterations that selected the same
(covariate, direction) as the original-data subgroup.
A selection-frequency table counting how often each
(covariate, direction) was chosen. The covariate-selection
stability diagnostic.
Each bootstrap iteration calls dina() (single-pass, sandwich
variance) under the hood, not dina_bagged().
If you have already run dina() and dina_subgroup() on the original
data, pass those objects via fit and/or sg so the original-data
point estimate reuses them rather than being recomputed here. This
guarantees the reported point estimate matches your standalone result
exactly; otherwise the internal refit uses its own cross-fitting fold
assignment, which at a boundary-case m_diff can disagree with the
upstream fit on whether a subgroup qualifies.
An object of class "dina_subgroup_bootstrap", a list with
components:
the "dina_subgroup" object computed on the
original (unbootstrapped) data.
named length-2 numeric vector (lower,
upper) giving the bootstrap percentile CI on the
fixed-subgroup linear functional a*^T beta_b, where
a* = (1, x_bar_S) is the covariate-mean vector of the
original-data subgroup and beta_b is each bootstrap
iteration's DINA coefficient vector. This is the
meaningful effect-uncertainty CI; width reflects sampling
variance of beta-hat.
numeric vector of length n_boot
containing a*^T beta_b for each iteration (NA for
iterations whose DINA fit failed).
the "dina_subgroup_refit" object (standard
within-subgroup model on the original data), or NULL if
refit = FALSE, no subgroup was found, or the fit failed.
named length-2 numeric vector (lower,
upper); bootstrap percentile CI on the within-subgroup
standard-model treatment effect, refit within the FIXED
discovered signature on each resample. Conditional on the
signature; comparable to effect_ci. (NA, NA) if refit
was not performed.
numeric vector of length n_boot of
per-iteration within-signature standard-model treatment
effects (NA where not computed or the fit failed).
named length-2 numeric
vectors giving percentile CIs for the structural quantities
of bootstrap-selected subgroups, restricted to iterations
that selected the same (covariate, direction) as the
original-data subgroup. Subgroup-size and boundary-location
stability diagnostics.
integer; number of bootstrap iterations
whose selection matched the original-data
(covariate, direction). Denominator for the stability CIs.
a table of
(covariate, direction) selection counts across found
iterations. Covariate-selection stability diagnostic.
data frame with one row per bootstrap
iteration; columns found, covariate, direction,
threshold, n_subgroup, mean_tau_hat, failed. The
mean_tau_hat column records the bootstrap-selected
subgroup's boundary value (pinned near m_diff by the
search rule) and is retained for diagnostic transparency
rather than as a meaningful effect estimate.
convergence diagnostics.
echoed inputs.
the matched call.
A naive bootstrap of dina_subgroup()'s mean_tau_hat is
uninformative. Under the default sg_focus = "maxSG" the search
selects the largest subgroup whose mean tau-hat exceeds m_diff,
so the chosen subgroup lies at the boundary by construction: adding
one more patient would push the mean below m_diff. Each bootstrap
iteration's selected subgroup is similarly pinned, so the bootstrap
distribution of mean_tau_hat clusters tightly above m_diff
and the resulting CI quantifies threshold-grid granularity
rather than effect uncertainty. (Under the band foci
"effMaxSG" / "effMinSG" the per-iteration subgroup is instead
anchored to the maximum effect rather than the m_diff boundary,
but the same caveat applies: mean_tau_hat is a selection-pinned
quantity, not an effect estimate.) The fixed-subgroup linear
functional a*^T beta_b instead targets the clinically
meaningful estimand "treatment effect for patients whose
covariates lie in the discovered subgroup". Because DINA's
beta-hat is cross-fit (and hence asymptotically unbiased even
for data-driven contrasts), the percentile distribution of
a*^T beta_b gives a non-parametric CI that complements the
sandwich Wald CI of dina_subgroup().
When refit = TRUE (default), the function reports two treatment
effects for the discovered subgroup, on the same natural-parameter
scale:
the DINA effect (effect_ci): the BLP-analog
a*^T beta, a projection of the cross-fitted CATE surface
averaged over the subgroup; and
the within-subgroup standard-model effect
(refit_effect_ci): the treatment coefficient from a plain Cox
model (or GLM) fit on the subgroup, refit within the FIXED
discovered signature on each resample. This is the contrast a
clinical-trial reader usually expects.
The two coincide only under correct linearity; reporting both is
informative. Crucially, both CIs are conditional on the
discovered signature treated as pre-specified – neither corrects for
the data-driven selection of the signature. A selection-adjusted
(de-biased) interval requires the more involved bias-corrected
bootstrap of Leon et al. (2024, Section 3.2) and is not provided
here; selection stability is instead summarized by
selection_frequency.
With parallel = "boots", each bootstrap iteration runs in a worker
via foreach::foreach() %dofuture%. Set future::plan() to a
parallel backend (e.g., future::multisession) before calling, and
reset to "sequential" afterwards. Workers run from the installed
package; devtools::install() is required after code edits before
the parallel branch will see them.
dina_subgroup() for the underlying threshold search;
dina() for the per-iteration DINA fit;
dina_subgroup_refit for the standard within-subgroup
model reported when refit = TRUE.
## Not run:
set.seed(1)
n <- 400
df_demo <- data.frame(
w = stats::rbinom(n, 1, 0.5),
x1 = stats::runif(n, -1, 1),
x2 = stats::runif(n, -1, 1)
)
tau_x <- 0.4 + 1.2 * df_demo$x1
df_demo$y <- 0.5 * df_demo$x1 + df_demo$w * tau_x + stats::rnorm(n)
bs <- dina_subgroup_bootstrap(
df = df_demo,
outcome = "y",
treatment = "w",
covariates = c("x1", "x2"),
family = "gaussian",
m_diff = 0.5,
n_boot = 50L,
seed = 1L
)
print(bs)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.