initial_weights <- c(0.5, 0.5, 0, 0)
transition_matrix <- matrix(c(0, 0.5, 0.5, 0,
0.5, 0, 0, 0.5,
0, 1, 0, 0,
1, 0, 0, 0),
nrow = 4, byrow = TRUE)
wgtmat <- fwgtmat(initial_weights, transition_matrix)
family <- matrix(c(1, 1, 0, 0,
0, 0, 1, 1),
nrow = 2, byrow = TRUE)
corr <- matrix(c(1, 0.5, NA, NA,
0.5, 1, NA, NA,
NA, NA, 1, 0.5,
NA, NA, 0.5, 1),
nrow = 4, byrow = TRUE)
alpha <- 0.025
alpha1 <- errorSpent(0.5, alpha, "sfOF")
stage1_pvalues <- c(0.00045, 0.0952, 0.0225, 0.1104)
stage1_loc_p <- fPCStagewise(
stg2_p = stage1_pvalues, wgtmat = wgtmat,
family = family, corr = corr,
stg1_inthyp_nr = 1:15, stg2_elemhyp = 1:4,
stg2_wgtmat = wgtmat, test = "dunnett",
nthreads = 1)
stage1_rejections <- fPCStage1(stage1_loc_p, alpha1)
adapted_graph <- updateGraph(initial_weights,
transition_matrix,
I = 1:4, j = 1)
stage2_weight_matrix <- fwgtmat(
w = adapted_graph$w[adapted_graph$I],
G = adapted_graph$G[adapted_graph$I, adapted_graph$I])
stage2_pvalues <- c(0.1121, 0.0112, 0.1153)
stage2_loc_p <- fPCStagewise(
stg2_p = stage2_pvalues, wgtmat = wgtmat,
family = family, corr = corr,
stg1_inthyp_nr = stage1_rejections$stg1_inthyp_nr_idx,
stg2_elemhyp = adapted_graph$I,
stg2_wgtmat = stage2_weight_matrix,
test = "dunnett", nthreads = 1)
fPCRej(stg1_loc_p = stage1_loc_p, stg2_loc_p = stage2_loc_p,
stg1_elemhyp_r_idx = stage1_rejections$stg1_elemhyp_r_idx,
stg2_elemhyp_idx = adapted_graph$I, alpha = alpha,
info_frac = 0.5)
# Change weights for the elementary hypotheses.
stage2_weight_matrix_reweighted <- fwgtmat(
w = c(0.5, 0.25, 0.25),
G = adapted_graph$G[adapted_graph$I, adapted_graph$I])
stage2_loc_p_reweighted <- fPCStagewise(
stg2_p = stage2_pvalues, wgtmat = wgtmat,
family = family, corr = corr,
stg1_inthyp_nr = stage1_rejections$stg1_inthyp_nr_idx,
stg2_elemhyp = adapted_graph$I,
stg2_wgtmat = stage2_weight_matrix_reweighted,
test = "dunnett", nthreads = 1)
fPCRej(stg1_loc_p = stage1_loc_p,
stg2_loc_p = stage2_loc_p_reweighted,
stg1_elemhyp_r_idx = stage1_rejections$stg1_elemhyp_r_idx,
stg2_elemhyp_idx = adapted_graph$I,
alpha = alpha, info_frac = 0.5)
Run the code above in your browser using DataLab