toxicity_probs <- c(0.05, 0.15, 0.30, 0.45, 0.60)
efficacy_probs <- c(0.20, 0.40, 0.60, 0.70, 0.65)
# Moderate toxicity aversion
w1 <- 0.5 # Base penalty
w2 <- 1.0 # Additional penalty for high toxicity
threshold <- 0.35 # 35% toxicity threshold
utilities <- utility.weighted(
probt = toxicity_probs,
probe = efficacy_probs,
w1 = w1, w2 = w2,
tox.upper = threshold
)
# Display results
dose_comparison <- data.frame(
Dose = 1:5,
Toxicity = toxicity_probs,
Efficacy = efficacy_probs,
Utility = round(utilities, 3),
Exceeds_Threshold = toxicity_probs > threshold
)
print(dose_comparison)
# Identify optimal dose
optimal_dose <- which.max(utilities)
cat("Optimal dose:", optimal_dose,
"with utility:", round(max(utilities), 3), "\n")
Run the code above in your browser using DataLab