# 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),
power_threshold = c(0.30, 0.55, 0.75,
0.50, 0.72, 0.88,
0.62, 0.80, 0.92),
stringsAsFactors = FALSE
)
syn_result <- list(
summary = syn_summary,
settings = list(effect_name = "treatment")
)
# --- Assurance mode: each metric value IS the assurance target ---
w <- assurance_prior_weights(c(0.2, 0.5, 0.8), dist = "normal",
mean = 0.5, sd = 0.2)
# Find n where direction assurance >= 0.80 AND threshold assurance >= 0.75
rec_assurance <- decide_sample_size(
syn_result,
direction = 0.80,
threshold = 0.75,
prior_weights = w
)
print(rec_assurance)
# --- Conditional mode (backward compatible) ---
rec_cond <- decide_sample_size(syn_result, direction = 0.80)
print(rec_cond)
Run the code above in your browser using DataLab