discover_confirm: Discover a Tree and Confirm It on Held-Out Data

View source: R/confirm.R

discover_confirmR Documentation

Discover a Tree and Confirm It on Held-Out Data

Description

A single call that splits the data, imputes each half separately, fits the Stack/M tree on the discovery half, and tests the resulting partition on the confirmation half. Equivalent to calling split_holdout(), mice::mice() twice, ctree_stacked() and confirm_ctreeMI() in sequence.

Usage

discover_confirm(
  formula,
  data,
  prop = 0.5,
  m = 30L,
  strata = NULL,
  cluster = NULL,
  seed = NULL,
  alpha = 0.05,
  mice_args = list(),
  vcov_type = "HC1",
  ...
)

Arguments

formula

Model formula, as for ctree_stacked().

data

A data frame containing missing values.

prop

Proportion assigned to discovery. Default 0.5.

m

Number of imputations for each half. Default 30.

strata

Optional stratification column for the split.

cluster

Optional name of a column identifying a higher-level unit. When given, the split keeps every unit intact on one side, the unit identifier is excluded from the imputation model, and the confirmation test uses a cluster-robust variance. See split_holdout() and confirm_ctreeMI().

seed

Optional integer seed. The confirmation imputation uses seed + 1L so that the two halves are imputed with different streams.

alpha

Nominal level for the discovery tree. Default 0.05.

mice_args

A list of additional arguments passed to mice::mice() for both halves. If it contains a predictorMatrix, that matrix is used as given and cluster is not removed from it.

vcov_type

Passed to confirm_ctreeMI(); ignored unless cluster is given.

...

Further arguments passed to ctree_stacked().

Details

Imputing the halves separately is deliberate. A single imputation of the full data lets each half's outcomes inform the other's imputed predictors, and the confirmation test then no longer sees independent data. The cost is that each imputation model is fitted to half the observations. For most designs this is a reasonable trade; for small samples it may not be, and the user should judge.

Value

An object of class "ctreeMI_dc" containing tree (the ctreeMI fit), confirmation (a ctreeMI_confirm object), split (the ctreeMI_split object), and the two mids objects as imp_discover and imp_confirm.

See Also

split_holdout(), confirm_ctreeMI(), ctree_stacked()

Examples

## Not run: 
set.seed(11)
n <- 800
d <- data.frame(x1 = rnorm(n), x2 = factor(sample(letters[1:3], n, TRUE)))
d$y <- rnorm(n) + 1.5 * (d$x1 > 0.3) + (d$x2 == "a")
d$x1[sample(n, 120)] <- NA
d$x2[sample(n, 80)]  <- NA

res <- discover_confirm(y ~ x1 + x2, data = d, m = 20, seed = 11)
res$tree
res$confirmation

## End(Not run)

ctreeMI documentation built on Oct. 12, 2026, 5:08 p.m.