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)
stage1_pvalues <- c(0.00045, 0.0952, 0.0225, 0.1104)
bounds <- fCERStageBound(
wgtmat, family, corr, alpha = 0.025,
alpha1 = errorSpent(0.5, 0.025, "sfOF"),
info_frac = 0.5, nthreads = 1)
conditional_error_rates <- fCERCer(
stage1_pvalues, wgtmat, family, corr, info_frac = 0.5,
bounds$stg1_bnd, bounds$stg2_bnd, nthreads = 1)
stage2_weight_matrix <- fwgtmat(
w = c(0.5, 0.5),
G = matrix(c(0, 1, 1, 0), 2, 2, byrow = TRUE))
adapted_bounds <- fCERNewBound(
stage1_pvalues, wgtmat, family, corr,
conditional_error_rates$stg1_inthyp_nr_idx,
conditional_error_rates$CER,
stg2_elemhyp_idx = c(2, 4), stage2_weight_matrix,
info_frac_new = 0.4, nthreads = 1)
stage2_cumulative_pvalues <-
1 - pnorm(sqrt(0.4) * qnorm(1 - c(0.0952, 0.1104)) +
sqrt(1 - 0.4) * qnorm(1 - c(0.0299, 0.0586)))
fCERRej(stage2_cumulative_pvalues,
conditional_error_rates$stg1_elemhyp_r_idx,
stg2_elemhyp_idx = c(2, 4),
adapted_bounds$inthyp, adapted_bounds$stg2_bnd_new)
Run the code above in your browser using DataLab