fs_assert_membership: Assert the exported selected-subgroup membership matches...

View source: R/fs_to_guohe.R

fs_assert_membershipR Documentation

Assert the exported selected-subgroup membership matches forestsearch's own

Description

Integrity check for fs_export_maxeff_family(): the materialized membership column of the selected candidate must equal, row for row, the per-subject membership forestsearch itself computed (fit$grp.consistency$sg.harm.id). A mismatch means the label-to-dummy reconstruction is wrong, so this stops with an error rather than letting a silently different subgroup be de-biased. fs_to_guohe() runs this check by default (verify = TRUE).

Usage

fs_assert_membership(exp, fit)

Arguments

exp

The list returned by fs_export_maxeff_family().

fit

The forestsearch object exp was exported from.

Value

TRUE, invisibly, if the memberships agree; otherwise an error is thrown.

See Also

fs_export_maxeff_family(), fs_to_guohe()

Examples

set.seed(11)
n <- 200
df <- data.frame(id = seq_len(n), treat = rbinom(n, 1, 0.5),
                 age = round(rnorm(n, 55, 12)),
                 bm = factor(rbinom(n, 1, 0.5)))
harm <- df$age <= 50 & df$bm == "1"
tt <- rexp(n, 0.05 * exp(log(2.5) * df$treat * harm))
df$time <- pmin(tt, 60)
df$event <- as.integer(tt <= 60)
fit <- forestsearch(
  df.analysis = df,
  outcome.name = "time", event.name = "event",
  treat.name = "treat", id.name = "id",
  confounders.name = c("age", "bm"),
  sg_focus = "maxeff", use_grf = FALSE, use_lasso = FALSE,
  fs.splits = 50, n.min = 30, d0.min = 5, d1.min = 5,
  hr.threshold = 1.1, hr.consistency = 1.0,
  pconsistency.threshold = 0.5, maxk = 2,
  details = FALSE, plot.sg = FALSE,
  parallel_args = list(plan = "sequential", workers = 1L,
                       show_message = FALSE)
)
exp_fam <- fs_export_maxeff_family(fit)
fs_assert_membership(exp_fam, fit)


forestsearch documentation built on Nov. 15, 2026, 9:06 a.m.