# Example of usage for `NextBestNCRMLoss` NextBest class.
# Create the data.
my_data <- Data(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 0, 0, 0, 0, 1, 0),
ID = 1:8,
cohort = c(0, 1, 2, 3, 4, 5, 5, 5),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Initialize the CRM model used to model the data.
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Set-up some MCMC parameters and generate samples from the posterior.
my_options <- McmcOptions(burnin = 100, step = 2, samples = 500)
my_samples <- mcmc(my_data, my_model, my_options)
# Define the rule for dose increments and calculate the maximum dose allowed.
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
next_max_dose <- maxDose(my_increments, data = my_data)
# Define the rule which will be used to select the next best dose
# based on the class `NextBestNCRMLoss`.
nrcm_loss_next_best <- NextBestNCRMLoss(
target = c(0.2, 0.35),
overdose = c(0.35, 0.6),
unacceptable = c(0.6, 1),
max_overdose_prob = 0.999,
losses = c(1, 0, 1, 2)
)
# Calculate the next best dose.
dose_recommendation <- nextBest(
nextBest = nrcm_loss_next_best,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
# Next best dose.
dose_recommendation$value
# Look at the probabilities.
dose_recommendation$probs
# Define another rule (loss function of 3 elements).
nrcm_loss_next_best_losses_3 <- NextBestNCRMLoss(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.30,
losses = c(1, 0, 2)
)
# Calculate the next best dose.
dose_recommendation_losses_3 <- nextBest(
nextBest = nrcm_loss_next_best_losses_3,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
# Next best dose.
dose_recommendation_losses_3$value
# Look at the probabilities.
dose_recommendation_losses_3$probs
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.