Proper Closed Testing Procedure for Hierarchical Hypotheses
closed_testing_procedure.RdThis implements a valid closed testing procedure following Goeman's methodology that ensures proper FWER control by testing all intersection hypotheses.
References
Goeman, J. J., & Solari, A. (2011). Multiple testing for exploratory research. Statistical science, 26(4), 584-597.
Goeman, J. J., & Finos, L. (2012). The inheritance procedure: multiple testing of tree-structured hypotheses. Statistical Applications in Genetics and Molecular Biology, 11(1).
Examples
if (FALSE) { # \dontrun{
# Load example data and run find_blocks with closed testing
data(example_dat, package = "manytestsr")
library(data.table)
library(dplyr)
# Prepare data
idat <- as.data.table(example_dat)
bdat <- idat %>%
group_by(blockF) %>%
summarize(
nb = n(),
pb = mean(trt),
hwt = (nb / nrow(idat)) * (pb * (1 - pb)),
.groups = "drop"
) %>%
as.data.table()
# Run find_blocks with closed testing procedure
results_closed <- find_blocks(
idat = idat,
bdat = bdat,
blockid = "blockF",
splitfn = splitCluster,
pfn = pIndepDist,
fmla = Y1 ~ trtF | blockF,
splitby = "hwt",
parallel = "no",
use_closed_testing = TRUE,
closed_testing_method = "simes", # Goeman & Solari recommend Simes
thealpha = 0.05,
maxtest = 20
)
# Compare with traditional approach
results_traditional <- find_blocks(
idat = idat,
bdat = bdat,
blockid = "blockF",
splitfn = splitCluster,
pfn = pIndepDist,
fmla = Y1 ~ trtF | blockF,
splitby = "hwt",
parallel = "no",
use_closed_testing = FALSE,
thealpha = 0.05,
maxtest = 20
)
# Examine closed testing results
if ("closed_testing_reject" %in% names(results_closed$node_dat)) {
closed_rejections <- results_closed$node_dat[
closed_testing_reject == TRUE,
.(nodenum, p, closed_testing_reject)
]
cat("Closed testing rejections:\n")
print(closed_rejections)
}
# Traditional rejections for comparison
traditional_detections <- report_detections(results_traditional$bdat, fwer = TRUE)
cat("Traditional FWER rejections:", sum(traditional_detections$hit, na.rm = TRUE), "\n")
} # }