# Build a small synthetic power_result without running INLA
syn_summary <- data.frame(
n = rep(c(50, 100, 200), each = 3),
treatment = rep(c(0.2, 0.5, 0.8), 3),
power_direction = c(0.40, 0.65, 0.85,
0.60, 0.82, 0.95,
0.72, 0.90, 0.98),
stringsAsFactors = FALSE
)
syn_result <- list(
summary = syn_summary,
settings = list(effect_name = "treatment")
)
# (a) Uniform weights — assurance is the simple mean of per-cell powers
w_uniform <- c("0.2" = 1/3, "0.5" = 1/3, "0.8" = 1/3)
out <- compute_assurance(syn_result, prior_weights = w_uniform)
print(out)
# (b) Normal design prior centred on a medium-sized effect
out2 <- compute_assurance(
syn_result,
prior_weights = list(dist = "normal", mean = 0.5, sd = 0.2)
)
print(out2)
# (c) Using assurance_prior_weights() to build the weight vector explicitly
w_norm <- assurance_prior_weights(c(0.2, 0.5, 0.8), dist = "normal",
mean = 0.5, sd = 0.2)
out3 <- compute_assurance(syn_result, prior_weights = w_norm)
Run the code above in your browser using DataLab