# 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. (2011a).
alpha <- 0.025
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)
marginal_power <- c(0.8, 0.8, 0.7, 0.9)
corr1 <- matrix(0.5, nrow = 2, ncol = 2)
diag(corr1) <- 1
corr <- rbind(
cbind(corr1, 0.5 * corr1),
cbind(0.5 * corr1, corr1)
)
success_fns <- list(
# Probability to reject both H1 and H2
`H1andH2` = function(x) x[1] & x[2],
# Probability to reject both (H1 and H3) or (H2 and H4)
`(H1andH3)or(H2andH4)` = function(x) (x[1] & x[3]) | (x[2] & x[4])
)
set.seed(1234)
# Bonferroni tests
# Reduce the number of simulations to save time for package compilation
power_output <- graph_calculate_power(
g,
alpha,
sim_corr = corr,
sim_n = 1e2,
power_marginal = marginal_power,
sim_success = success_fns
)
# Parametric tests for H1 and H2; Simes tests for H3 and H4
# User-defined success: to reject H1 or H2; to reject H1 and H2
# Reduce the number of simulations to save time for package compilation
graph_calculate_power(
g,
alpha,
test_groups = list(1:2, 3:4),
test_types = c("parametric", "simes"),
test_corr = list(corr1, NA),
sim_n = 1e2,
sim_success = list(
function(.) .[1] || .[2],
function(.) .[1] && .[2]
)
)
Run the code above in your browser using DataLab