# A graphical multiple comparison procedure with two primary hypotheses
# (H1 and H2) and two secondary hypotheses (H3 and H4)
# See Figure 4 in Bretz et al. (2011).
hypotheses <- c(0.5, 0.5, 0, 0)
delta <- 0.5
transitions <- rbind(
c(0, delta, 1 - delta, 0),
c(delta, 0, 0, 1 - delta),
c(0, 1, 0, 0),
c(1, 0, 0, 0)
)
g <- graph_create(hypotheses, transitions)
p <- c(0.018, 0.01, 0.105, 0.006)
alpha <- 0.025
# Closed graphical multiple comparison procedure using Bonferroni tests
# Same results as `graph_test_shortcut(g, p, alpha)`
graph_test_closure(g, p, alpha)
# Closed graphical multiple comparison procedure using parametric tests for
# H1 and H2, and Bonferroni tests for H3 and H4
set.seed(1234)
corr_list <- list(matrix(c(1, 0.5, 0.5, 1), nrow = 2), NA)
graph_test_closure(
graph = g,
p = p,
alpha = alpha,
test_groups = list(1:2, 3:4),
test_types = c("parametric", "bonferroni"),
test_corr = corr_list
)
# The "named" approach to obtain the same results
# Note that "group2" appears before "group1" in `test_groups`
set.seed(1234)
corr_list <- list(group1 = matrix(c(1, 0.5, 0.5, 1), nrow = 2), group2 = NA)
graph_test_closure(
graph = g,
p = p,
alpha = alpha,
test_groups = list(group1 = 1:2, group2 = 3:4),
test_types = c(group2 = "bonferroni", group1 = "parametric"),
test_corr = corr_list
)
# Closed graphical multiple comparison procedure using parametric tests for
# H1 and H2, and Simes tests for H3 and H4
set.seed(1234)
graph_test_closure(
graph = g,
p = p,
alpha = alpha,
test_groups = list(group1 = 1:2, group2 = 3:4),
test_types = c(group1 = "parametric", group2 = "simes"),
test_corr = corr_list
)
Run the code above in your browser using DataLab