| Title: | Object-Oriented Implementation of Dose Escalation Designs |
| Version: | 2.0.0 |
| Description: | Implements a wide range of dose escalation designs. The focus is on model-based designs, ranging from classical and modern continual reassessment methods (CRMs) based on dose-limiting toxicity endpoints to dual-endpoint designs taking into account a biomarker/efficacy outcome. Bayesian inference is performed via MCMC sampling in JAGS, and it is easy to setup a new design with custom JAGS code. However, it is also possible to implement 3+3 designs for comparison or models with non-Bayesian estimation. The whole package is written in a modular form in the S4 class system, making it very flexible for adaptation to new models, escalation or stopping rules. Further details are presented in Sabanes Bove et al. (2019) <doi:10.18637/jss.v089.i10>. |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| URL: | https://github.com/openpharma/crmPack, https://openpharma.github.io/crmPack/ |
| BugReports: | https://github.com/openpharma/crmPack/issues |
| Depends: | ggplot2 (≥ 3.0.0), graphics, R (≥ 4.1.0) |
| Imports: | checkmate (≥ 2.2.0), dplyr, futile.logger, GenSA, gridExtra, kableExtra, knitr, lifecycle, magrittr, methods, mvtnorm, parallel, parallelly, Rdpack, rjags, rlang, survival, tibble, tidyselect (≥ 1.2.0), tools, utils |
| Suggests: | bookdown, broom, covr, data.tree, DiagrammeR, ggmcmc, quarto (≥ 1.4), rmarkdown, stringr, testthat (≥ 3.0.0), tidyr, vdiffr, withr |
| VignetteBuilder: | knitr, quarto |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| Language: | en-US |
| LazyLoad: | yes |
| RoxygenNote: | 7.3.3 |
| RdMacros: | Rdpack |
| Collate: | 'CrmPackClass-class.R' 'CrmPackClass-methods.R' 'Data-validity.R' 'helpers.R' 'Data-class.R' 'helpers_data.R' 'Data-methods.R' 'Rules-validity.R' 'Rules-class.R' 'ModelParams-validity.R' 'ModelParams-class.R' 'Model-validity.R' 'helpers_jags.R' 'Model-class.R' 'Design-validity.R' 'Design-class.R' 'McmcOptions-validity.R' 'McmcOptions-class.R' 'McmcOptions-methods.R' 'Samples-validity.R' 'Samples-class.R' 'logger.R' 'helpers_covr.R' 'mcmc.R' 'Simulations-validity.R' 'Simulations-class.R' 'helpers_broom.R' 'helpers_rules.R' 'Model-methods.R' 'checkmate.R' 'Rules-methods.R' 'Design-methods.R' 'fromQuantiles.R' 'Samples-methods.R' 'Simulations-methods.R' 'crmPack-package.R' 'helpers_design.R' 'helpers_knitr.R' 'helpers_knitr_CohortSize.R' 'helpers_knitr_Design.R' 'helpers_knitr_GeneralData.R' 'helpers_knitr_GeneralModel.R' 'helpers_knitr_Increments.R' 'helpers_knitr_NextBest.R' 'helpers_knitr_SafetyWindow.R' 'helpers_knitr_Stopping.R' 'helpers_model.R' 'helpers_samples.R' 'helpers_simulations.R' 'utils-pipe.R' 'utils.R' |
| NeedsCompilation: | no |
| Packaged: | 2025-11-29 07:54:03 UTC; Daniel |
| Author: | Daniel Sabanes Bove [aut, cre],
Wai Yin Yeung [aut],
Burak Kuersad Guenhan [aut],
Giuseppe Palermo [aut],
Thomas Jaki [aut],
Jiawen Zhu [aut],
Ziwei Liao [aut],
Dimitris Kontos [aut],
Marlene Schulte-Goebel [aut],
Doug Kelkhoff |
| Maintainer: | Daniel Sabanes Bove <daniel.sabanes_bove@rconis.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-11-29 13:30:07 UTC |
Object-oriented implementation of CRM designs
Description
Object-oriented implementation of CRM designs
Author(s)
Maintainer: Daniel Sabanes Bove daniel.sabanes_bove@rconis.com
Authors:
Wai Yin Yeung winnie.yeung@roche.com
Burak Kuersad Guenhan burakgunhan@gmail.com
Giuseppe Palermo giuseppe.palermo@roche.com
Thomas Jaki jaki.thomas@gmail.com
Jiawen Zhu zhu.jiawen@gene.com
Ziwei Liao ziwei.liao.fdu@gmail.com
Dimitris Kontos dimitris.kontos@bayer.com
Marlene Schulte-Goebel marlene.schulte-goebel@merckgroup.com
Doug Kelkhoff doug.kelkhoff@gmail.com (ORCID)
Oliver Boix oliver.boix@bayer.com
Robert Adams robert.adams@bayer.com
Clara Beck clara.beck@bayer.com
John Kirkpatrick john@puzzledface.net
Wojciech Wójciak wojciech.wojciak@gmail.com
Guanya Peng
Prerana Chandratre
Other contributors:
F. Hoffmann-La Roche AG [copyright holder, funder]
Merck Healthcare KGaA [copyright holder, funder]
Bayer AG [copyright holder, funder]
RPACT GmbH [copyright holder, funder]
References
Sabanés Bové D, Yeung WY, Palermo G, Jaki T (2019). “Model-Based Dose Escalation Designs in R with crmPack.” Journal of Statistical Software, 89(10), 1–22. doi:10.18637/jss.v089.i10.
See Also
Useful links:
Report bugs at https://github.com/openpharma/crmPack/issues
Pipe operator
Description
See magrittr::%>% for details.
Usage
lhs %>% rhs
Arguments
lhs |
A value or the magrittr placeholder. |
rhs |
A function call using the magrittr semantics. |
Value
The result of calling rhs(lhs).
Combine Two Stopping Rules with AND
Description
The method combining two atomic stopping rules.
Usage
## S4 method for signature 'Stopping,Stopping'
e1 & e2
Arguments
e1 |
( |
e2 |
( |
Value
The StoppingAll object.
Examples
## Example of combining two atomic stopping rules with an AND ('&') operator
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
myStopping <- myStopping1 & myStopping2
Combine an Atomic Stopping Rule and a Stopping List with AND
Description
The method combining an atomic stopping rule and a stopping list.
Usage
## S4 method for signature 'Stopping,StoppingAll'
e1 & e2
Arguments
e1 |
( |
e2 |
( |
Value
The modified StoppingAll object.
Examples
## Example of combining an atomic stopping rule with a list of stopping rules
## with an AND ('&') operator
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
myStopping3 <- StoppingMinPatients(nPatients = 20)
myStopping <- myStopping3 & (myStopping1 | myStopping2)
Combine a Stopping List and an Atomic Stopping Rule with AND
Description
The method combining a stopping list and an atomic stopping rule.
Usage
## S4 method for signature 'StoppingAll,Stopping'
e1 & e2
Arguments
e1 |
( |
e2 |
( |
Value
The modified StoppingAll object.
Examples
## Example of combining a list of stopping rules with an atomic stopping rule
## with an AND ('&') operator
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
myStopping3 <- StoppingMinPatients(nPatients = 20)
myStopping <- (myStopping1 | myStopping2) & myStopping3
CohortSize
Description
CohortSize is a class for cohort sizes.
Usage
.DefaultCohortSize()
.DefaultCohortSize()
Note
Typically, end users will not use the DefaultCohortSize() function.
Typically, end users will not use the DefaultCohortSize() function.
See Also
CohortSizeRange, CohortSizeDLT, CohortSizeConst,
CohortSizeParts, CohortSizeMin, CohortSizeMin.
CohortSizeConst
Description
CohortSizeConst is the class for fixed and constant size of cohort.
Usage
CohortSizeConst(size)
.DefaultCohortSizeConst()
Arguments
size |
( |
Slots
size(
integer)
cohort size.
Note
Typically, end users will not use the .DefaultCohortSizeConst() function.
Examples
# Cohort of size 3, constant along the study.
my_size <- CohortSizeConst(size = 3)
CohortSizeDLT
Description
CohortSizeDLT is the class for cohort size based on number of DLTs.
Usage
CohortSizeDLT(intervals, cohort_size)
.DefaultCohortSizeDLT()
Arguments
intervals |
( |
cohort_size |
( |
Slots
intervals(
integer)
a vector with the left bounds of the relevant DLT intervals.cohort_size(
integer)
a vector with the cohort sizes corresponding to the elements ofintervals.
Note
Typically, end users will not use the .DefaultCohortSizeDLT() function.
Examples
# Rule for having cohort of size 1 until no DLT is observed and having cohort
# of size 3 as soon as 1 DLT is observed.
my_size <- CohortSizeDLT(intervals = c(0, 1), cohort_size = c(1, 3))
CohortSizeMax
Description
CohortSizeMax is the class for cohort size that is based on maximum of
multiple cohort size rules. The cohort_sizes slot stores a set of cohort
size rules, which are again the objects of class CohortSize. The maximum
of these individual cohort sizes is taken to give the final cohort size.
Usage
.DefaultCohortSizeMax()
CohortSizeMax(cohort_sizes)
Arguments
cohort_sizes |
( |
Slots
cohort_sizes(
list)
a list of cohort size rules, i.e. objects of classCohortSize.
Note
Typically, end users will not use the .DefaultCohortSizeMax() function.
Examples
# Rule for cohort of size 1 for doses <30 and cohort of size 3 for doses >=30.
my_size1 <- CohortSizeRange(intervals = c(0, 10), cohort_size = c(1, 3))
# Rule for cohort of size 1 until no DLT were observed and cohort of size 3
# as soon as 1 DLT is observed.
my_size2 <- CohortSizeDLT(intervals = c(0, 1), cohort_size = c(1, 3))
# Cohort size rules of class 'CohortSizeMax' which will then be combined with
# the 'max' operation.
mySize <- CohortSizeMax(cohort_sizes = list(my_size1, my_size2))
CohortSizeMin
Description
CohortSizeMin is the class for cohort size that is based on minimum of
multiple cohort size rules. The cohort_sizes slot stores a set of cohort
size rules, which are again the objects of class CohortSize. The minimum
of these individual cohort sizes is taken to give the final cohort size.
Usage
CohortSizeMin(cohort_sizes)
.DefaultCohortSizeMin()
Arguments
cohort_sizes |
( |
Slots
cohort_sizes(
list)
a list of cohort size rules, i.e. objects of classCohortSize.
Note
Typically, end users will not use the .DefaultCohortSizeMin() function.
Examples
# Rule for cohort of size 1 for doses <30 and cohort of size 3 for doses >=30.
my_size1 <- CohortSizeRange(intervals = c(0, 10), cohort_size = c(1, 3))
# Rule for cohort of size 1 until no DLT were observed and cohort of size 3
# as soon as 1 DLT is observed.
my_size2 <- CohortSizeDLT(intervals = c(0, 1), cohort_size = c(1, 3))
# Cohort size rules of class 'CohortSizeMin' which will then be combined with
# the 'min' operation.
my_size <- CohortSizeMin(cohort_sizes = list(my_size1, my_size2))
CohortSizeOrdinal
Description
CohortSizeOrdinal is the class for cohort size for an ordinal CRM trial.
Usage
CohortSizeOrdinal(grade, rule)
.DefaultCohortSizeOrdinal()
Arguments
grade |
( |
rule |
( |
Slots
grade(
integer)
the grade at which the rule should be appliedrule(
CohortSize)
theCohortSizerule to apply.
Note
Typically, end users will not use the .DefaultCohortSizeOrdinal() function.
Examples
CohortSizeOrdinal(
grade = 1L,
rule = CohortSizeRange(intervals = c(0, 30), cohort_size = c(1L, 3L))
)
CohortSizeParts
Description
CohortSizeParts is the class for cohort size that changes for the second
part of the dose escalation. It works only in conjunction with DataParts
objects.
Usage
CohortSizeParts(cohort_sizes)
.DefaultCohortSizeParts()
Arguments
cohort_sizes |
( |
Slots
cohort_sizes(
integer)
a vector of length two with two sizes, one for part 1, and one for part 2 respectively.
Note
Typically, end users will not use the .DefaultCohortSizeParts() function.
Examples
# Part 1 cohort size = 1, Part 2 cohort size = 3.
my_size <- CohortSizeParts(cohort_sizes = c(1, 3))
CohortSizeRange
Description
CohortSizeRange is the class for cohort size based on dose range.
Usage
CohortSizeRange(intervals, cohort_size)
.DefaultCohortSizeRange()
Arguments
intervals |
( |
cohort_size |
( |
Slots
intervals(
numeric)
a vector with the left bounds of the relevant dose intervals.cohort_size(
integer)
an integer vector with the cohort sizes corresponding to the elements ofintervals.
Note
Typically, end users will not use the .DefaultCohortSizeRange() function.
Examples
# Example for the rule having cohort of size 1 for doses <30
# and having cohort of size 3 for doses >=30.
my_size <- CohortSizeRange(intervals = c(0, 30), cohort_size = c(1, 3))
CrmPackClass
Description
CrmPackClass is a virtual class, from which all other crmPack classes
inherit.
DADesign
Description
This class has special requirements for the model and data
slots in comparison to the parent class Design:
Usage
DADesign(model, data, safetyWindow, ...)
.DefaultDADesign()
Arguments
model |
( |
data |
( |
safetyWindow |
( |
... |
Arguments passed on to
|
Details
The safetyWindow slot should be an instance of the SafetyWindow class.
It can be customized to specify the duration of the safety window for your trial.
The safety window represents the time period required to observe toxicity data
from the ongoing cohort before opening the next cohort.
Note that even after opening the next cohort,
further toxicity data will be collected and analyzed to make dose escalation decisions.
To specify a constant safety window, use the SafetyWindowConst constructor. For example:
mysafetywindow <- SafetyWindowConst(c(6, 2), 10, 20)
Slots
model(
GeneralModel)
the model to use, see in particularDALogisticLogNormalandTITELogisticLogNormalwhich make use of the time-to-DLT data.data(
DataDA)
what is the dose grid, any previous data, etc.safetyWindow(
SafetyWindow)
the safety window to apply between cohorts.
Note
Typically, end users will not use the .DefaultDADesign() function.
See Also
SafetyWindowConst for creating a constant safety window.
Examples
empty_data <- DataDA(
doseGrid = c(
0.1,
0.5,
1,
1.5,
3,
6,
seq(from = 10, to = 80, by = 2)
),
Tmax = 60
)
npiece <- 10
t_max <- 60
lambda_prior <- function(k) {
npiece / (t_max * (npiece - k + 0.5))
}
model <- DALogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56,
npiece = npiece,
l = as.numeric(t(apply(as.matrix(c(1:npiece), 1, npiece), 2, lambda_prior))),
c_par = 2
)
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
my_next_best <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
my_size1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
my_size2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
my_size <- maxSize(my_size1, my_size2)
my_stopping1 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
my_stopping2 <- StoppingMinPatients(nPatients = 50)
my_stopping <- (my_stopping1 | my_stopping2)
my_safety_window <- SafetyWindowConst(c(6, 2), 7, 7)
design <- DADesign(
model = model,
increments = my_increments,
nextBest = my_next_best,
stopping = my_stopping,
cohort_size = my_size,
data = empty_data,
safetyWindow = my_safety_window,
startingDose = 3
)
DALogisticLogNormal
Description
DALogisticLogNormal is the class for the logistic model with bivariate
(log) normal prior and data augmentation. This class inherits from the
LogisticLogNormal class.
Usage
DALogisticLogNormal(npiece = 3, l, c_par = 2, cond_pem = TRUE, ...)
.DefaultDALogisticLogNormal()
Arguments
npiece |
( |
l |
( |
c_par |
( |
cond_pem |
( |
... |
Arguments passed on to
|
Slots
npiece(
number)
the number of pieces in thePEM.l(
numeric)
a vector used in the lambda prior.c_par(
numeric)
a parameter used in the lambda prior; according to Liu's paper,c_par = 2is recommended.cond_pem(
flag)
is a conditional piecewise-exponential model used? (default). Otherwise an unconditional model is used.
Note
We still need to include here formula for the lambda prior.
Typically, end users will not use the .DefaultDALogisticLogNormal() function.
See Also
ModelLogNormal, LogisticNormal, LogisticLogNormal.
Examples
npiece <- 10
Tmax <- 60 # nolintr
lambda_prior <- function(k) {
npiece / (Tmax * (npiece - k + 0.5))
}
model <- DALogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56,
npiece = npiece,
l = as.numeric(t(apply(as.matrix(c(1:npiece), 1, npiece), 2, lambda_prior))),
c_par = 2
)
DASimulations
Description
This class captures the trial simulations from DA based designs.
In comparison to the parent class Simulations,
it contains additional slots to capture the time to DLT fits, additional
parameters and the trial duration.
Usage
DASimulations(trial_duration, ...)
.DefaultDASimulations()
Arguments
trial_duration |
( |
... |
additional parameters from |
Slots
trial_duration(
numeric)
the vector of trial duration values for all simulations.
Note
Typically, end users will not use the .DefaultDASimulations() function.
Likelihood of DLTs in each interval
Description
This is a helper function for the fitPEM methods below.
Usage
DLTLikelihood(lambda, Tmax)
Arguments
lambda |
the vector of piecewise hazards |
Tmax |
the end of the time interval for DLTs |
Value
vector with the probabilities for DLTs within the intervals.
Data
Description
Data is a class for the data input.
It inherits from GeneralData.
Usage
Data(
x = numeric(),
y = integer(),
ID = integer(),
cohort = integer(),
doseGrid = numeric(),
placebo = FALSE,
...
)
.DefaultData()
Arguments
x |
( |
y |
( |
ID |
( |
cohort |
( |
doseGrid |
( |
placebo |
( |
... |
not used. |
Details
The cohort can be missing if and only if placebo is equal to
FALSE.
Slots
x(
numeric)
the doses for the patients.y(
integer)
the vector of toxicity events (0 or 1 integers).doseGrid(
numeric)
the vector of all possible doses (sorted), i.e. the dose grid.nGrid(
integer)
number of gridpoints.xLevel(
integer)
the levels for the doses the patients have been given, w.r.tdoseGrid.placebo(
logical)
ifTRUEthe first dose level in thedoseGridis considered as PLACEBO.
Note
ID and cohort can be missing. Then a message will be issued
and the variables will be filled with default IDs and best guesses cohort,
i.e. a sorted (in ascending order) sequence of values from {1, 2, ...}.
Typically, end users will not use the .DefaultData() function.
Examples
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 = as.integer(1:8),
cohort = as.integer(c(1, 2, 3, 4, 5, 6, 6, 6)),
doseGrid = c(
0.1,
0.5,
1.5,
3,
6,
seq(from = 10, to = 80, by = 2)
)
)
my_data
DataDA
Description
DataDA is a class for the time-to-DLT augmented data.
It inherits from Data and it contains additional DLT free survival times.
Usage
DataDA(
u = numeric(),
t0 = numeric(length(u)),
Tmax = 0 + .Machine$double.xmin,
...
)
.DefaultDataDA()
Arguments
u |
( |
t0 |
( |
Tmax |
( |
... |
parameters passed to |
Slots
u(
numeric)
the continuous vector of DLT free survival times.t0(
numeric)
time of initial dosing for each patient. Non-negative values sorted in ascending order.Tmax(
number)
the DLT observation period.
Note
survival time here refers to the time period for which the subject
did not experience any DLT, and is not referring to deaths.
Typically, end users will not use the .DefaultDataDA() function.
Examples
my_data <- DataDA(
u = c(42, 30, 15, 5, 20, 25, 30, 60),
t0 = c(0, 15, 30, 40, 55, 70, 75, 85),
Tmax = 60,
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 1, 1, 0, 0, 1, 0),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Set up an empty data set.
empty_data <- DataDA(
doseGrid = c(0.1, 0.5, 1, 1.5, 3, 6, seq(from = 10, to = 80, by = 2)),
Tmax = 60
)
empty_data
DataDual
Description
DataDual is a class for the dual endpoint data.
It inherits from Data and it contains additional biomarker information.
Usage
DataDual(w = numeric(), ...)
.DefaultDataDual()
Arguments
w |
( |
... |
parameters passed to |
Slots
w(
numeric)
the continuous vector of biomarker values.
Note
Typically, end users will not use the .DefaultDataDual() function.
Examples
my_data <- DataDual(
w = rnorm(8),
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 0, 0, 0, 0, 1, 0),
doseGrid = c(
0.1,
0.5,
1.5,
3,
6,
seq(from = 10, to = 80, by = 2)
)
)
my_data
DataGrouped
Description
DataGrouped is a class for a two groups dose escalation data set,
comprised of a monotherapy (mono) and a combination therapy (combo)
arm. It inherits from Data and it contains the additional group information.
Usage
DataGrouped(group = character(), ...)
.DefaultDataGrouped()
Arguments
group |
( |
... |
parameters passed to |
Slots
group(
factor)
whethermonoorcombowas used.
Note
Typically, end users will not use the .DefaultDataGrouped() function.
Examples
my_data <- DataGrouped(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 1, 1, 0, 0, 1, 0),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2)),
group = c("mono", "mono", "mono", "mono", "mono", "mono", "combo", "combo")
)
# Set up an empty data set.
empty_data <- DataGrouped(
doseGrid = c(0.1, 0.5, 1, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
empty_data
DataMixture
Description
DataMixture is a class for the data with mixture sharing.
It inherits from Data and it contains additional information
on the mixture sharing.
Usage
DataMixture(xshare = numeric(), yshare = integer(), ...)
.DefaultDataMixture()
Arguments
xshare |
( |
yshare |
( |
... |
parameters passed to |
Slots
xshare(
numeric)
the doses for the share patients.yshare(
integer)
the vector of toxicity events (0 or 1) for the share patients.nObsshare(
count)
number of share patients.
Note
Typically, end users will not use the .DefaultDataMixture() function.
Examples
my_data <- DataMixture(
xshare = c(12, 14, 16, 18.0),
yshare = c(0L, 1L, 1L, 1L),
nObsshare = 4L,
x = c(0.1, 0.5, 1.5),
y = c(0, 0, 0),
ID = 1:3,
cohort = 1:3,
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
my_data
DataOrdinal
Description
DataOrdinal is a class for ordinal toxicity data.
It inherits from GeneralData and it describes toxicity responses on an
ordinal rather than binary scale.
Usage
DataOrdinal(
x = numeric(),
y = integer(),
ID = integer(),
cohort = integer(),
doseGrid = numeric(),
placebo = FALSE,
yCategories = c(`No DLT` = 0L, DLT = 1L),
...
)
.DefaultDataOrdinal()
Arguments
x |
( |
y |
( |
ID |
( |
cohort |
( |
doseGrid |
( |
placebo |
( |
yCategories |
(named |
... |
not used. |
Details
The cohort can be missing if and only if placebo is equal to
FALSE.
Note
This class has been implemented as a sibling of the existing Data class
(rather than as a parent or child) to minimise the risk of unintended side
effects on existing classes and methods.
The default setting for the yCategories slot replicates the behaviour
of the existing Data class.
Typically, end users will not use the .DefaultDataOrdinal() function.
Examples
DataOrdinal(
x = c(10, 20, 30, 40, 50, 50, 50, 60, 60, 60),
y = as.integer(c(0, 0, 0, 0, 0, 1, 0, 0, 1, 2)),
ID = 1L:10L,
cohort = as.integer(c(1:4, 5, 5, 5, 6, 6, 6)),
doseGrid = c(seq(from = 10, to = 100, by = 10)),
yCategories = c("No tox" = 0L, "Sub-tox AE" = 1L, "DLT" = 2L),
placebo = FALSE
)
DataParts
Description
DataParts is a class for the data with two study parts.
It inherits from Data and it contains additional information
on the two study parts.
Usage
DataParts(part = integer(), nextPart = 1L, part1Ladder = numeric(), ...)
.DefaultDataParts()
Arguments
part |
( |
nextPart |
( |
part1Ladder |
( |
... |
parameters passed to |
Slots
part(
integer)
which part does each of the patients belong to?nextPart(
count)
what is the part for the next cohort (1 or 2)?part1Ladder(
numeric)
what is the escalation ladder for part 1? This shall be an ordered subset of thedoseGrid.
Note
Typically, end users will not use the .DefaultDataParts() function.
Examples
my_data <- DataParts(
x = c(0.1, 0.5, 1.5),
y = c(0, 0, 0),
ID = 1:3,
cohort = 1:3,
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2)),
part = c(1L, 1L, 1L),
nextPart = 1L,
part1Ladder = c(0.1, 0.5, 1.5, 3, 6, 10)
)
my_data
Design
Description
Design is the class for rule-based designs. The difference between
this class and its parent RuleDesign class is that Design class
contains additional model, stopping and increments slots.
Usage
Design(model, stopping, increments, pl_cohort_size = CohortSizeConst(0L), ...)
.DefaultDesign()
Arguments
model |
( |
stopping |
( |
increments |
( |
pl_cohort_size |
( |
... |
Arguments passed on to
|
Slots
model(
GeneralModel)
the model to be used.stopping(
Stopping)
stopping rule(s) for the trial.increments(
Increments)
how to control increments between dose levels.pl_cohort_size(
CohortSize)
rules for the cohort sizes for placebo, if any planned (defaults to constant 0 placebo patients).
Note
Typically, end users will not use the .DefaultDesign() function.
Examples
empty_data <- Data(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Initialize the CRM model.
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Choose the rule for selecting the next dose.
my_next_best <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size.
my_size1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
my_size2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
my_size <- maxSize(my_size1, my_size2)
# Choose the rule for stopping.
my_stopping1 <- StoppingMinCohorts(nCohorts = 3)
my_stopping2 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
my_stopping3 <- StoppingMinPatients(nPatients = 20)
my_stopping <- (my_stopping1 & my_stopping2) | my_stopping3
# Choose the rule for dose increments.
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design.
design <- Design(
model = my_model,
nextBest = my_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = empty_data,
startingDose = 3
)
DesignGrouped
Description
DesignGrouped combines two Design objects: one for the mono and one
for the combo arm of a joint dose escalation design.
Usage
DesignGrouped(
model,
mono,
combo = mono,
first_cohort_mono_only = TRUE,
same_dose_for_all = !same_dose_for_start,
same_dose_for_start = FALSE,
stop_mono_with_combo = FALSE,
...
)
Arguments
model |
( |
mono |
( |
combo |
( |
first_cohort_mono_only |
( |
same_dose_for_all |
( |
same_dose_for_start |
( |
stop_mono_with_combo |
( |
... |
not used. |
Details
Note that the model slots inside the
monoandcomboparameters are ignored (because we don't fit separate regression models for the mono and combo arms). Instead, themodelparameter is used to fit a joint regression model for the mono and combo arms together.-
same_dose_for_start = TRUEis useful as an option when we want to usesame_dose_for_all = FALSEcombined withfirst_cohort_mono_only = TRUE. This will allow to randomize patients to the mono and combo arms at the same dose as long as the selected dose for the cohorts stay the same. This can therefore further mitigate bias as long as possible between the mono and combo arms.
Slots
model(
LogisticLogNormalGrouped)
the model to be used, currently only one class is allowed.mono(
Design)
defines the dose escalation rules for the mono arm, see details.combo(
Design)
defines the dose escalation rules for the combo arm, see details.first_cohort_mono_only(
flag)
whether first test one mono agent cohort, and then once its DLT data has been collected, we proceed from the second cohort onwards with concurrent mono and combo cohorts.same_dose_for_all(
flag)
whether the lower dose of the separately determined mono and combo doses should be used as the next dose for both mono and combo in all cohorts.same_dose_for_start(
flag)
indicates whether, when mono and combo are used in the same cohort for the first time, the same dose should be used for both. Note that this is different fromsame_dose_for_allwhich will always force them to be the same. Ifsame_dose_for_all = TRUE, this is therefore ignored. See Details.
Note
Typically, end-users will not use the .DefaultDesignGrouped() function.
Examples
empty_data <- Data(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Initialize the joint model.
my_model <- LogisticLogNormalGrouped(
mean = c(-0.85, 0, 1, 0),
cov = diag(1, 4),
ref_dose = 56
)
# Choose the rule for selecting the next dose.
my_next_best <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size.
my_size1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
my_size2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
my_size <- maxSize(my_size1, my_size2)
# Choose the rule for stopping.
my_stopping1 <- StoppingMinCohorts(nCohorts = 3)
my_stopping2 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
my_stopping3 <- StoppingMinPatients(nPatients = 20)
my_stopping <- (my_stopping1 & my_stopping2) | my_stopping3
# Choose the rule for dose increments.
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Rules to be used for both arms.
one_arm <- Design(
model = .DefaultModelLogNormal(), # Ignored.
nextBest = my_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = empty_data,
startingDose = 3
)
# Initialize the design.
design <- DesignGrouped(
model = my_model,
mono = one_arm
)
# Alternative options: Here e.g.
# - use both mono in first cohort and afterwards have mono and combo in parallel,
# - in general allow different dose levels for the cohorts,
# - but for the start (i.e. second cohort) have the same dose for mono and combo.
# - Stop mono arm too, when combo arm is stopped.
design2 <- DesignGrouped(
model = my_model,
mono = one_arm,
first_cohort_mono_only = TRUE,
same_dose_for_all = FALSE,
same_dose_for_start = TRUE,
stop_mono_with_combo = TRUE
)
DesignOrdinal
Description
DesignOrdinal is the class for rule-based ordinal designs. The difference
between this class and its parent RuleDesignOrdinal class is that the
DesignOrdinal class contains additional model, stopping,
increments and pl_cohort_size slots.
Usage
DesignOrdinal(
model,
stopping,
increments,
pl_cohort_size = CohortSizeOrdinal(1L, CohortSizeConst(0L)),
...
)
.DefaultDesignOrdinal()
Arguments
model |
( |
stopping |
( |
increments |
( |
pl_cohort_size |
( |
... |
Arguments passed on to
|
Details
Please note that stopping, increments or cohort size rules need to be wrapped into
the corresponding StoppingOrdinal, IncrementsOrdinal or CohortSizeOrdinal classes, before
a successful evaluation of the corresponding methods can take place.
Note also that these wrappers cannot be nested, i.e., you cannot have an IncrementsOrdinal inside
another IncrementsOrdinal (which also would not make sense) because it would not be clear which
event grade to use for the methods calculation.
However, multiple rules can be combined using the operators defined for these classes, e.g.,
StoppingOrdinal(1L, rule1 & rule2) | StoppingOrdinal(2L, rule3).
Slots
model(
LogisticLogNormalOrdinal)
the model to be used.stopping(
Stopping)
stopping rule(s) for the trial.increments(
Increments)
how to control increments between dose levels.pl_cohort_size(
CohortSize)
rules for the cohort sizes for placebo, if any planned (defaults to constant 0 placebo patients).
Note
Typically, end users will not use the .DefaultDesignOrdinal() function.
Examples
my_size1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
my_size2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
my_size <- CohortSizeOrdinal(1L, maxSize(my_size1, my_size2))
my_stopping1 <- StoppingMinCohorts(nCohorts = 3)
my_stopping2 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
my_stopping3 <- StoppingMinPatients(nPatients = 20)
my_stopping <- StoppingOrdinal(1L, (my_stopping1 & my_stopping2) | my_stopping3)
# Initialize the design.
design <- DesignOrdinal(
model = LogisticLogNormalOrdinal(
mean = c(-3, -4, 1),
cov = diag(c(3, 4, 1)),
ref_dose = 50
),
next_best = NextBestOrdinal(
1L,
NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
),
stopping = my_stopping,
increments = IncrementsOrdinal(
1L,
IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
),
cohort_size = my_size,
data = DataOrdinal(
doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100),
yCategories = c("No tox" = 0L, "Sub-tox AE" = 1L, "DLT" = 2L)
),
starting_dose = 3
)
DualDesign
Description
DualDesign is the class for the dual-endpoint CRM design. This class has
special requirements for the model and data slots in comparison to the
parent class Design.
Usage
DualDesign(model, data, ...)
.DefaultDualDesign()
Arguments
model |
( |
data |
( |
... |
Arguments passed on to
|
Slots
model(
DualEndpoint)
the model to be used.data(
DataDual)
specifies dose grid, any previous data, etc.
Note
the nextBest slot can be of any class, this allows for easy comparison
with recommendation methods that don't use the biomarker information.
Typically, end users will not use the .DefaultDualDesign() function.
Examples
empty_data <- DataDual(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Initialize the CRM model.
my_model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# Choose the rule for selecting the next dose.
my_next_best <- NextBestDualEndpoint(
target = c(0.9, 1),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size.
my_size1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
my_size2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
my_size <- maxSize(my_size1, my_size2)
# Choose the rule for stopping.
my_stopping1 <- StoppingTargetBiomarker(
target = c(0.9, 1),
prob = 0.5
)
my_stopping <- my_stopping1 | StoppingMinPatients(40)
# Choose the rule for dose increments.
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design.
design <- DualDesign(
model = my_model,
data = empty_data,
nextBest = my_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
startingDose = 3
)
DualEndpoint
Description
DualEndpoint is the general class for the dual endpoint model.
Usage
DualEndpoint(mean, cov, ref_dose = 1, use_log_dose = FALSE, sigma2W, rho)
.DefaultDualEndpoint()
Arguments
mean |
( |
cov |
( |
ref_dose |
( |
use_log_dose |
( |
sigma2W |
( |
rho |
( |
Details
The idea of the dual-endpoint models is to model not only the dose-toxicity relationship, but also to model, at the same time, the relationship of a PD biomarker with the dose. The sub-classes of this class define how the dose-biomarker relationship is parametrized. This class here shall contain all the common features to reduce duplicate code. (This class however, must not be virtual as we need to create objects of it during the construction of subclass objects.)
The dose-toxicity relationship is modeled with probit regression model
probit[p(x)] = betaZ1 + betaZ2 * x/x*,
or
probit[p(x)] = betaZ1 + betaZ2 * log(x/x*),
in case when the option use_log_dose is TRUE.
Here, p(x) is the probability of observing a DLT for a given
dose x and x* is the reference dose.
The prior
(betaZ1, log(betaZ2)) ~ Normal(mean, cov).
For the biomarker response w at a dose x, we assume
w(x) ~ Normal(f(x), sigma2W),
where f(x) is a function of the dose x, which is further
specified in sub-classes. The biomarker variance sigma2W can be fixed
or assigned an Inverse-Gamma prior distribution; see the details below under
slot sigma2W.
Finally, the two endpoints y (the binary DLT variable) and w
(the biomarker) can be correlated, by assuming a correlation of level
rho between the underlying continuous latent toxicity variable z
and the biomarker w. Again, this correlation can be fixed or assigned
a prior distribution from the scaled Beta family; see the details below
under slot rho.
Please see the example vignette by typing crmPackExample() for a full example.
Slots
betaZ_params(
ModelParamsNormal)
for the probit toxicity model, it contains the prior mean, covariance matrix and precision matrix which is internally calculated as an inverse of the covariance matrix.ref_dose(
positive_number)
for the probit toxicity model, the reference dose.use_log_dose(
flag)
for the probit toxicity model, whether a log transformation of the (standardized) dose should be used?sigma2W(
numeric)
the biomarker variance. Either a fixed value or Inverse-Gamma distribution parameters, i.e. vector with two elements namedaandb.rho(
numeric)
either a fixed value for the correlation (between-1and1), or a named vector with two elements namedaandbfor the Beta prior on the transformationkappa = (rho + 1) / 2, which is in(0, 1). For example,a = 1, b = 1leads to a uniform prior onrho.use_fixed(
logical)
indicates whether a fixed value forsigma2Worrho(for each parameter separately) is used or not. This slot is needed for internal purposes and must not be touched by the user.
Note
Typically, end users will not use the .DefaultDualEndpoint() function.
See Also
DualEndpointRW, DualEndpointBeta, DualEndpointEmax.
DualEndpointBeta
Description
DualEndpointBeta is the class for the dual endpoint model with beta
function for dose-biomarker relationship.
Usage
DualEndpointBeta(E0, Emax, delta1, mode, ref_dose_beta = 1, ...)
.DefaultDualEndpointBeta()
Arguments
E0 |
( |
Emax |
( |
delta1 |
( |
mode |
( |
ref_dose_beta |
( |
... |
parameters passed to |
Details
This class extends the DualEndpoint class so that the dose-biomarker
relationship f(x) is modelled by a parametric, rescaled beta density
function:
f(x) = E0 + (Emax - E0) * Beta(delta1, delta2) * (x/x*)^{delta1} * (1 - x/x*)^{delta2},
where x* is the maximum dose (end of the dose range to be considered),
delta1 and delta2 are the two beta function parameters, and
E0, Emax are the minimum and maximum levels, respectively.
For ease of interpretation, we use the parametrization based on delta1
and the mode, where
mode = delta1 / (delta1 + delta2),
so that multiplying this by x* gives the mode on the dose grid.
All parameters can currently be assigned uniform distributions or be fixed
in advance. Note that E0 and Emax can have negative values or
uniform distributions reaching into negative range, while delta1 and
mode must be positive or have uniform distributions in the positive
range.
Slots
E0(
numeric)
either a fixed number or the two uniform distribution parameters.Emax(
numeric)
either a fixed number or the two uniform distribution parameters.delta1(
numeric)
either a fixed positive number or the two parameters of the uniform distribution, that can take only positive values.mode(
numeric)
either a fixed positive number or the two parameters of the uniform distribution, that can take only positive values.ref_dose_beta(
positive_number)
the reference dosex*(note that this is different from theref_dosein the inheritedDualEndpointmodel).
Note
Typically, end users will not use the .DefaultDualEndpointBeta() function.
See Also
DualEndpoint, DualEndpointRW, DualEndpointEmax.
Examples
my_model <- DualEndpointBeta(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
ref_dose = 10,
use_log_dose = TRUE,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
E0 = c(0, 100),
Emax = c(0, 500),
delta1 = c(0, 5),
mode = c(1, 15),
ref_dose_beta = 1000
)
DualEndpointEmax
Description
DualEndpointEmax is the class for the dual endpoint model with Emax
function for dose-biomarker relationship.
Usage
DualEndpointEmax(E0, Emax, ED50, ref_dose_emax = 1, ...)
.DefaultDualEndpointEmax()
Arguments
E0 |
( |
Emax |
( |
ED50 |
( |
ref_dose_emax |
( |
... |
parameters passed to |
Details
This class extends the DualEndpoint class so that the dose-biomarker
relationship f(x) is modelled by a parametric Emax function:
f(x) = E0 + [(Emax - E0) * (x/x*)]/[ED50 + (x/x*)],
where x* is a reference dose, E0 and Emax are the minimum
and maximum levels for the biomarker, and ED50 is the dose achieving
half of the maximum effect 0.5 * Emax.
All parameters can currently be assigned uniform distributions or be fixed.
Slots
E0(
numeric)
either a fixed number or the two uniform distribution parameters.Emax(
numeric)
either a fixed number or the two uniform distribution parameters.ED50(
numeric)
either a fixed number or the two uniform distribution parameters.ref_dose_emax(
positive_number)
the reference dosex*(note that this is different from theref_dosein the inheritedDualEndpointmodel).
Note
Typically, end users will not use the .DefaultDualEndpointEmax() function.
See Also
DualEndpoint, DualEndpointRW, DualEndpointBeta.
Examples
my_model <- DualEndpointEmax(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
E0 = c(0, 100),
Emax = c(0, 500),
ED50 = c(10, 200),
ref_dose_emax = 1000
)
DualEndpointRW
Description
DualEndpointRW is the class for the dual endpoint model with random walk
prior for biomarker.
Usage
DualEndpointRW(sigma2betaW, rw1 = TRUE, ...)
.DefaultDualEndpointRW()
Arguments
sigma2betaW |
( |
rw1 |
( |
... |
parameters passed to |
Details
This class extends the DualEndpoint class so that the dose-biomarker
relationship f(x) is modelled by a non-parametric random walk of first
or second order. That means, for the first order random walk we assume
betaW_i - betaW_i-1 ~ Normal(0, (x_i - x_i-1) * sigma2betaW),
where betaW_i = f(x_i) is the biomarker mean at the i-th dose
gridpoint x_i.
For the second order random walk, the second-order differences instead of
the first-order differences of the biomarker means follow the normal distribution
with 0 mean and 2 * (x_i - x_i-2) * sigma2betaW variance.
The variance parameter sigma2betaW is important because it steers the
smoothness of the function f(x), i.e.: if it is large, then f(x)
will be very wiggly; if it is small, then f(x) will be smooth.
This parameter can either be a fixed value or assigned an inverse gamma prior
distribution.
Slots
sigma2betaW(
numeric)
the prior variance factor of the random walk prior for the biomarker model. Either a fixed value or Inverse-Gamma distribution parameters, i.e. vector with two elements namedaandb.rw1(
flag)
for specifying the random walk prior on the biomarker level. WhenTRUE, random walk of first order is used. Otherwise, the random walk of second order is used.
Note
Non-equidistant dose grids can be used now, because the difference
x_i - x_i-1 is included in the modelling assumption above.
Please note that due to impropriety of the random walk prior distributions,
it is not possible to produce MCMC samples with empty data objects (i.e.,
sample from the prior). This is not a bug, but a theoretical feature of this
model.
Typically, end users will not use the .DefaultDualEndpointRW() function.
See Also
DualEndpoint, DualEndpointBeta, DualEndpointEmax.
Examples
my_model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
sigma2betaW = 0.01,
rw1 = TRUE
)
DualResponsesDesign.R
Description
This is a class of design based on DLE responses using the LogisticIndepBeta model
without DLE and efficacy samples. It contains all slots from the
RuleDesign and TDsamplesDesign classes.
Usage
DualResponsesDesign(eff_model, data, ...)
.DefaultDualResponsesDesign()
Arguments
eff_model |
( |
data |
( |
... |
Arguments passed on to
|
Slots
data(
DataDual)
the data set.eff_model(
ModelEff)
the pseudo efficacy model to be used.
Note
Typically, end users will not use the .DefaultDualResponsesDesign() function.
Examples
empty_data <- DataDual(doseGrid = seq(25, 300, 25))
tox_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = empty_data
)
eff_model <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = empty_data
)
my_next_best <- NextBestMaxGain(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
my_increments <- IncrementsRelative(
intervals = c(25, 300),
increments = c(2, 2)
)
my_size <- CohortSizeConst(size = 3)
my_stopping <- StoppingMinPatients(nPatients = 36)
design <- DualResponsesDesign(
nextBest = my_next_best,
cohort_size = my_size,
startingDose = 25,
model = tox_model,
eff_model = eff_model,
data = empty_data,
stopping = my_stopping,
increments = my_increments
)
DualResponsesSamplesDesign
Description
This is a class of design based on DLE responses using the LogisticIndepBeta model
with DLE and efficacy samples. It contain all slots in
RuleDesign and TDsamplesDesign class objects.
Usage
DualResponsesSamplesDesign(eff_model, data, ...)
.DefaultDualResponsesSamplesDesign()
Arguments
eff_model |
( |
data |
( |
... |
Arguments passed on to
|
Slots
data(
DataDual)
the data set.eff_model(
ModelEff)
the pseudo efficacy model to be used.
Note
Typically, end users will not use the .DefaultDualResponsesSamplesDesign() function.
Examples
empty_data <- DataDual(doseGrid = seq(25, 300, 25))
tox_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = empty_data
)
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
tox_samples <- mcmc(empty_data, tox_model, options)
eff_model <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = empty_data
)
eff_samples <- mcmc(empty_data, eff_model, options)
my_next_best <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
my_increments <- IncrementsRelative(
intervals = c(25, 300),
increments = c(2, 2)
)
my_size <- CohortSizeConst(size = 3)
my_stopping <- StoppingMinPatients(nPatients = 36)
design <- DualResponsesSamplesDesign(
nextBest = my_next_best,
cohort_size = my_size,
startingDose = 25,
model = tox_model,
eff_model = eff_model,
data = empty_data,
stopping = my_stopping,
increments = my_increments
)
DualSimulations
Description
This class captures the trial simulations from dual-endpoint model based
designs. In comparison to the parent class Simulations,
it contains additional slots to capture the dose-biomarker fits, and the
sigma2W and rho estimates.
Usage
DualSimulations(rho_est, sigma2w_est, fit_biomarker, ...)
.DefaultDualSimulations()
Arguments
rho_est |
( |
sigma2w_est |
( |
fit_biomarker |
( |
... |
additional parameters from |
Slots
rho_est(
numeric)
vector of final posterior median rho estimatessigma2w_est(
numeric)
vector of final posterior median sigma2W estimatesfit_biomarker(
list)
with the final dose-biomarker curve fits
Note
Typically, end users will not use the .DefaultDualSimulations() function.
Examples
data_list <- list(
Data(
x = 1:2,
y = 0:1,
doseGrid = 1:2,
ID = 1L:2L,
cohort = 1L:2L
),
Data(
x = 3:4,
y = 0:1,
doseGrid = 3:4,
ID = 1L:2L,
cohort = 1L:2L
)
)
doses <- c(1, 2)
seed <- as.integer(123)
fit <- list(
c(0.1, 0.2),
c(0.3, 0.4)
)
stop_report <- matrix(c(TRUE, FALSE), nrow = 2)
stop_reasons <- list("A", "B")
additional_stats <- list(a = 1, b = 1)
dual_simulations_obj <- DualSimulations(
rho_est = c(0.25, 0.35),
sigma2w_est = c(0.15, 0.25),
fit_biomarker = list(c(0.3, 0.4), c(0.4, 0.5)),
fit = fit,
stop_report = stop_report,
stop_reasons = stop_reasons,
additional_stats = additional_stats,
data = data_list,
doses = doses,
seed = seed
)
DualSimulationsSummary
Description
This class captures the summary of dual-endpoint simulations output.
In comparison to its parent class
SimulationsSummary, it has additional slots.
Usage
.DefaultDualSimulationsSummary()
Slots
biomarker_fit_at_dose_most_selected(
numeric)
fitted biomarker level at most often selected dose.mean_biomarker_fit(
list)
list with average, lower (2.5%) and upper (97.5%) quantiles of mean fitted biomarker level at each dose
Note
Typically, end users will not use the .DefaultDualSimulationsSummary() function.
EffFlexi
Description
EffFlexi is the class for the efficacy model in flexible form of prior
expressed in form of pseudo data. In this class, a flexible form is used to
describe the relationship between the efficacy responses and the dose levels
and it is specified as
(W | betaW, sigma2W) ~ Normal(X * betaW, sigma2W * I),
where W is a vector of the efficacy responses, betaW is a column
vector of the mean efficacy responses for all dose levels, and X is
the design matrix with entries I_i,j that are equal to 1 if subject
i is allocated to dose j, and 0 otherwise. The sigma2W
is the variance of the efficacy responses which can be either a fixed number
or a number from an inverse gamma distribution.
This flexible form aims to capture different shapes of the dose-efficacy
curve. In addition, the first (RW1) or second order (RW2) random walk model
can be used for smoothing data. That is the random walk model is used to model
the first or the second order differences of the mean efficacy responses to
its neighboring dose levels of their mean efficacy responses.
The RW1 model is given as
betaW_j - betaW_j-1) ~ Normal(0, sigma2betaW),
and for RW2 as
betaW_j-2 - 2 * betaW_j-1 + beta_j ~ Normal(0, sigma2betaW),
where betaW_j is the vector of mean efficacy responses at dose j, and
the sigma2betaW is the prior variance which can be either a fixed
number or a number from an inverse gamma distribution.
The eff and eff_dose are the pseudo efficacy responses and dose levels at
which these pseudo efficacy responses are observed. Both, eff and eff_dose
must be vectors of length at least 2. The positions of the elements specified
in eff and eff_dose must correspond to each other between these vectors.
Usage
EffFlexi(eff, eff_dose, sigma2W, sigma2betaW, rw1 = TRUE, data)
.DefaultEffFlexi()
Arguments
eff |
( |
eff_dose |
( |
sigma2W |
( |
sigma2betaW |
( |
rw1 |
( |
data |
( |
Details
This model will output the updated value or the updated values of the
parameters of the inverse gamma distributions for sigma2W and
sigma2betaW. The EffFlexi inherits all slots from ModelEff class.
Slots
eff(
numeric)
the pseudo efficacy responses. Each element here must represent responses treated based on one subject. It must be a vector of length at least 2 and the order of its elements must correspond to values specified ineff_dose.eff_dose(
numeric)
the pseudo efficacy dose levels at which the pseudo efficacy responses are observed. It must be a vector of length at least 2 and the order of its elements must correspond to values specified ineff.sigma2W(
numeric)
the prior variance of the flexible efficacy form. This is either a fixed value or a named vector with two positive numbers, the shape (a), and the rate (b) parameters for the gamma distribution.sigma2betaW(
numeric)
the prior variance of the random walk model for the mean efficacy responses. This is either a fixed value or a named vector with two positive numbers, the shape (a), and the rate (b) parameters for the gamma distribution.use_fixed(
logical)
indicates whether a fixed value forsigma2Wandsigma2betaW(for each parameter separately) is used or not. This slot is needed for internal purposes and must not be touched by the user.rw1(
flag)
used for smoothing data for this efficacy model. If it isTRUE, the first-order random walk model is used for the mean efficacy responses. Otherwise, the random walk of second order is used.X(
matrix)
the design matrix for the efficacy responses. It is based on both the pseudo and the observed efficacy responses.RW(
matrix)
the difference matrix for the random walk model. This slot is needed for internal purposes and must not be used by the user.RW_rank(
integer)
is the rank of the difference matrix. This slot is needed for internal purposes and must not be used by the user.
Note
Typically, end users will not use the .DefaultEffFlexi() function.
Examples
# Obtain prior estimates for the efficacy model in flexible form, given the pseudo data.
# First define an empty data set by defining the dose levels used in the study.
# There are 12 dose levels used in the study, ranging from 25 to 300 mg with
# increments of 25.
emptydata <- DataDual(doseGrid = seq(25, 300, 25))
# Define the pseudo data, i.e.: fixed 2 dose levels 25 and 300 mg (`eff_dose`)
# and the efficacy responses 1.223 and 2.513 observed at these two dose levels (`eff`).
# The prior variance of the pseudo efficacy responses can be either a fixed value
# or two parameters for the inverse gamma distribution, the shape (a) and the
# rate (b) (`sigma2W`).
# The prior variance of the random walk model can be either a fixed value or two
# parameters for the inverse gamma distribution, the shape (a) and the rate (b)
# (`sigma2betaW`).
my_model <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = emptydata
)
# Obtain estimates from the model given some observed data is available.
data <- DataDual(
x = c(25, 50, 50, 75, 100, 100, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = emptydata@doseGrid
)
my_model1 <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = data
)
Effloglog
Description
Effloglog is the class for the linear log-log efficacy model using pseudo
data prior. It describes the relationship between continuous efficacy
responses and corresponding dose levels in log-log scale. This efficacy
log-log model is given as
y_i = theta1 + theta2 * log(log(x_i)) + epsilon_i,
where y_i is the efficacy response for subject i, x_i is
the dose level treated for subject i and epsilon_i is the random
error term of efficacy model at subject i. The error term
epsilon_i is a random variable that follows normal distribution with
mean 0 and variance nu^{-1}, which is assumed to be the
same for all subjects.
There are three parameters in this model, the intercept theta1, the
slope theta2 and the precision nu of the efficacy responses, also
known as the inverse of the variance of the pseudo efficacy responses. It can
be a fixed constant or having a gamma distribution. Therefore, a single scalar
value or a vector with two positive numbers values must be specified for nu
slot. If there are some observed efficacy responses available, in the output,
nu will display the updated value of the precision or the updated values
for the parameters of the gamma distribution.
The Effloglog inherits all slots from ModelEff class.
Usage
Effloglog(eff, eff_dose, nu, data, const = 0)
.DefaultEffloglog()
Arguments
eff |
( |
eff_dose |
( |
nu |
( |
data |
( |
const |
( |
Details
The prior of this model is specified in form of pseudo data. First,
at least two dose levels are fixed. Then, using e.g. experts' opinion, the
efficacy values that correspond to these dose levels can be obtained,
The eff and eff_dose arguments represent the prior in form of the pseudo
data. The eff represents the pseudo efficacy values. The eff_dose
represents the dose levels at which these pseudo efficacy values are
observed. Hence, the positions of the elements specified in eff and
eff_dose must correspond to each other between these vectors.
Since at least 2 pseudo efficacy values are needed to obtain modal
estimates of the intercept and slope parameters, both eff and eff_dose
must be vectors of length at least 2.
The joint prior distribution of the intercept theta1 and the slope
theta2 of this model follows bivariate normal distribution with mean
mu and covariance matrix (nu * Q)^{-1}.
The mean mu is a 2 x 1 column vector that contains the prior
modal estimates of the intercept and the slope.
Scalar nu is the precision of the pseudo efficacy responses and
Q is the prior or posterior (given that observed, no DLT data is
available) precision matrix.
It is specified as Q = X0^T * X0 + X^T * X, where X0 is a
design matrix that is based on pseudo dose levels only, and X is a
design matrix that is based on dose levels corresponding to the no DLT
efficacy responses observed only (if any).
Hence, the X0 (or X) will be of size r x 2, if
there are r >= 2 pseudo efficacy responses specified (or
if there are r no DLT efficacy responses observed in the data).
Slots
eff(
numeric)
the pseudo efficacy responses. Each element here must represent responses treated based on one subject. It must be a vector of length at least 2 and the order of its elements must correspond to values specified ineff_dose.eff_dose(
numeric)
the pseudo efficacy dose levels at which the pseudo efficacy responses are observed. It must be a vector of length at least 2 and the order of its elements must correspond to values specified ineff.nu(
numeric)
parameter of the prior precision of pseudo efficacy responses. This is either a fixed value or a named vector with two positive numbers, the shape (a), and the rate (b) parameters for the gamma distribution.use_fixed(
flag)
indicates whethernuspecified is a fixed value or a vector with two parameters for gamma distribution. This slot is for internal purposes only and must not be used by the user.theta1(
number)
the intercept in this efficacy log-log model. This slot is used in output to display the resulting prior or posterior modal estimates obtained based on the pseudo and observed (if any) data.theta2(
number)
the slope in this efficacy log-log model. This slot is used in output to display the resulting prior or posterior modal estimates obtained based on the pseudo and observed (if any) data.Pcov(
matrix)
refers to the2 x 2covariance matrix of the estimators of the intercepttheta1and the slopetheta2parameters in this model. This is used in output to display the resulting prior and posterior covariance matrix oftheta1andtheta2obtained, based on the pseudo and observed (if any) data. This slot is needed for internal purposes.X(
matrix)
is the design matrix that is based on either the pseudo dose levels or observed dose levels (without DLT). This is used in the output to display the design matrix for the pseudo or the observed efficacy responses.Y(
numeric)
is a vector that either contains the pseudo efficacy responses or observed efficacy responses (without DLT).mu(
numeric)
a vector of the prior or the posterior modal estimates of the intercept (theta1) and the slope (theta2). This slot is used in output to display as the mean of the prior or posterior bivariate normal distribution fortheta1andtheta2.Q(
matrix)
is the prior or posterior (given that observed, no DLT data is available) precision matrix. It is specified asQ = X0^T * X0 + X^T * X, whereX0is a design matrix that is based on pseudo dose levels only, andXis a design matrix that is based on dose levels corresponding to the observed, no DLT efficacy values only (if any).const(
number)
a non-negative number (default to 0), leading to the model form described above. In general, the model has the formy_i = theta1 + theta2 * log(log(x_i + const)) + epsilon_i, such that dose levels greater than1 - constcan be considered as described in Yeung et al. (2015).
Note
Typically, end users will not use the .DefaultEffloglog() function.
References
Yeung WY, Whitehead J, Reigner B, Beyer U, Diack C, Jaki T (2015). “Bayesian adaptive dose-escalation procedure for binary and continuous responses utilizing a gain function.” Pharmaceutical Statistics. doi:10.1002/pst.1706, Published online ahead of print.
Examples
# Obtain prior modal estimates given the pseudo data.
# First we use an empty data set such that only the dose levels under
# investigations are given. In total, 12 dose levels are under investigation
# ranging from 25 to 300 mg with increments of 25 (i.e 25, 50, 75, ..., 300).
emptydata <- DataDual(doseGrid = seq(25, 300, 25), placebo = FALSE)
# Define the pseudo data as first by fixing two dose levels 25 and 300 mg (`eff_dose`).
# Then, the efficacy responses observed at these two dose levels are 1.223 and 2.513 (`eff`).
# We specify the prior precision of the pseudo efficacy responses (`nu`) as a vector
# with the shape (a) and the rate (b) parameters for the gamma distribution.
# Obtain modal estimates and other estimates from the model (no observations,
# only pseudo data).
my_model1 <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = emptydata
)
# Observed data.
my_data <- DataDual(
x = c(25, 50, 50, 75, 100, 100, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = emptydata@doseGrid
)
# Obtain posterior modal estimates and other estimates from the model given some
# observed data.
my_model2 <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = my_data
)
FractionalCRM
Description
FractionalCRM is the class for a fractional CRM model based on a one
parameter CRM (with normal prior on the log-power parameter) as well as
Kaplan-Meier based estimation of the conditional probability to experience a
DLT for non-complete observations.
This fractional CRM model follows the paper and code by Yin et al. (2013).
Usage
FractionalCRM(...)
.DefaultFractionalCRM()
Arguments
... |
Arguments passed on to
|
Note
Typically, end users will not use the .DefaultTITELogisticLogNormal() function.
References
Yin G, Zheng S, Xu J (2013). “Fractional dose-finding methods with late-onset toxicity in phase I clinical trials.” Journal of Biopharmaceutical Statistics, 23(4), 856–870. doi:10.1080/10543406.2013.789892.
See Also
Examples
my_model <- FractionalCRM(
skel_probs = c(0.1, 0.2, 0.3, 0.4),
dose_grid = c(10, 30, 50, 100),
sigma2 = 2
)
GeneralData
Description
GeneralData is a class for general data input.
Usage
.DefaultDataGeneral()
Slots
ID(
integer)
unique patient IDs.cohort(
integer)
the cohort (non-negative sorted) indices.nObs(
integer)
number of observations, a single value.
Note
Typically, end users will not use the .DefaultDataGeneral() function.
GeneralModel
Description
GeneralModel is a general model class, from which all other specific
model-like classes inherit.
Usage
.DefaultGeneralModel()
Slots
datamodel(
function)
a function representing theJAGSdata model specification.priormodel(
function)
a function representing theJAGSprior specification.modelspecs(
function)
a function computing the list of the data model and prior model specifications that are required to be specified completely (e.g. prior parameters, reference dose, etc.), based on the data slots that are required as arguments of this function. Apart of data arguments, this function can be specified with one additional (optional) argumentfrom_priorof typelogicaland length one. Thisfrom_priorflag can be used to differentiate the output of themodelspecs, as its value is taken directly from thefrom_priorargument of themcmcmethod that invokesmodelspecsfunction. That is, whenfrom_priorisTRUE, then onlypriormodelJAGS model is used (datamodelis not used) by themcmc, and hencemodelspecsfunction should return all the parameters that are required by thepriormodelonly. If the value offrom_priorisFALSE, then both JAGS modelsdatamodelandpriormodelare used in the MCMC sampler, and hencemodelspecsfunction should return all the parameters required by bothdatamodelandpriormodel.init(
function)
a function computing the list of starting values for parameters required to be initialized in the MCMC sampler, based on the data slots that are required as arguments of this function.datanames(
character)
the names of all data slots that are used bydatamodelJAGS function. No other names should be specified here.datanames_prior(
character)
the names of all data slots that are used bypriormodelJAGS function. No other names should be specified here.sample(
character)
names of all parameters from which you would like to save the MCMC samples.
Note
The datamodel must obey the convention that the data input is
called exactly in the same way as in the corresponding data class.
All prior distributions for parameters should be contained in the
model function priormodel. The background is that this can
be used to simulate from the prior distribution, before obtaining any data.
Typically, end users will not use the .DefaultGeneralModel() function.
See Also
GeneralSimulations
Description
This class captures trial simulations.
Here also the random generator state before starting the simulation is
saved, in order to be able to reproduce the outcome. For this just use
set.seed with the seed as argument before running
simulate,Design-method.
Usage
GeneralSimulations(data, doses, seed)
.DefaultGeneralSimulations()
Arguments
data |
( |
doses |
( |
seed |
( |
Slots
data(
list)
producedDataobjects.doses(
numeric)
final dose recommendations.seed(
integer)
random generator state before starting the simulation.
Note
Typically, end users will not use the .DefaultGeneralSimulations() function.
Examples
data <- list(
Data(x = 1:3, y = c(0, 1, 0), doseGrid = 1:3, ID = 1L:3L, cohort = 1L:3L),
Data(x = 4:6, y = c(0, 1, 0), doseGrid = 4:6, ID = 1L:3L, cohort = 1L:3L)
)
doses <- c(1, 2)
seed <- 123L
simulations <- GeneralSimulations(data, doses, seed)
GeneralSimulationsSummary
Description
This class captures the summary of general simulations output. Note that objects should not be created by users, therefore no initialization function is provided for this class.
Usage
.DefaultGeneralSimulationsSummary()
Slots
target(
numeric)
target toxicity intervaltarget_dose_interval(
numeric)
corresponding target dose intervalnsim(
integer)
number of simulationsprop_dlts(
ANY)
A numeric array (multi-dimensional) or list representing proportions of DLTs in the trialsmean_tox_risk(
numeric)
mean toxicity risks for the patientsdose_selected(
numeric)
doses selected as MTDtox_at_doses_selected(
numeric)
true toxicity at doses selectedprop_at_target(
numeric)
Proportion of trials selecting target MTDdose_most_selected(
numeric)
dose most often selected as MTDobs_tox_rate_at_dose_most_selected(
numeric)
observed toxicity rate at dose most often selectedn_obs(
ANY)
A numeric array (multi-dimensional) or list representing number of patients overall.n_above_target(
integer)
number of patients treated above target tox intervaldose_grid(
numeric)
the dose grid that has been usedplacebo(
logical)
set to TRUE (default is FALSE) for a design with placebo
Note
Typically, end users will not use the .DefaultGeneralSimulationsSummary() function.
Increments
Description
Increments is a virtual class for controlling increments, from which all
other specific increments classes inherit.
Usage
.DefaultIncrements()
Note
Typically, end users will not use the .DefaultIncrements() function.
See Also
IncrementsRelative, IncrementsRelativeDLT,
IncrementsDoseLevels, IncrementsHSRBeta, IncrementsMin.
IncrementsDoseLevels
Description
IncrementsDoseLevels is the class for increments control based on the
number of dose levels.
Usage
IncrementsDoseLevels(levels = 1L, basis_level = "last")
.DefaultIncrementsDoseLevels()
Arguments
levels |
( |
basis_level |
( |
Slots
levels(
count)
maximum number of dose levels to increment for the next dose. It defaults to 1, which means that no dose skipping is allowed, i.e. the next dose can be maximum one level higher than the current base dose. The current base dose level is the dose level used to increment from (seebasis_levelparameter).basis_level(
string)
defines the current base dose level. It can take one out of two possible values:lastormax. Iflastis specified (default), the current base dose level is set to the last dose given. Ifmaxis specified, then the current base dose level is set to the maximum dose level given.
Note
Typically, end users will not use the .DefaultIncrementsDoseLevels() function.
Examples
# The rule for dose increments which allows for maximum skip one dose level,
# that is 2 dose levels higher than the last dose given.
my_increments <- IncrementsDoseLevels(levels = 2, basis_level = "last")
IncrementsHSRBeta
Description
IncrementsHSRBeta is a class for limiting further increments using
a Hard Safety Rule based on the Bin-Beta model.
Increment control is based on the number of observed DLTs and number of
subjects at each dose level. The probability of toxicity is calculated
using a Bin-Beta model with prior (a,b). If the probability exceeds
the threshold for a given dose, that dose and all doses above are excluded
from further escalation.
This is a hard safety rule that limits further escalation based on the
observed data per dose level, independent from the underlying model.
Usage
IncrementsHSRBeta(target = 0.3, prob = 0.95, a = 1, b = 1)
.DefaultIncrementsHSRBeta()
Arguments
target |
( |
prob |
( |
a |
( |
b |
( |
Slots
target(
proportion)
the target toxicity, except 0 or 1.prob(
proportion)
the threshold probability (except 0 or 1) for a dose being toxic.a(
number)
shape parametera > 0of probability distribution Beta (a,b).b(
number)
shape parameterb > 0of probability distribution Beta (a,b).
Note
Typically, end users will not use the .DefaultIncrementsHSRBeta() function.
Examples
# Limit the escalation with a hard safety criteria to the doses that are below
# the first dose that is toxic with a probability of 0.95.
my_increments <- IncrementsHSRBeta(target = 0.3, prob = 0.95)
IncrementsMaxToxProb
Description
IncrementsMaxToxProb is the class for increments control based on
probability of toxicity
Usage
IncrementsMaxToxProb(prob)
.DefaultIncrementsMaxToxProb()
Arguments
prob |
( |
Slots
prob(
numeric)
See Usage Notes below.
Usage Notes
For binary models, prob should be a scalar probability.
For ordinal models, prob should be a named vector containing the maximum
permissible probability of toxicity by grade. The names should match the
names of the yCategories slot of the associated DataOrdinal object.
Note
Typically, end users will not use the .DefaultIncrementsMaxToxProb() function.
Examples
# For use with binary models and data
IncrementsMaxToxProb(prob = 0.35)
# For use with ordinal models and data
IncrementsMaxToxProb(prob = c("DLAE" = 0.2, "DLT" = 0.05))
IncrementsMin
Description
IncrementsMin is the class that combines multiple increment rules with
the minimum operation. Slot increments_list contains all increment rules,
which are itself the objects of class Increments. The minimum of these
individual increments is taken to give the final maximum increment.
Usage
IncrementsMin(increments_list)
.DefaultIncrementsMin()
Arguments
increments_list |
( |
Slots
increments_list(
list)
list with increment rules.
Note
Typically, end users will not use the .DefaultIncrementsMin() function.
Examples
# As example, here we are combining 2 different increment rules.
# The first rule is the following:
# maximum doubling the dose if no DLTs were observed at the current dose
# or maximum increasing the dose by 1.33 if 1 or 2 DLTs were observed at the current dose
# or maximum increasing the dose by 1.22 if 3 or more DLTs were observed.
my_increments_1 <- IncrementsRelativeDLT(
intervals = c(0, 1, 3),
increments = c(1, 0.33, 0.2)
)
# The second rule is the following:
# maximum doubling the dose if the current dose is <20
# or only maximum increasing the dose by 1.33 if the current dose is >=20.
my_increments_2 <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Now we combine the 2 rules.
comb_increments <- IncrementsMin(
increments_list = list(my_increments_1, my_increments_2)
)
IncrementsOrdinal
Description
IncrementsOrdinal is the class for applying a standard Increments rule to
the results of an ordinal CRM trial.
Usage
IncrementsOrdinal(grade, rule)
.DefaultIncrementsOrdinal()
Arguments
grade |
( |
rule |
( |
Slots
grade(
integer)
the toxicity grade to which theruleshould be applied.rule(
Increments)
the standardIncrementsrule to be applied
Note
Typically, end users will not use the .DefaultIncrementsOrdinal() function.
Examples
IncrementsOrdinal(
grade = 1L,
rule = IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
)
IncrementsRelative
Description
IncrementsRelative is the class for increments control based on relative
differences in intervals.
Usage
IncrementsRelative(intervals, increments)
.DefaultIncrementsRelative()
Arguments
intervals |
( |
increments |
( |
Slots
intervals(
numeric)
a vector with the left bounds of the relevant intervals. For example,intervals = c(0, 50, 100)specifies three intervals:(0, 50),[50, 100)and[100, +Inf). That means, the right bound of the intervals are exclusive to the interval and the last interval goes from the last value to infinity.increments(
numeric)
a vector of the same length with the maximum allowable relative increments in theintervals.
Note
Typically, end users will not use the .DefaultIncrementsRelative() function.
Examples
# This is the example of a rule for:
# maximum doubling the dose if the current dose is <20
# or only maximum increasing the dose by 1.33 if the current dose is >=20.
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
IncrementsRelativeDLT
Description
IncrementsRelativeDLT is the class for increments control based on
relative differences in terms of DLTs.
Usage
IncrementsRelativeDLT(intervals, increments)
.DefaultIncrementsRelativeDLT()
Arguments
intervals |
( |
increments |
( |
Slots
intervals(
integer)
a vector with the left bounds of the relevant DLT intervals. For example,intervals = c(0, 1, 3)specifies three intervals (sets of DLTs: first, 0 DLT; second 1 or 2 DLTs; and the third one, at least 3 DLTs. That means, the right bound of the intervals are exclusive to the interval and the last interval goes from the last value to infinity.increments(
numeric)
a vector of maximum allowable relative increments corresponding tointervals. IT must be of the same length as the length ofintervals.
Note
This considers all DLTs across all cohorts observed so far.
Typically, end users will not use the .DefaultIncrementsRelativeDLT() function.
See Also
IncrementsRelativeDLTCurrent which only considers the DLTs in the current cohort.
Examples
# This is the example of a rule for:
# maximum doubling the dose if no DLTs were observed in the whole study so far
# or maximum increasing the dose by 1.33 if 1 or 2 DLTs were observed so far
# or maximum increasing the dose by 1.22 if 3 or more DLTs were observed so far.
my_increments <- IncrementsRelativeDLT(
intervals = c(0, 1, 3),
increments = c(1, 0.33, 0.2)
)
IncrementsRelativeDLTCurrent
Description
IncrementsRelativeDLTCurrent is the class for increments control based on
relative differences and current DLTs. The class is based on the number of
DLTs observed in the current cohort, but not cumulatively over all cohorts
so far.
Usage
IncrementsRelativeDLTCurrent(intervals = c(0L, 1L), increments = c(2L, 1L))
.DefaultIncrementsRelativeDLTCurrent()
Arguments
intervals |
( |
increments |
( |
Note
Typically, end users will not use the .DefaultIncrementsRelativeDLTCurrent() function.
See Also
Examples
# As example, here is the rule for:
# maximum doubling the dose if no DLTs were observed at the current dose
# or maximum increasing the dose by 1.33 if 1 or 2 DLTs were observed at the current dose
# or maximum increasing the dose by 1.22 if 3 or more DLTs were observed.
my_increments <- IncrementsRelativeDLTCurrent(
intervals = c(0, 1, 3),
increments = c(1, 0.33, 0.2)
)
IncrementsRelativeParts
Description
IncrementsRelativeParts is the class for increments control based on
relative differences in intervals, with special rules for part 1 and
beginning of part 2.
Usage
IncrementsRelativeParts(dlt_start, clean_start, ...)
.DefaultIncrementsRelativeParts()
Arguments
dlt_start |
( |
clean_start |
( |
... |
Arguments passed on to
|
Details
This class works only in conjunction with DataParts objects. If
part 2 will just be started in the next cohort, then the next maximum dose
will be either dlt_start (e.g. -1) shift of the last part 1 dose in case
of a DLT in part 1, or clean_start shift (e.g. -1) in case of no DLTs in
part 1, given that clean_start <= 0 (see description of clean_start
slot for more details). If part 1 will still be on in the next cohort,
then the next dose level will be the next higher dose level in the
part1Ladder slot of the data object. If part 2 has been started before,
the usual relative increment rules apply, see IncrementsRelative.
Slots
dlt_start(
integer)
a scalar, the dose level increment for starting part 2 in case of at least one DLT event in part 1.clean_start(
integer)
a scalar, the dose level increment for starting part 2 in case of no DLTs in part 1. Ifclean_start <= 0, then the part 1 ladder will be used to find the maximum next dose. Otherwise, the relative increment rules will be applied to find the next maximum dose level.
Note
We require that clean_start >= dlt_start. However, this precondition
is not a prerequisite for any function (except of the class' validation
function) that works with objects of this class. It is rather motivated by
the semantics. That is, if we observe a DLT in part 1, we cannot be more
aggressive than in case of a clean part 1 without DLT.
Typically, end users will not use the .DefaultIncrementsRelativeParts() function.
Examples
my_increments <- IncrementsRelativeParts(dlt_start = 0, clean_start = 1)
LogisticIndepBeta
Description
LogisticIndepBeta is the class for the two-parameters logistic regression
dose-limiting events (DLE) model with prior expressed in form of pseudo data.
This model describes the relationship between the binary DLE responses
and the dose levels. More specifically, it represents the relationship of the
probabilities of the occurrence of a DLE for corresponding dose levels in log
scale. This model is specified as
p(x) = exp(phi1 + phi2 * log(x)) / (1 + exp(phi1 + phi2 * log(x)))
where p(x) is the probability of the occurrence of a DLE at dose x.
The two parameters of this model are the intercept phi1 and the slope
phi2. The LogisticIndepBeta inherits all slots from ModelTox class.
In the context of pseudo data, the following three arguments are used,
binDLE, DLEdose and DLEweights. The DLEdose represents fixed dose
levels at which the pseudo DLE responses binDLE are observed. DLEweights
represents total number of subjects treated per each dose level in DLEdose.
The binDLE represents the number of subjects observed with DLE per each
dose level in DLEdose. Hence, all these three vectors must be of the same
length and the order of the elements in any of the vectors binDLE,
DLEdose and DLEweights must be kept, so that an element of a given vector
corresponds to the elements of the remaining two vectors (see the example for
more insight).
Finally, since at least two DLE pseudo responses are needed to
obtain prior modal estimates (same as the maximum likelihood estimates) for
the model parameters, the binDLE, DLEdose and DLEweights must all be
vectors of at least length 2.
Usage
LogisticIndepBeta(binDLE, DLEdose, DLEweights, data)
.DefaultLogisticIndepBeta()
Arguments
binDLE |
( |
DLEdose |
( |
DLEweights |
( |
data |
( |
Details
The pseudo data can be interpreted as if we obtain some observations before the trial starts. It can be used to express our prior, i.e. the initial beliefs for the model parameters. The pseudo data is expressed in the following way. First, fix at least two dose levels, then ask for experts' opinion on how many subjects are to be treated at each of these dose levels and on the number of subjects observed with a DLE. At each dose level, the number of subjects observed with a DLE, divided by the total number of subjects treated, is the probability of the occurrence of a DLE at that particular dose level. The probabilities of the occurrence of a DLE based on this pseudo data are independent and they follow Beta distributions. Therefore, the joint prior probability density function of all these probabilities can be obtained. Hence, by a change of variable, the joint prior probability density function of the two parameters in this model can also be obtained. In addition, a conjugate joint prior density function of the two parameters in the model is used. For details about the form of all these joint prior and posterior probability density functions, please refer to Whitehead and Williamson (1998).
Slots
binDLE(
numeric)
a vector of total numbers of DLE responses. It must be at least of length 2 and the order of its elements must correspond to values specified inDLEdoseandDLEweights.DLEdose(
numeric)
a vector of the dose levels corresponding to It must be at least of length 2 and the order of its elements must correspond to values specified inbinDLEandDLEweights.DLEweights(
integer)
total number of subjects treated at each of the pseudo dose levelDLEdose. It must be at least of length 2 and the order of its elements must correspond to values specified inbinDLEandDLEdose.phi1(
number)
the intercept of the model. This slot is used in output to display the resulting prior or posterior modal estimate of the intercept obtained based on the pseudo data and (if any) observed data/responses.phi2(
number)
the slope of the model. This slot is used in output to display the resulting prior or posterior modal estimate of the slope obtained based on the pseudo data and (if any) the observed data/responses.Pcov(
matrix)
refers to the 2x2 covariance matrix of the intercept (phi1) and the slope parameters (phi2) of the model. This is used in output to display the resulting prior and posterior covariance matrix ofphi1andphi2obtained, based on the pseudo data and (if any) the observed data and responses. This slot is needed for internal purposes.
Note
Typically, end users will not use the .DefaultLogisticIndepBeta() function.
References
Whitehead J, Williamson D (1998). “Bayesian decision procedures based on logistic regression models for dose-finding studies.” Journal of Biopharmaceutical Statistics, 8(3), 445–467.
Examples
# Obtain prior modal estimates given the pseudo data.
# First we used an empty data set such that only the dose levels under
# investigations are given. In total, 12 dose levels are under investigation
# ranging from 25 to 300 mg with increments of 25 (i.e 25, 50, 75, ..., 300).
emptydata <- Data(doseGrid = seq(25, 300, 25))
# Fix two dose levels 25 and 300 mg (DLEdose).
# Total number of subjects treated in each of these levels is 3, (DLEweights).
# The number of subjects observed with a DLE is 1.05 at dose 25 mg and 1.8 at dose 300 mg (binDLE).
my_model1 <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEdose = c(25, 300),
DLEweights = c(3, 3),
data = emptydata
)
# Use observed DLE responses to obtain posterior modal estimates.
my_data <- Data(
x = c(25, 50, 50, 75, 100, 100, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
doseGrid = emptydata@doseGrid
)
my_model2 <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEdose = c(25, 300),
DLEweights = c(3, 3),
data = my_data
)
LogisticKadane
Description
LogisticKadane is the class for the logistic model in the parametrization
of Kadane et al. (1980).
Usage
LogisticKadane(theta, xmin, xmax)
.DefaultLogisticKadane()
Arguments
theta |
( |
xmin |
( |
xmax |
( |
Details
Let rho0 = p(xmin) be the probability of a DLT at the minimum dose
xmin, and let gamma be the dose with target toxicity probability theta,
i.e. p(gamma) = theta. Then it can easily be shown that the logistic
regression model has intercept
[gamma * logit(rho0) - xmin * logit(theta)] / [gamma - xmin]
and slope
[logit(theta) - logit(rho0)] / [gamma - xmin].
The priors are
gamma ~ Unif(xmin, xmax).
and
rho0 ~ Unif(0, theta).
Slots
theta(
proportion)
the target toxicity probability.xmin(
number)
the minimum of the dose range.xmax(
number)
the maximum of the dose range.
Note
The slots of this class, required for creating the model, are the target toxicity, as well as the minimum and maximum of the dose range. Note that these can be different from the minimum and maximum of the dose grid in the data later on.
Typically, end-users will not use the .DefaultLogisticKadane() function.
References
Kadane JB, Dickey JM, Winkler RL, Smith WS, Peters SC (1980). “Interactive Elicitation of Opinion for a Normal Linear Model.” Journal of the American Statistical Association, 75(372), 845–854. ISSN 01621459, 1537274X, doi:10.2307/2287171, http://www.jstor.org/stable/2287171.
See Also
Examples
my_model <- LogisticKadane(theta = 0.33, xmin = 1, xmax = 200)
LogisticKadaneBetaGamma
Description
LogisticKadaneBetaGamma is the class for the logistic model in the parametrization
of Kadane et al. (1980),
using a beta and a gamma distribution as the model priors.
Usage
LogisticKadaneBetaGamma(theta, xmin, xmax, alpha, beta, shape, rate)
.DefaultLogisticKadaneBetaGamma()
Arguments
theta |
( |
xmin |
( |
xmax |
( |
alpha |
( |
beta |
( |
shape |
( |
rate |
( |
Details
Let rho0 = p(xmin) be the probability of a DLT at the minimum dose
xmin, and let gamma be the dose with target toxicity probability theta,
i.e. p(gamma) = theta. Then it can easily be shown that the logistic
regression model has intercept
[gamma * logit(rho0) - xmin * logit(theta)] / [gamma - xmin]
and slope
[logit(theta) - logit(rho0)] / [gamma - xmin].
The prior for gamma, is
gamma ~ Gamma(shape, rate).
.
The prior for rho0 = p(xmin), is
rho0 ~ Beta(alpha, beta).
Slots
theta(
proportion)
the target toxicity probability.xmin(
number)
the minimum of the dose range.xmax(
number)
the maximum of the dose range.alpha(
number)
the first shape parameter of the Beta prior distribution ofrho0 = p(xmin)the probability of a DLT at the minimum dosexmin.beta(
number)
the second shape parameter of the Beta prior distribution ofrho0 = p(xmin)the probability of a DLT at the minimum dosexmin.shape(
number)
the shape parameter of the Gamma prior distribution ofgammathe dose with target toxicity probabilitytheta.rate(
number)
the rate parameter of the Gamma prior distribution ofgammathe dose with target toxicity probabilitytheta.
Note
The slots of this class, required for creating the model, are the same
as in the LogisticKadane class. In addition, the shape parameters of the
Beta prior distribution of rho0 and the shape and rate parameters of the
Gamma prior distribution of gamma, are required for creating the prior model.
Typically, end users will not use the .Default() function.
References
Kadane JB, Dickey JM, Winkler RL, Smith WS, Peters SC (1980). “Interactive Elicitation of Opinion for a Normal Linear Model.” Journal of the American Statistical Association, 75(372), 845–854. ISSN 01621459, 1537274X, doi:10.2307/2287171, http://www.jstor.org/stable/2287171.
See Also
ModelLogNormal, LogisticKadane.
Examples
my_model <- LogisticKadaneBetaGamma(
theta = 0.3,
xmin = 0,
xmax = 7,
alpha = 1,
beta = 19,
shape = 0.5625,
rate = 0.125
)
LogisticLogNormal
Description
LogisticLogNormal is the class for the usual logistic regression model
with a bivariate normal prior on the intercept and log slope.
Usage
LogisticLogNormal(mean, cov, ref_dose = 1)
.DefaultLogisticLogNormal()
Arguments
mean |
( |
cov |
( |
ref_dose |
( |
Details
The covariate is the natural logarithm of the dose x divided by
the reference dose x*, i.e.:
logit[p(x)] = alpha0 + alpha1 * log(x/x*),
where p(x) is the probability of observing a DLT for a given dose x.
The prior
(alpha0, log(alpha1)) ~ Normal(mean, cov).
Note
Typically, end users will not use the .DefaultLogisticLogNormal() function.
See Also
ModelLogNormal, LogisticNormal, LogisticLogNormalSub,
ProbitLogNormal, ProbitLogNormalRel, LogisticLogNormalMixture,
DALogisticLogNormal.
Examples
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 50
)
my_model
LogisticLogNormalGrouped
Description
LogisticLogNormalGrouped is the class for a logistic regression model
for both the mono and the combo arms of the simultaneous dose escalation
design.
Usage
LogisticLogNormalGrouped(mean, cov, ref_dose = 1)
.DefaultLogisticLogNormalGrouped()
Arguments
mean |
( |
cov |
( |
ref_dose |
( |
Details
The continuous covariate is the natural logarithm of the dose x divided by
the reference dose x* as in LogisticLogNormal. In addition,
I_c is a binary indicator covariate which is 1 for the combo arm and 0 for the mono arm.
The model is then defined as:
logit[p(x)] = (alpha0 + I_c * delta0) + (alpha1 + I_c * delta1) * log(x / x*),
where p(x) is the probability of observing a DLT for a given dose x,
and delta0 and delta1 are the differences in the combo arm compared to the mono intercept
and slope parameters alpha0 and alpha1.
The prior is defined as
(alpha0, log(delta0), log(alpha1), log(delta1)) ~ Normal(mean, cov).
Note
Typically, end users will not use the .DefaultLogisticLogNormalGrouped() function.
See Also
ModelLogNormal, LogisticLogNormal.
Examples
my_model <- LogisticLogNormalGrouped(
mean = c(-0.85, 0, 1, 0),
cov = diag(1, 4),
ref_dose = 50
)
my_model
LogisticLogNormalMixture
Description
LogisticLogNormalMixture is the class for standard logistic model with
online mixture of two bivariate log normal priors.
Usage
LogisticLogNormalMixture(mean, cov, ref_dose, share_weight)
.DefaultLogisticLogNormalMixture()
Arguments
mean |
( |
cov |
( |
ref_dose |
( |
share_weight |
( |
Details
This model can be used when data is arising online from the informative
component of the prior, at the same time with the data of the trial of
main interest. Formally, this is achieved by assuming that the probability
of a DLT at dose x is given by
p(x) = \pi * p1(x) + (1 - \pi) * p2(x)
where \pi is the probability for the model p(x) being the same
as the model p1(x), which is the informative component of the prior.
From this model data arises in parallel: at doses xshare, DLT information
yshare is observed, in total nObsshare data points (see DataMixture).
On the other hand, 1 - \pi, is the probability of a separate model
p2(x). Both components have the same log normal prior distribution,
which can be specified by the user, and which is inherited from the
LogisticLogNormal class.
Slots
share_weight(
proportion)
the prior weight for the share componentp_{1}(x).
Note
Typically, end users will not use the .DefaultLogNormalMixture() function.
See Also
ModelLogNormal, LogisticNormalMixture,
LogisticNormalFixedMixture.
Examples
# Decide on the dose grid and MCMC options.
dose_grid <- 1:80
my_options <- McmcOptions()
# Classic model.
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 50
)
empty_data <- Data(doseGrid = dose_grid)
prior_samples <- mcmc(empty_data, my_model, my_options)
plot(prior_samples, my_model, empty_data)
# Set up the mixture model and data share object.
model_share <- LogisticLogNormalMixture(
share_weight = 0.1,
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 50
)
empty_data_share <- DataMixture(
doseGrid = dose_grid,
xshare = rep(c(10, 20, 40), each = 4),
yshare = rep(0L, 12),
)
# Compare with the resulting prior model.
prior_samples_share <- mcmc(empty_data_share, model_share, my_options)
plot(prior_samples_share, model_share, empty_data_share)
LogisticLogNormalOrdinal
Description
LogisticLogNormalOrdinal is the class for a logistic lognormal CRM model
using an ordinal toxicity scale.
Usage
LogisticLogNormalOrdinal(mean, cov, ref_dose)
.DefaultLogisticLogNormalOrdinal()
Arguments
mean |
( |
cov |
( |
ref_dose |
( |
Note
Typically, end users will not use the .DefaultLogisticLogNormalOrdinal() function.
Examples
LogisticLogNormalOrdinal(
mean = c(3, 4, 0),
cov = diag(c(4, 3, 1)),
ref_dose = 1
)
LogisticLogNormalSub
Description
LogisticLogNormalSub is the class for a standard logistic model with
bivariate (log) normal prior with subtractive dose standardization.
Usage
LogisticLogNormalSub(mean, cov, ref_dose = 0)
.DefaultLogisticLogNormalSub()
Arguments
mean |
( |
cov |
( |
ref_dose |
( |
Details
The covariate is the dose x minus the reference dose x*,
i.e.:
logit[p(x)] = alpha0 + alpha1 * (x - x*),
where p(x) is the probability of observing a DLT for a given dose x.
The prior
(alpha0, log(alpha1)) ~ Normal(mean, cov).
Slots
params(
ModelParamsNormal)
bivariate normal prior parameters.ref_dose(
number)
the reference dosex*.
Note
Typically, end-users will not use the .DefaultLogisticLogNormalSub() function.
See Also
LogisticNormal, LogisticLogNormal, ProbitLogNormal,
ProbitLogNormalRel.
Examples
my_model <- LogisticLogNormalSub(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 50
)
LogisticNormal
Description
LogisticNormal is the class for the usual logistic regression model with
a bivariate normal prior on the intercept and slope.
Usage
LogisticNormal(mean, cov, ref_dose = 1)
.DefaultLogisticNormal()
Arguments
mean |
( |
cov |
( |
ref_dose |
( |
Details
The covariate is the natural logarithm of the dose x divided by
the reference dose x*, i.e.:
logit[p(x)] = alpha0 + alpha1 * log(x/x*),
where p(x) is the probability of observing a DLT for a given dose x.
The prior
(alpha0, alpha1) ~ Normal(mean, cov).
Note
Typically, end users will not use the .DefaultLogisticNormal() function.
See Also
ModelLogNormal, LogisticLogNormal, LogisticLogNormalSub,
ProbitLogNormal, ProbitLogNormalRel, LogisticNormalMixture.
Examples
# Define the dose-grid.
empty_data <- Data(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
my_model <- LogisticNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2)
)
my_options <- McmcOptions(burnin = 10, step = 2, samples = 100)
samples <- mcmc(empty_data, my_model, my_options)
samples
LogisticNormalFixedMixture
Description
LogisticNormalFixedMixture is the class for standard logistic regression
model with fixed mixture of multiple bivariate (log) normal priors on the
intercept and slope parameters. The weights of the normal priors are fixed,
hence no additional model parameters are introduced. This type of prior is
often used to better approximate a given posterior distribution, or when the
information is given in terms of a mixture.
Usage
LogisticNormalFixedMixture(components, weights, ref_dose, log_normal = FALSE)
.DefaultLogisticNormalFixedMixture()
Arguments
components |
( |
weights |
( |
ref_dose |
( |
log_normal |
( |
Details
The covariate is the natural logarithm of the dose x divided
by the reference dose x*, i.e.:
logit[p(x)] = alpha0 + alpha1 * log(x/x*),
where p(x) is the probability of observing a DLT for a given dose x.
The prior
(alpha0, alpha1) ~ w1 * Normal(mean1, cov1) + ... + wK * Normal(meanK, covK),
if a normal prior is used and
(alpha0, log(alpha1)) ~ w1 * Normal(mean1, cov1) + ... + wK * Normal(meanK, covK),
if a log normal prior is used.
The weights w1, ..., wK of the components are fixed and sum to 1.
The slots of this class comprise a list with components parameters. Every single component contains the mean vector and the covariance matrix of bivariate normal distributions. Remaining slots are the weights of the components as well as the reference dose. Moreover, a special indicator slot specifies whether a log normal prior is used.
Slots
components(
list)
the specifications of the mixture components, a list withModelParamsNormalobjects for each bivariate (log) normal prior.weights(
numeric)
the weights of the components; these must be positive and must sum to 1.ref_dose(
positive_number)
the reference dose.log_normal(
flag)
should a log normal prior be used, such that the mean vectors and covariance matrices are valid for the intercept and log slope?
Note
Typically, end-users will not use the .DefaultLogisticNormalFixedMixture()
function.
See Also
ModelParamsNormal, ModelLogNormal,
LogisticNormalMixture, LogisticLogNormalMixture.
Examples
my_model <- LogisticNormalFixedMixture(
components = list(
comp1 = ModelParamsNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2)
),
comp2 = ModelParamsNormal(
mean = c(1, 1.5),
cov = matrix(c(1.2, -0.45, -0.45, 0.6), nrow = 2)
)
),
weights = c(0.3, 0.7),
ref_dose = 50
)
LogisticNormalMixture
Description
LogisticNormalMixture is the class for standard logistic regression model
with a mixture of two bivariate normal priors on the intercept and slope parameters.
Usage
LogisticNormalMixture(comp1, comp2, weightpar, ref_dose)
.DefaultLogisticNormalMixture()
Arguments
comp1 |
( |
comp2 |
( |
weightpar |
( |
ref_dose |
( |
Details
The covariate is the natural logarithm of the dose x divided by
the reference dose x*, i.e.:
logit[p(x)] = alpha0 + alpha1 * log(x/x*),
where p(x) is the probability of observing a DLT for a given dose x.
The prior
(alpha0, alpha1) ~ w * Normal(mean1, cov1) + (1 - w) * Normal(mean2, cov2).
The weight w for the first component is assigned a beta prior B(a, b).
Slots
comp1(
ModelParamsNormal)
bivariate normal prior specification of the first component.comp2(
ModelParamsNormal)
bivariate normal prior specification of the second component.weightpar(
numeric)
the beta parameters for the weight of the first component. It must a be a named vector of length 2 with namesaandband with strictly positive values.ref_dose(
positive_number)
the reference dose.
Note
The weight of the two normal priors is a model parameter, hence it is a flexible mixture. This type of prior is often used with a mixture of a minimal informative and an informative component, in order to make the CRM more robust to data deviations from the informative component.
Typically, end-users will not use the .DefaultLogisticNormalMixture() function.
See Also
ModelParamsNormal, ModelLogNormal,
LogisticNormalFixedMixture, LogisticLogNormalMixture.
Examples
my_model <- LogisticNormalMixture(
comp1 = ModelParamsNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2)
),
comp2 = ModelParamsNormal(
mean = c(1, 1.5),
cov = matrix(c(1.2, -0.45, -0.45, 0.6), nrow = 2)
),
weightpar = c(a = 1, b = 1),
ref_dose = 50
)
McmcOptions
Description
McmcOptions is a class for the three canonical MCMC options as well as
Random Number Generator settings.
Usage
McmcOptions(
burnin = 10000L,
step = 2L,
samples = 10000L,
rng_kind = NA_character_,
rng_seed = NA_integer_
)
.DefaultMcmcOptions()
Arguments
burnin |
( |
step |
( |
samples |
( |
rng_kind |
( |
rng_seed |
( |
Slots
iterations(
count)
number of MCMC iterations.burnin(
count)
number of burn-in iterations which are not saved.step(
count)
only everystep-th iteration is saved after theburnin. In other words, a sample from iterationi = 1,...,iterations, is saved if and only if(i - burnin) mod step = 0.
For example, foriterations = 6,burnin = 0andstep = 2, only samples from iterations2,4,6will be saved.rng_kind(
string)
a Random Number Generator (RNG) type used byrjags::rjags. It must be one out of the following four values:base::Wichmann-Hill,base::Marsaglia-Multicarry,base::Super-Duper,base::Mersenne-Twister, orNA_character_. If it isNA_character_(default), then the RNG kind will be chosen byrjags::rjags.rng_seed(
number)
a Random Number Generator (RNG) seed used byrjags::rjagsfor a chosenrng_kind. It must be an integer scalar orNA_integer_, which means that the seed will be chosen byrjags::rjags.
Note
Typically, end users will not use the .DefaultMcmcOptions() function.
Examples
# Set up MCMC option in order to have a burn-in of 10000 iterations and
# then take every other iteration up to a collection of 10000 samples.
McmcOptions(burnin = 10000, step = 2, samples = 10000)
Construct a Minimally Informative Prior
Description
This function constructs a minimally informative prior, which is captured in
a LogisticNormal (or LogisticLogNormal) object.
Based on the proposal by Neuenschwander et al. (2008),
a minimally informative prior distribution is constructed. The
required key input is the minimum (d_{1} in the notation of the
Appendix A.1 of that paper) and the maximum value (d_{J}) of the dose
grid supplied to this function. Then threshmin is the probability
threshold q_{1}, such that any probability of DLT larger than
q_{1} has only 5% probability. Therefore q_{1} is the 95%
quantile of the beta distribution and hence p_{1} = 0.95. Likewise,
threshmax is the probability threshold q_{J}, such that any
probability of DLT smaller than q_{J} has only 5% probability
(p_{J} = 0.05). The probabilities 1 - p_{1} and p_{J} can be
controlled with the arguments probmin and probmax, respectively.
Subsequently, for all doses supplied in the
dosegrid argument, beta distributions are set up from the assumption
that the prior medians are linear in log-dose on the logit scale, and
Quantiles2LogisticNormal() is used to transform the resulting
quantiles into an approximating LogisticNormal (or
LogisticLogNormal) model. Note that the reference dose
is not required for these computations.
Usage
MinimalInformative(
dosegrid,
refDose,
threshmin = 0.2,
threshmax = 0.3,
probmin = 0.05,
probmax = 0.05,
...
)
Arguments
dosegrid |
( |
refDose |
( |
threshmin |
( |
threshmax |
( |
probmin |
( |
probmax |
( |
... |
additional arguments for computations, see
|
Value
See Quantiles2LogisticNormal().
References
Neuenschwander B, Branson M, Gsponer T (2008). “Critical aspects of the Bayesian approach to phase I cancer trials.” Statistics in Medicine, 27(13), 2420–2439. https://onlinelibrary.wiley.com/doi/10.1002/sim.3230.
Examples
# Setting up a minimal informative prior
# max.time is quite small only for the purpose of showing the example. They
# should be increased for a real case.
set.seed(132)
coarseGrid <- c(0.1, 10, 30, 60, 100)
minInfModel <- MinimalInformative(dosegrid = coarseGrid,
refDose=50,
threshmin=0.2,
threshmax=0.3,
control=## for real case: leave out control
list(max.time=0.1))
# Plotting the result
matplot(x=coarseGrid,
y=minInfModel$required,
type="b", pch=19, col="blue", lty=1,
xlab="dose",
ylab="prior probability of DLT")
matlines(x=coarseGrid,
y=minInfModel$quantiles,
type="b", pch=19, col="red", lty=1)
legend("right",
legend=c("quantiles", "approximation"),
col=c("blue", "red"),
lty=1,
bty="n")
ModelEff
Description
ModelEff is the parent class for efficacy models using pseudo data prior.
It is dedicated all efficacy models that have their prior specified in the
form of pseudo data (as if there is some data before the trial starts).
The data must obey the convention of the DataDual class. This refers to
any observed efficacy/biomarker responses (w in DataDual), the dose
levels at which these responses are observed (x in DataDual), all dose
levels considered in the study (doseGrid in DataDual), and finally
other specifications in DataDual class that can be used to generate prior
or posterior modal estimates or samples estimates for model parameter(s).
If no responses are observed, at least doseGrid has to be specified
in data for which prior modal estimates or samples can be obtained for
model parameters based on the specified pseudo data.
Usage
.DefaultModelEff()
Slots
data(
DataDual)
observed data that is used to obtain model parameters estimates or samples (see details above).
Note
Typically, end users will not use the .DefaultModelEff() function.
See Also
ModelLogNormal
Description
ModelLogNormal is the class for a model with a reference dose and bivariate
normal prior on the model parameters alpha0 and natural logarithm of alpha1,
i.e.:
(alpha0, log(alpha1)) ~ Normal(mean, cov),
. Transformations other
than log, e.g. identity, can be specified too in priormodel slot.
The parameter alpha1 has a log-normal distribution by default to ensure
positivity of alpha1 which further guarantees exp(alpha1) > 1.
The slots of this class contain the mean vector, the covariance and
precision matrices of the bivariate normal distribution, as well as the
reference dose. Note that the precision matrix is an inverse of the
covariance matrix in the JAGS.
All ("normal") model specific classes inherit from this class.
Usage
ModelLogNormal(mean, cov, ref_dose = 1)
.DefaultModelLogNormal()
Arguments
mean |
( |
cov |
( |
ref_dose |
( |
Slots
params(
ModelParamsNormal)
bivariate normal prior parameters.ref_dose(
positive_number)
the reference dose.
Note
Typically, end users will not use the .DefaultModelLogNormal() function.
See Also
ModelParamsNormal, LogisticNormal, LogisticLogNormal,
LogisticLogNormalSub, ProbitLogNormal, ProbitLogNormalRel.
ModelParamsNormal
Description
ModelParamsNormal is the class for a bivariate normal model parameters,
i.e. the mean vector, covariance matrix and precision matrix.
The precision matrix is an inverse of the covariance matrix in the
JAGS and it is computed internally by the object constructor function.
Usage
ModelParamsNormal(mean, cov)
.DefaultModelParamsNormal()
Arguments
mean |
( |
cov |
( |
Slots
mean(
numeric)
the mean vector.cov(
matrix)
the covariance matrix.prec(
matrix)
the precision matrix, which is an inverse matrix of thecov.
Note
Typically, end users will not use the .ModelPAramsNormal() function.
See Also
ModelLogNormal, LogisticNormalMixture.
Examples
ModelParamsNormal(mean = c(1, 6), cov = diag(2))
ModelPseudo
Description
ModelPseudo is the parent class for models that express their prior in
the form of pseudo data (as if there is some data before the trial starts).
Usage
.DefaultModelPseudo()
Note
Typically, end users will not use the .DefaultModelPseudo() function.
See Also
ModelTox
Description
ModelTox is the parent class for DLE (dose-limiting events) models using
pseudo data prior. It is dedicated for DLE models or toxicity models that
have their prior specified in the form of pseudo data (as if there is some
data before the trial starts).
The data must obey the convention of the Data class. This refers to any
observed DLE responses (y in Data), the dose levels (x in Data)
at which these responses are observed, all dose levels considered in the
study (doseGrid in Data), and finally other specifications in Data
class that can be used to generate prior or posterior modal estimates or
samples estimates for model parameter(s).
If no responses are observed, at least doseGrid has to be specified
in data for which prior modal estimates or samples can be obtained for
model parameters based on the specified pseudo data.
Usage
.DefaultModelTox()
Slots
data(
Data)
observed data that is used to obtain model parameters estimates or samples (see details above).
Note
Typically, end users will not use the .DefaultModelTox() function.
See Also
NextBest
Description
NextBest is a virtual class for finding next best dose, from which all
other specific next best dose classes inherit.
Usage
.DefaultNextBest()
Note
Typically, end users will not use the DefaultNextBest() function.
See Also
NextBestEWOC, NextBestMTD, NextBestNCRM,
NextBestNCRMLoss, NextBestThreePlusThree, NextBestDualEndpoint,
NextBestMinDist, NextBestInfTheory, NextBestTD,
NextBestTDsamples, NextBestMaxGain, NextBestMaxGainSamples,
NextBestProbMTDLTE, NextBestProbMTDMinDist, NextBestOrdinal.
NextBestDualEndpoint
Description
NextBestDualEndpoint is the class for next best dose that is based on the
dual endpoint model.
Usage
NextBestDualEndpoint(
target,
overdose,
max_overdose_prob,
target_relative = TRUE,
target_thresh = 0.01
)
.DefaultNextBestDualEndpoint()
Arguments
target |
( |
overdose |
( |
max_overdose_prob |
( |
target_relative |
( |
target_thresh |
( |
Details
Under this rule, at first admissible doses are found, which are those
with toxicity probability to fall in overdose category and being below
max_overdose_prob. Next, it picks (from the remaining admissible doses) the
one that maximizes the probability to be in the target biomarker range. By
default (target_relative = TRUE) the target is specified as relative to the
maximum biomarker level across the dose grid or relative to the Emax
parameter in case a parametric model was selected (i.e. DualEndpointBeta,
DualEndpointEmax). However, if target_relative = FALSE, then the
absolute biomarker range can be used as a target.
Slots
target(
numeric)
the biomarker target range that needs to be reached. For example, the target range(0.8, 1.0)andtarget_relative = TRUEmeans that we target a dose with at least80\%of maximum biomarker level. As an other example,(0.5, 0.8)would mean that we target a dose between50\%and80\%of the maximum biomarker level.overdose(
numeric)
the overdose toxicity interval (lower limit excluded, upper limit included).max_overdose_prob(
proportion)
maximum overdose probability that is allowed.target_relative(
flag)
istargetspecified as relative? IfTRUE, then thetargetis interpreted relative to the maximum, so it must be a probability range. Otherwise, thetargetis interpreted as absolute biomarker range.target_thresh(
proportion)
a target probability threshold that needs to be fulfilled before the target probability will be used for deriving the next best dose (default to 0.01).
Note
Typically, end users will not use the .DefaultNextBestDualEndpoint() function.
Examples
# Target a dose achieving at least 0.9 of maximum biomarker level (efficacy)
# and with a probability below 0.25 that prob(DLT) > 0.35 (safety).
my_next_best <- NextBestDualEndpoint(
target = c(0.9, 1),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Now, using absolute target on the natural biomarker scale.
my_next_best_absolute <- NextBestDualEndpoint(
target = c(200, 300),
overdose = c(0.35, 1),
max_overdose_prob = 0.25,
target_relative = FALSE
)
NextBestEWOC
Description
NextBestEWOC is the class implementing Escalation With Overdose Control
(EWOC). It recommends the highest possible dose subject to a probabilistic
constraint that the posterior probability of overdosing does not exceed
max_overdose_prob. Overdosing is defined as the model-based toxicity
probability lying inside the interval given by overdose.
Usage
NextBestEWOC(target, overdose, max_overdose_prob)
.DefaultNextBestEWOC()
Arguments
target |
( |
overdose |
( |
max_overdose_prob |
( |
Slots
target(
proportion)
target toxicity probability to be achieved, belowoverdose[1]; only used for simulation reporting purposes.overdose(
numeric)
the (exclusive) lower and (inclusive) upper boundaries of the toxicity probability interval considered an overdose region. The prototype usesc(0.35, 1)meaning probabilities > 0.35 are treated as overly toxic.max_overdose_prob(
proportion)
maximum acceptable posterior probability that the next recommended dose is in the overdose interval.
Note
Typically, end users will not use the .DefaultNextBestEWOC() function.
See Also
NextBest, other next-best classes listed in its documentation.
Examples
# Example: Define EWOC next best dose rule.
# Target toxicity probability is 0.30. Overdose region is any probability > 0.35.
# We restrict posterior probability of recommending an overdosing dose to <= 0.25.
next_best_ewoc <- NextBestEWOC(
target = 0.30,
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
NextBestInfTheory
Description
NextBestInfTheory is the class for next best dose that is based on
information theory as proposed in https://doi.org/10.1002/sim.8450.
Usage
NextBestInfTheory(target, asymmetry)
.DefaultNextBestInfTheory()
Arguments
target |
( |
asymmetry |
( |
Slots
target(
proportion)
target toxicity probability, except 0 or 1.asymmetry(
number)
value of the asymmetry exponent in the divergence function that describes the rate of penalization for overly toxic does. It must be a value from(0, 2)interval.
Note
Typically, end users will not use the .DefaultNextBestInfTheory() function.
NextBestMTD
Description
NextBestMTD is the class for next best dose based on MTD estimate.
Usage
NextBestMTD(target, derive)
.DefaultNextBestMTD()
Arguments
target |
( |
derive |
( |
Slots
target(
proportion)
target toxicity probability, except 0 or 1.derive(
function)
a function which derives the final next best MTD estimate, based on vector of posterior MTD samples. It must therefore accept one and only one argument, which is a numeric vector, and return a number.
Note
Typically, end users will not use the .DefaultNextBestMTD() function.
Examples
# In the example below, the MTD is defined as the dose for which prob(DLE) = 0.33
# and we will use the 25th quantile of the posterior of MTD as our next best dose.
next_best_mtd <- NextBestMTD(
target = 0.33,
derive = function(mtd_samples) {
quantile(mtd_samples, probs = 0.25)
}
)
NextBestMaxGain
Description
NextBestMaxGain is the class to find a next best dose with maximum gain
value based on a pseudo DLT and efficacy models without samples. It is based
solely on the probabilities of the occurrence of a DLT and the values
of the mean efficacy responses obtained by using the modal estimates of the
DLT and efficacy model parameters. There are two target probabilities of the
occurrence of a DLT that must be specified: target probability to be used
during the trial and target probability to be used at the end of the trial.
It is suitable to use it only with the ModelTox model and ModelEff
classes (except EffFlexi).
Usage
NextBestMaxGain(prob_target_drt, prob_target_eot)
.DefaultNextBestMaxGain()
Arguments
prob_target_drt |
( |
prob_target_eot |
( |
Slots
prob_target_drt(
proportion)
the target probability of the occurrence of a DLT to be used during the trial.prob_target_eot(
proportion)
the target probability of the occurrence of a DLT to be used at the end of the trial.
Note
Typically, end users will not use the .DefaultNextBestMaxGain() function.
Examples
my_next_best <- NextBestMaxGain(0.35, 0.3)
NextBestMaxGainSamples
Description
NextBestMaxGainSamples is the class to find a next best dose with maximum
gain value based on a pseudo DLT and efficacy models and DLT and efficacy
samples. There are two target probabilities of the occurrence of a DLT that
must be specified: target probability to be used during the trial and target
probability to be used at the end of the trial.
It is suitable to use it only with the ModelTox model and ModelEff
classes.
Usage
NextBestMaxGainSamples(prob_target_drt, prob_target_eot, derive, mg_derive)
.DefaultNextBestMaxGainSamples()
Arguments
prob_target_drt |
( |
prob_target_eot |
( |
derive |
( |
mg_derive |
( |
Slots
derive(
function)
derives, based on a vector of posterior dose samples, the target dose that has the probability of the occurrence of DLT equals to either theprob_target_drtorprob_target_eot. It must therefore accept one and only one argument, which is a numeric vector, and return a number.mg_derive(
function)
derives, based on a vector of posterior dose samples that give the maximum gain value, the final next best estimate of the dose that gives the maximum gain value. It must therefore accept one and only one argument, which is a numeric vector, and return a number.
Note
Typically, end users will not use the .DefaultNextBestMaxGainSamples() function.
Examples
# Target probability of the occurrence of a DLT during the trial is set to 0.35.
# Target probability of the occurrence of a DLT at the end of the trial is set to 0.3.
# We want the use the 30% posterior quantile (the 30th percentile) of the TD35
# (the dose level with probability of the DLT equals 0.35) and TD30 samples.
# For `mg_derive` function (which takes the sample of doses which give the maximum
# gain), we will use the 50% posterior quantile (the median or th 50th percentile)
# of the sample.
my_next_best <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
NextBestMinDist
Description
NextBestMinDist is the class for next best dose that is based on minimum
distance to target probability.
Usage
NextBestMinDist(target)
.DefaultNextBestMinDist()
Arguments
target |
( |
Slots
target(
proportion)
single target toxicity probability, except 0 or 1.
Note
Typically, end users will not use the .DefaultNextBestMinDist() function.
Examples
# In the example below, the MTD is defined as the dose with the toxicity rate
# with minimal distance to the target of 30%.
next_best_min_dist <- NextBestMinDist(target = 0.3)
NextBestNCRM
Description
NextBestNCRM is the class for next best dose that finds the next dose
with high posterior probability to be in the target toxicity interval.
Usage
NextBestNCRM(target, overdose, max_overdose_prob)
.DefaultNextBestNCRM()
Arguments
target |
( |
overdose |
( |
max_overdose_prob |
( |
Details
To avoid numerical problems, the dose selection algorithm has been
implemented as follows: First admissible doses are found, which are those
with probability to fall in overdose category being below max_overdose_prob.
Next, within the admissible doses, the maximum probability to fall in the
target category is calculated. If that is above 5% (i.e. it is not just
numerical error), then the corresponding dose is the next recommended dose.
Otherwise, the highest admissible dose is the next recommended dose.
Slots
target(
numeric)
the target toxicity interval (limits included).overdose(
numeric)
the overdose toxicity interval (lower limit excluded, upper limit included). It is used to filter probability samples.max_overdose_prob(
proportion)
maximum overdose posterior probability that is allowed, except 0 or 1.
Note
Typically, end users will not use the .DefaultNextBestNCRM() function.
Examples
# In the example below, the target toxicity interval [0.2, 0.35] while the
# overdose interval is (0.35,1]. Finally we would like to constrain the
# probability of overdosing below 25%.
my_next_best <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
NextBestNCRMLoss
Description
NextBestNCRMLoss is the class based on NCRM rule and loss function.
This class is similar to NextBestNCRM class, but differences are the
addition of loss function and re-defined toxicity intervals, see each
toxicity interval documentation and the note for details. As in NCRM rule, first admissible doses are found,
which are those with probability to fall in overdose category being below
max_overdose_prob. Next, within the admissible doses, the loss function is
calculated, i.e. losses %*% target. Finally, the corresponding
dose with lowest loss function (Bayes risk) is recommended for the next dose.
Usage
NextBestNCRMLoss(
target,
overdose,
unacceptable = c(1, 1),
max_overdose_prob,
losses
)
.DefaultNextBestNCRMLoss()
Arguments
target |
( |
overdose |
( |
unacceptable |
( |
max_overdose_prob |
( |
losses |
( |
Slots
target(
numeric)
the target toxicity interval (limits included). It has to be a probability range excluding 0 and 1.overdose(
numeric)
the overdose toxicity interval (lower limit excluded, upper limit included) or the excessive toxicity interval (lower limit excluded, upper limit included) if unacceptable is not provided. It has to be a probability range. It is used to filter probability samples.unacceptable(
numeric)
an unacceptable toxicity interval (lower limit excluded, upper limit included). This must be specified if theoverdosedoes not include 1. Otherwise, it isc(1, 1)(default), which is essentially a scalar equals 1. It has to be a probability range.losses(
numeric)
a vector specifying the loss function. If theunacceptableis provided, the vector length must be 4, otherwise 3.
Note
The loss function should be a vector of either 3 or 4 values. This is because the loss function values must be specified for each interval, that is under-dosing, target toxicity, and overdosing toxicity or under-dosing, target toxicity, overdosing (excessive) toxicity, and unacceptable toxicity intervals.
Typically, end users will not use the .DefaultNextBestnCRMLoss() function.
Examples
# In the example below, the target toxicity interval [0.2, 0.35] while the
# overdose interval is (0.35, 1]. We would like to constrain the probability
# of overdosing below 25%. The loss function is c(1, 0, 1, 2).
my_next_best <- NextBestNCRMLoss(
target = c(0.2, 0.35),
overdose = c(0.35, 0.6),
unacceptable = c(0.6, 1),
max_overdose_prob = 0.25,
losses = c(1, 0, 1, 2)
)
NextBestOrdinal
Description
NextBestOrdinal is the class for applying a standard NextBest rule to
the results of an ordinal CRM trial.
Usage
NextBestOrdinal(grade, rule)
.DefaultNextBestOrdinal()
Arguments
grade |
( |
rule |
( |
Slots
grade(
integer)
the toxicity grade to which theruleshould be applied.rule(
NextBest)
the standardNextBestrule to be applied
Note
Typically, end users will not use the .DefaultNextBestOrdinal() function.
Examples
NextBestOrdinal(
grade = 1L,
rule = NextBestMTD(
0.25,
function(mtd_samples) {
quantile(mtd_samples, probs = 0.25)
}
)
)
NextBestProbMTDLTE
Description
NextBestProbMTDLTE is the class of finding a next best dose that selects
the dose with the highest probability of having a toxicity rate less or equal
to the toxicity target.
The dose is determined by calculating the posterior toxicity probability
for each dose per iteration and select the maximum dose that has a toxicity
probability below or equal to the target. The dose with the highest frequency
of being selected as MTD across iterations is the next best dose. Placebo
is not considered in the calculation and removed from the dose grid for
any calculations.
Usage
NextBestProbMTDLTE(target)
.DefaultNextBestProbMTDLTE()
Arguments
target |
( |
Slots
target(
numeric)
the target toxicity probability.
Note
Typically, end users will not use the .DefaultNextBestProbMTDLTE() function.
Examples
# In the example below, the MTD is defined as the dose with the highest
# probability of having a toxicity rate below 30%.
next_best_prob_mtd_lte <- NextBestProbMTDLTE(target = 0.3)
NextBestProbMTDMinDist
Description
NextBestProbMTDMinDist is the class of finding a next best dose that selects
the dose with the highest probability of having a toxicity rate with the
smallest distance to the toxicity target.
The dose is determined by calculating the posterior toxicity probability
for each dose per iteration and select the dose that has the smallest toxicity
probability distance to the target. The dose with the highest frequency
of being selected as MTD across iterations is the next best dose. Placebo
is not considered as the next dose and for that reason not used in
calculations. I.e. for placebo the toxicity probability distance to target
is not calculated and taken into account for determination of the next dose.
Usage
NextBestProbMTDMinDist(target)
.DefaultNextBestProbMTDMinDist()
Arguments
target |
( |
Slots
target(
numeric)
the target toxicity probability.
Note
Typically, end users will not use the .DefaultNextBestProbMTDMinDist() function.
Examples
# In the example below, the MTD is defined as the dose with the highest
# probability of having a toxicity rate with minimal distance
# to the target of 30%.
next_best_prob_mtd_min_dist <- NextBestProbMTDMinDist(target = 0.3)
NextBestTD
Description
NextBestTD is the class to find a next best dose based on pseudo
DLT model without samples. Namely, it is to find two next best doses, one
for allocation during the trial and the second for final recommendation at
the end of a trial without involving any samples, i.e. only DLT responses
will be incorporated for the dose-allocation. This is based solely on the
probabilities of the occurrence of a DLT obtained by using the modal estimates
of the model parameters. There are two target probabilities of the
occurrence of a DLT that must be specified: target probability to be used
during the trial and target probability to be used at the end of the trial.
It is suitable to use it only with the ModelTox model class.
Usage
.DefaultNextBestTD()
NextBestTD(prob_target_drt, prob_target_eot)
Arguments
prob_target_drt |
( |
prob_target_eot |
( |
Slots
prob_target_drt(
proportion)
the target probability (except 0 or 1) of the occurrence of a DLT to be used during the trial.prob_target_eot(
proportion)
the target probability (except 0 or 1) of the occurrence of a DLT to be used at the end of the trial.
Note
Typically, end users will not use the .DefaultNextBestTD() function.
Examples
my_next_best <- NextBestTD(0.35, 0.3)
NextBestTDsamples
Description
NextBestTDsamples is the class to find a next best dose based on Pseudo
DLT model with samples. Namely, it is to find two next best doses, one
for allocation during the trial and the second for final recommendation at
the end of a trial. Hence, there are two target probabilities of the
occurrence of a DLT that must be specified: target probability to be used
during the trial and target probability to be used at the end of the trial.
Usage
NextBestTDsamples(prob_target_drt, prob_target_eot, derive)
.DefaultNextBestTDsamples()
Arguments
prob_target_drt |
( |
prob_target_eot |
( |
derive |
( |
Slots
derive(
function)
derives, based on a vector of posterior dose samples, the target dose that has the probability of the occurrence of DLT equals to either theprob_target_drtorprob_target_eot. It must therefore accept one and only one argument, which is a numeric vector, and return a number.
Note
Typically, end users will not use the .DefaultNextBestTDsamples() function.
Examples
# Target probability of the occurrence of a DLT during the trial is set to 0.35.
# Target probability of the occurrence of a DLT at the end of the trial is set to 0.3.
# We want the use the 30% posterior quantile (the 30th percentile) of the TD35
# (the dose level with probability of the DLT equals 0.35) and TD30 samples.
my_next_best <- NextBestTDsamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, probs = 0.3))
}
)
NextBestThreePlusThree
Description
NextBestThreePlusThree is the class for next best dose that
implements the classical 3+3 dose recommendation. No input is required,
hence this class has no slots.
Usage
NextBestThreePlusThree()
.DefaultNextBestThreePlusThree()
Note
Typically, end users will not use the .DefaultNextBestThreePlusThree() function.
Examples
# Next best dose class object using the classical 3+3 design.
my_next_best <- NextBestThreePlusThree()
OneParExpPrior
Description
OneParExpPrior is the class for a standard CRM with an exponential prior
on the power parameter for the skeleton prior probabilities. It is an
implementation of a version of the one-parameter CRM
(O'Quigley et al. 1990).
Usage
OneParExpPrior(skel_probs, dose_grid, lambda)
.DefaultOneParExpPrior()
Arguments
skel_probs |
see slot definition. |
dose_grid |
( |
lambda |
see slot definition. |
Slots
skel_fun(
function)
function to calculate the prior DLT probabilities.skel_fun_inv(
function)
inverse function ofskel_fun.skel_probs(
numeric)
skeleton prior probabilities. This is a vector of unique and sorted probability values between 0 and 1.lambda(
number)
rate parameter of prior exponential distribution for theta.
Note
Typically, end users will not use the .DefaultOneparExpPrior() function.
Typically, end users will not use the .DefaultOneParLogNormalPrior() function.
References
O'Quigley J, Pepe M, Fisher L (1990). “Continual reassessment method: a practical design for phase 1 clinical trials in cancer.” Biometrics, 46(1). doi:10.2307/2531628.
Examples
my_model <- OneParExpPrior(
skel_probs = c(0.1, 0.3, 0.5, 0.7, 0.9),
dose_grid = 1:5,
lambda = 2
)
OneParLogNormalPrior
Description
OneParLogNormalPrior is the class for a standard CRM with a normal prior on
the log power parameter for the skeleton prior probabilities.
Usage
OneParLogNormalPrior(skel_probs, dose_grid, sigma2)
.DefaultOneParLogNormalPrior()
Arguments
skel_probs |
( |
dose_grid |
( |
sigma2 |
( |
Value
an instance of the OneParLogNormalPrior class
Slots
skel_fun(
function)
function to calculate the prior DLT probabilities.skel_fun_inv(
function)
inverse function ofskel_fun.skel_probs(
numeric)
skeleton prior probabilities. This is a vector of unique and sorted probability values between 0 and 1.sigma2(
number)
prior variance of log power parameter alpha.
See Also
Examples
my_model <- OneParLogNormalPrior(
skel_probs = seq(from = 0.1, to = 0.9, length = 5),
dose_grid = 1:5,
sigma2 = 2
)
ProbitLogNormal
Description
ProbitLogNormal is the class for probit regression model with a
bivariate normal prior on the intercept and log slope.
Usage
ProbitLogNormal(mean, cov, ref_dose = 1)
.DefaultProbitLogNormal()
Arguments
mean |
( |
cov |
( |
ref_dose |
( |
Details
The covariate is the natural logarithm of dose x divided by a
reference dose x*, i.e.:
probit[p(x)] = alpha0 + alpha1 * log(x/x*),
where p(x) is the probability of observing a DLT for a given dose x.
The prior
(alpha0, log(alpha1)) ~ Normal(mean, cov).
Note
The model used in the DualEndpoint classes is an extension of this model:
DualEndpoint supports both ProbitNormal (which is not implemented yet) and
ProbitLogNormal models through its use_log_dose slot.
ProbitLogNormal has no such flag, so always uses log(x/x*)as a covariate in
its model. Therefore this class can be used to check the prior assumptions on the
dose-toxicity model, even when sampling from the prior distribution of the dual
endpoint model is not possible, when use_log_dose = TRUE is used.
Typically, end users will not use the .DefaultProbitLogNormal() function.
See Also
ModelLogNormal, LogisticNormal, LogisticLogNormal,
LogisticLogNormalSub, ProbitLogNormalRel.
Examples
my_model <- ProbitLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 7.2
)
ProbitLogNormalRel
Description
ProbitLogNormalRel is the class for probit regression model with a bivariate
normal prior on the intercept and log slope.
Usage
ProbitLogNormalRel(mean, cov, ref_dose = 1)
.DefaultProbitLogNormalRel()
Arguments
mean |
( |
cov |
( |
ref_dose |
( |
Details
The covariate is the dose x divided by a reference dose x*,
i.e.:
probit[p(x)] = alpha0 + alpha1 * x/x*,
where p(x) is the probability of observing a DLT for a given dose x.
The prior
(alpha0, log(alpha1)) ~ Normal(mean, cov).
Note
This model is also used in the DualEndpoint classes, so this class
can be used to check the prior assumptions on the dose-toxicity model, even
when sampling from the prior distribution of the dual endpoint model is not
possible.
Typically, end users will not use the .DefaultProbitLogNormalRel() function.
See Also
ModelLogNormal, LogisticNormal, LogisticLogNormal,
LogisticLogNormalSub, ProbitLogNormal.
Examples
my_model <- ProbitLogNormalRel(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2)
)
PseudoDualFlexiSimulations
Description
This class captures the trial simulations design using both the DLE and
efficacy responses using
EffFlexi efficacy model.
It extends PseudoDualSimulations by adding the capability to capture the sigma2betaW estimates.
Usage
PseudoDualFlexiSimulations(sigma2_beta_w_est, ...)
.DefaultPseudoDualFlexiSimulations()
Arguments
sigma2_beta_w_est |
( |
... |
additional parameters from |
Slots
sigma2_beta_w_est(
numeric)
the vector of the final posterior mean sigma2betaW estimates
Note
Typically, end users will not use the .DefaultPseudoFlexiSimulations() function.
PseudoDualSimulations
Description
This class conducts trial simulations for designs using both the
DLE and efficacy responses. It defines final values for
efficacy fit and DLE, estimates of Gstar, optimal dose and sigma2.
Usage
PseudoDualSimulations(
fit_eff,
final_gstar_estimates,
final_gstar_at_dose_grid,
final_gstar_cis,
final_gstar_ratios,
final_optimal_dose,
final_optimal_dose_at_dose_grid,
sigma2_est,
...
)
.DefaultPseudoDualSimulations()
Arguments
fit_eff |
( |
final_gstar_estimates |
( |
final_gstar_at_dose_grid |
( |
final_gstar_cis |
( |
final_gstar_ratios |
( |
final_optimal_dose |
( |
final_optimal_dose_at_dose_grid |
( |
sigma2_est |
( |
... |
additional parameters from |
Slots
fit_eff(
list)
final values of efficacy fit.final_gstar_estimates(
numeric)
final Gstar estimates.final_gstar_at_dose_grid(
numeric)
final Gstar estimates at dose grid.final_gstar_cis(
list)
list of 95% confidence interval for Gstar estimates.final_gstar_ratios(
numeric)
ratios of confidence intervals for Gstar estimates.final_optimal_dose(
numeric)
final optimal dose.final_optimal_dose_at_dose_grid(
numeric)
final optimal dose at dose grid.sigma2_est(
numeric)
final sigma2 estimates.
Note
Do not use the .DefaultPseudoDualSimulations() function.
PseudoDualSimulationsSummary
Description
This class captures the summary of the dual responses simulations using pseudo models.
It contains all slots from PseudoSimulationsSummary object. In addition to
the slots in the parent class PseudoSimulationsSummary, it contains additional
slots for the efficacy model fit information.
Note that objects should not be created by users, therefore no initialization function is provided for this class.
Usage
.DefaultPseudoDualSimulationsSummary()
Slots
target_gstar(
numeric)
the target dose level such that its gain value is at maximumtarget_gstar_at_dose_grid(
numeric)
the dose level at dose Grid closest and below Gstargstar_summary(
table)
the six-number table summary (lowest, 25th, 50th (median), 75th percentile, mean and highest value) of the final Gstar values obtained across all simulationsratio_gstar_summary(
table)
the six-number summary table of the ratios of the upper to the lower 95% credibility intervals of the final Gstar across all simulationseff_fit_at_dose_most_selected(
numeric)
fitted expected mean efficacy value at dose most often selectedmean_eff_fit(
list)
list with mean, lower (2.5%) and upper (97.5%) quantiles of the fitted expected efficacy value at each dose level.
Note
Typically, end users will not use the .DefaultPseudoDualSimulationsSummary() function.
PseudoSimulations
Description
This class captures trial simulations from designs using pseudo model.
It has additional slots
fit and stop_reasons compared to the
general class GeneralSimulations.
Usage
PseudoSimulations(
fit,
final_td_target_during_trial_estimates,
final_td_target_end_of_trial_estimates,
final_td_target_during_trial_at_dose_grid,
final_td_target_end_of_trial_at_dose_grid,
final_tdeot_cis,
final_tdeot_ratios,
final_cis,
final_ratios,
stop_report,
stop_reasons,
...
)
.DefaultPseudoSimulations()
Arguments
fit |
( |
final_td_target_during_trial_estimates |
( |
final_td_target_end_of_trial_estimates |
( |
final_td_target_during_trial_at_dose_grid |
( |
final_td_target_end_of_trial_at_dose_grid |
( |
final_tdeot_cis |
( |
final_tdeot_ratios |
( |
final_cis |
( |
final_ratios |
( |
stop_report |
|
stop_reasons |
( |
... |
additional parameters from |
Slots
fit(
list)
final fit values.final_td_target_during_trial_estimates(
numeric)
final estimates of thetd_target_during_trial.final_td_target_end_of_trial_estimates(
numeric)
final estimates of thetd_target_end_of_trial.final_td_target_during_trial_at_dose_grid(
numeric)
dose levels at dose grid closest below the finaltd_target_during_trialestimates.final_td_target_end_of_trial_at_dose_grid(
numeric)
dose levels at dose grid closest below the finaltd_target_end_of_trialestimates.final_tdeot_cis(
list)
95% credibility intervals of the final estimates fortd_target_end_of_trial.final_tdeot_ratios(
numeric)
ratio of the upper to the lower 95% credibility intervals fortd_target_end_of_trial.final_cis(
list)
final 95% credibility intervals fortd_target_end_of_trialestimates.final_ratios(
numeric)
final ratios of the upper to the lower 95% credibility interval fortd_target_end_of_trial.stop_report(
matrix)
outcomes of stopping rules.stop_reasons(
list)
reasons for stopping each simulation run.
Note
Typically, end users will not use the .DefaultPseudoSimulations() function.
PseudoSimulationsSummary
Description
This class captures the summary of pseudo-models simulations output. Note that objects should not be created by users, therefore no initialization function is provided for this class.
Usage
.DefaultPseudoSimulationsSummary()
Slots
target_end_of_trial(
numeric)
the target probability of DLE wanted at the end of a trialtarget_dose_end_of_trial(
numeric)
the dose level corresponds to the target probability of DLE wanted at the end of a trial, TDEOTtarget_dose_end_of_trial_at_dose_grid(
numeric)
the dose level at dose grid corresponds to the target probability of DLE wanted at the end of a trialtarget_during_trial(
numeric)
the target probability of DLE wanted during a trialtarget_dose_during_trial(
numeric)
the dose level corresponds to the target probability of DLE wanted during the trial. TDDTtarget_dose_during_trial_at_dose_grid(
numeric)
the dose level at dose grid corresponds to the target probability of DLE wanted during a trialtdeot_summary(
table)
the six-number table summary, include the lowest, the 25th percentile (lower quartile), the 50th percentile (median), the mean, the 75th percentile and the highest values of the final dose levels obtained corresponds to the target probability of DLE want at the end of a trial across all simulationstddt_summary(
table)
the six-number table summary, include the lowest, the 25th percentile (lower quartile), the 50th percentile (median), the mean, the 75th percentile and the highest values of the final dose levels obtained corresponds to the target probability of DLE want during a trial across all simulationsfinal_dose_rec_summary(
table)
the six-number table summary, include the lowest, the 25th percentile (lower quartile), the 50th percentile (median), the mean, the 75th percentile and the highest values of the final optimal doses, which is either the TDEOT when only DLE response are incorporated into the escalation procedure or the minimum of the TDEOT and Gstar when DLE and efficacy responses are incorporated, across all simulationsratio_tdeot_summary(
table)
the six-number summary table of the final ratios of the upper to the lower 95% credibility intervals of the final TDEOTs across all simulationsfinal_ratio_summary(
table)
the six-number summary table of the final ratios of the upper to the lower 95% credibility intervals of the final optimal doses across all simulationsnsim(
integer)
number of simulationsprop_dle(
numeric)
proportions of DLE in the trialsmean_tox_risk(
numeric)
mean toxicity risks for the patientsdose_selected(
numeric)
doses selected as MTD (target_dose_end_of_trial)tox_at_doses_selected(
numeric)
true toxicity at doses selectedprop_at_target_end_of_trial(
numeric)
Proportion of trials selecting at the dose_grid closest below the MTD, the target_dose_end_of_trialprop_at_target_during_trial(
numeric)
Proportion of trials selecting at the dose_grid closest below the target_dose_during_trialdose_most_selected(
numeric)
dose most often selected as MTDobs_tox_rate_at_dose_most_selected(
numeric)
observed toxicity rate at dose most often selectedn_obs(
integer)
number of patients overalln_above_target_end_of_trial(
integer)
number of patients treated above target_dose_end_of_trialn_above_target_during_trial(
integer)
number of patients treated above target_dose_during_trialdose_grid(
numeric)
the dose grid that has been usedfit_at_dose_most_selected(
numeric)
fitted toxicity rate at dose most often selectedmean_fit(
list)
list with the average, lower (2.5%) and upper (97.5%) quantiles of the mean fitted toxicity at each dose levelstop_report(
matrix)
matrix of stopping rule outcomes
Note
Typically, end users will not use the .DefaultPseudoSimulationsSummary() function.
Convert Prior Quantiles to Logistic (Log) Normal Model
Description
This function uses generalized simulated annealing to optimize
a LogisticNormal model to be as close as possible
to the given prior quantiles.
Usage
Quantiles2LogisticNormal(
dosegrid,
refDose,
lower,
median,
upper,
level = 0.95,
logNormal = FALSE,
parstart = NULL,
parlower = c(-10, -10, 0, 0, -0.95),
parupper = c(10, 10, 10, 10, 0.95),
seed = 12345,
verbose = TRUE,
control = list(threshold.stop = 0.01, maxit = 50000, temperature = 50000, max.time =
600)
)
Arguments
dosegrid |
( |
refDose |
( |
lower |
( |
median |
( |
upper |
( |
level |
( |
logNormal |
( |
parstart |
( |
parlower |
( |
parupper |
( |
seed |
( |
verbose |
( |
control |
( |
Value
A list with the best approximating model
(LogisticNormal or LogisticLogNormal), the resulting quantiles,
the required quantiles and the distance to the required quantiles,
as well as the final parameters (which could be used for running the
algorithm a second time).
RuleDesign
Description
RuleDesign is the class for rule-based designs. The difference between
this class and the Design class is that RuleDesign does not contain
model, stopping and increments slots.
Usage
RuleDesign(nextBest, cohort_size, data, startingDose)
.DefaultRuleDesign()
ThreePlusThreeDesign(doseGrid)
Arguments
nextBest |
( |
cohort_size |
( |
data |
( |
startingDose |
( |
doseGrid |
( |
Functions
-
ThreePlusThreeDesign(): creates a new 3+3 design object from a dose grid.
Slots
nextBest(
NextBest)
how to find the next best dose.cohort_size(
CohortSize)
rules for the cohort sizes.data(
Data)
specifies dose grid, any previous data, etc.startingDose(
number)
the starting dose, it must lie on the dose grid indata.
Note
Typically, end users will not use the .DefaultRuleDesign() function.
Examples
# Specify the design to run simulations. The design comprises a model,
# the escalation rule, starting data, a cohort size and a starting dose.
# Initialing a 3+3 design with constant cohort size of 3 and starting dose equal 5.
my_design <- RuleDesign(
nextBest = NextBestThreePlusThree(),
cohort_size = CohortSizeConst(size = 3L),
data = Data(doseGrid = c(5, 10, 15, 25, 35, 50, 80)),
startingDose = 5
)
# Initialing a 3+3 design with constant cohort size of 3 and starting dose equal 8.
my_design <- ThreePlusThreeDesign(doseGrid = c(8, 10, 15, 25, 35, 50, 80))
RuleDesignOrdinal
Description
RuleDesignOrdinal is the class for rule-based designs. The difference between
this class and the DesignOrdinal class is that RuleDesignOrdinal
does not contain model, stopping and increments slots.
Usage
RuleDesignOrdinal(next_best, cohort_size, data, starting_dose)
.DefaultRuleDesignOrdinal()
Arguments
next_best |
( |
cohort_size |
( |
data |
( |
starting_dose |
( |
Details
Please note that the cohort size rules need to be wrapped into
the corresponding CohortSizeOrdinal class, before a successful evaluation of the
corresponding methods can take place. Note also that these wrappers cannot be nested,
i.e., you cannot have a CohortSizeOrdinal inside another CohortSizeOrdinal
(which also would not make sense) because it would not be clear which event grade to use
for the methods calculation. However, multiple rules can be combined using the operators
defined, e.g.,
CohortSizeMin(list(CohortSizeOrdinal(1L, rule1), CohortSizeOrdinal(2L, rule2))).
Slots
next_best(
NextBestOrdinal)
how to find the next best dose.cohort_size(
CohortSize)
rules for the cohort sizes.data(
DataOrdinal)
specifies dose grid, any previous data, etc.starting_dose(
number)
the starting dose, it must lie on the dose grid indata.
Note
Typically, end users will not use the .DefaultRuleDesignOrdinal() function.
Examples
RuleDesignOrdinal(
next_best = NextBestOrdinal(
1L,
NextBestMTD(
target = 0.25,
derive = function(x) median(x, na.rm = TRUE)
)
),
cohort_size = CohortSizeOrdinal(1L, CohortSizeConst(size = 3L)),
data = DataOrdinal(doseGrid = c(5, 10, 15, 25, 35, 50, 80)),
starting_dose = 5
)
SafetyWindow
Description
SafetyWindow is a class for safety window.
Usage
.DefaultSafetyWindow()
Note
Typically, end users will not use the .DefaultSafetyWindow() function.
See Also
SafetyWindowSize, SafetyWindowConst.
SafetyWindowConst
Description
SafetyWindowConst is the class for safety window length and it is used
when the gap should be kept constant across cohorts (though it may vary
within a cohort).
Usage
SafetyWindowConst(gap, follow, follow_min)
.DefaultSafetyWindowConst()
Arguments
gap |
see slot definition. |
follow |
see slot definition. |
follow_min |
see slot definition. |
Slots
gap(
integer)
a vector, the constant gap between patients.follow(
count)
how long to follow each patient. The period of time that each patient in the cohort needs to be followed before the next cohort opens.follow_min(
count)
minimum follow up. At least one patient in the cohort needs to be followed at the minimal follow up time.
Note
Typically, end users will not use the .DefaultSafetyWindowConst() function.
Examples
# This is to have along the study constant parameters settings of safety window
# length, regardless of the cohort size.
my_win_len <- SafetyWindowConst(
gap = c(7, 5, 3),
follow = 7,
follow_min = 14
)
SafetyWindowSize
Description
SafetyWindowSize is the class for safety window length based on cohort
size. This class is used to decide the rolling rule from the clinical
perspective.
Usage
SafetyWindowSize(gap, size, follow, follow_min)
.DefaultSafetyWindowSize()
Arguments
gap |
see slot definition. |
size |
see slot definition. |
follow |
see slot definition. |
follow_min |
see slot definition. |
Slots
gap(
list)
observed period of the previous patient before the next patient can be dosed. This is used as follows. If for instance, the cohort size is 4 and we want to specify three time intervals between these four consecutive patients, i.e. 7 units of time between the 1st and the 2nd patient, 5 units between the 2nd and the 3rd one, and finally 3 units between the 3rd and the 4th one, then,gap=list(c(7L, 5L, 3L)). Sometimes, we want that the interval only between the 1st and 2nd patient should be increased for the safety consideration and the rest time intervals should remain constant, regardless of what the cohort size is. Then,gap=list(c(7L, 3L))and the the package will automatically repeat the last element of the vector for the remaining time intervals.size(
integer)
a vector with the left bounds of the relevant cohort size intervals. This is used as follows. For instance, when we want to change thegapbased on the cohort size, i.e. the time interval between the 1st and 2nd patient = 9 units of time and the rest time intervals are of 5 units of time when the cohort size is equal to or larger than 4. And the time interval between the 1st and 2nd patient = 7 units of time and the rest time intervals are 3 units of time when the cohort size is smaller than 4, then we specify bothgap = list(c(7, 3), c(9, 5))andsize = c(0L, 4L). This means, the right bounds of the intervals are excluded from the interval, and the last interval goes from the last value to infinity.follow(
count)
the period of time that each patient in the cohort needs to be followed before the next cohort opens.follow_min(
count)
at least one patient in the cohort needs to be followed at the minimal follow up time.
Note
Typically, end users will not use the .DefaultSafetyWindowSize() function.
Examples
# Rule for having patient gap (7,3,3,3,...) for cohort size < 4, and
# patient gap (9,5,5,5...) for cohort size >= 4.
my_window_len <- SafetyWindowSize(
gap = list(c(7, 3), c(9, 5)),
size = c(1, 4),
follow = 7,
follow_min = 14
)
Samples
Description
Samples is the class to store the MCMC samples.
Usage
Samples(data, options)
.DefaultSamples()
Arguments
data |
see slot definition. |
options |
see slot definition. |
Slots
data(
list)
MCMC samples of the parameter. Each entry in this list must be a vector (in case of a scalar parameter) or matrix (in case of a vector-valued parameter) with samples. In case of matrix, every row is a separate sample, while columns correspond to the dimension of the parameter.options(
McmcOptions)
MCMC options that were used to generate the samples.
Note
Typically, end users will not use the .DefaultSamples() function.
Examples
# The MCMC options that were used to generate the samples.
my_options <- McmcOptions(
burnin = 1000,
step = 2,
samples = 1000
)
# Create an object of class 'Samples'
# Here the parameters 'alpha' and 'beta' are randomly generated. Of course, in
# a real example these would be a samples coming from MCMC procedures.
my_samples <- Samples(
data = list(alpha = rnorm(1000), beta = rnorm(1000)),
options = my_options
)
Simulations
Description
This class captures the trial simulations from model based designs.
Additional slots fit, stop_reasons, stop_report,additional_stats compared to
the general class GeneralSimulations.
Usage
Simulations(fit, stop_reasons, stop_report, additional_stats, ...)
.DefaultSimulations()
Arguments
fit |
( |
stop_reasons |
( |
stop_report |
see |
additional_stats |
( |
... |
additional parameters from |
Slots
fit(
list)
final fitsstop_reasons(
list)
stopping reasons for each simulation runstop_reportmatrix of stopping rule outcomes
additional_statslist of additional statistical summary
Note
Typically, end users will not use the .DefaultSimulations() function.
Examples
data <- list(
Data(
x = 1:2,
y = 0:1,
doseGrid = 1:2,
ID = 1L:2L,
cohort = 1L:2L
),
Data(
x = 3:4,
y = 0:1,
doseGrid = 3:4,
ID = 1L:2L,
cohort = 1L:2L
)
)
doses <- c(1, 2)
seed <- as.integer(123)
fit <- list(
c(0.1, 0.2),
c(0.3, 0.4)
)
stop_report <- matrix(c(TRUE, FALSE), nrow = 2)
stop_reasons <- list("A", "B")
additional_stats <- list(a = 1, b = 1)
simulations <- Simulations(
fit = fit,
stop_report = stop_report,
stop_reasons = stop_reasons,
additional_stats = additional_stats,
data,
doses,
seed
)
SimulationsSummary
Description
In addition to the slots in the parent class GeneralSimulationsSummary,
it contains two slots with model fit information.
Usage
.DefaultSimulationsSummary()
Slots
stop_report(
matrix)
matrix of stopping rule outcomesfit_at_dose_most_selected(
numeric)
fitted toxicity rate at dose most often selectedadditional_stats(
list)
list of additional statistical summarymean_fit(
list)
list with the average, lower (2.5%) and upper (97.5%) quantiles of the mean fitted toxicity at each dose level
Note
Typically, end users will not use the .DefaultSimulationsSummary() function.
StartingDose
Description
StartingDose is a simple wrapper class for the startingDose slot of all
design classes. It is used internally by knit_print methods
Usage
StartingDose(starting_dose)
.DefaultStartingDose()
Arguments
starting_dose |
( |
Slots
starting_dose(
numeric)
the starting dose
Note
Typically, end users will not use the .DefaultStartingDose() function.
Stopping
Description
Stopping is a class for stopping rules.
Slots
report_label(
string)
a label for the stopping report. The meaning of this parameter is twofold. If it is equal toNA_character_(default), thereport_labelwill not be used in the report at all. Otherwise, if it is specified as an empty character (i.e.character(0)) in a user constructor, then a default, class-specific label will be created for this slot. Finally, for the remaining cases, a user can provide a custom label.
See Also
StoppingList, StoppingCohortsNearDose, StoppingPatientsNearDose,
StoppingMinCohorts, StoppingMinPatients, StoppingTargetProb,
StoppingMTDdistribution, StoppingTargetBiomarker, StoppingHighestDose
StoppingMTDCV, StoppingLowestDoseHSRBeta, StoppingSpecificDose.
StoppingAll
Description
StoppingAll is the class for testing a stopping rule that consists of
many single stopping rules that are in turn the objects of class Stopping.
All single stopping rules must be satisfied in order the result of this rule
to be TRUE.
Usage
StoppingAll(stop_list, report_label = NA_character_)
.DefaultStoppingAll()
Arguments
stop_list |
( |
report_label |
( |
Slots
stop_list(
list)
list of stopping rules.report_labellabel for reporting
Note
Typically, end users will not use the .DefaultStoppingAll() function.
Examples
# Define some stopping rules.
my_stopping1 <- StoppingMinCohorts(nCohorts = 3)
my_stopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
my_stopping3 <- StoppingMinPatients(nPatients = 20)
# Create a list of stopping rules (of class `StoppingAll`) which would then be
# summarized by the `all` function, meaning that the study would be stopped only
# if all of the single stopping rules are `TRUE`.
my_stopping <- StoppingAll(
stop_list = c(my_stopping1, my_stopping2, my_stopping3)
)
StoppingAny
Description
StoppingAny is the class for testing a stopping rule that consists of
many single stopping rules that are in turn the objects of class Stopping.
At least one single stopping rule must be satisfied in order the result of
this rule to be TRUE.
Usage
StoppingAny(stop_list, report_label = NA_character_)
.DefaultStoppingAny()
Arguments
stop_list |
( |
report_label |
( |
Slots
stop_list(
list)
list of stopping rules.report_labellabel for reporting
Note
Typically, end users will not use the .DefaultStoppingAny() function.
Examples
# Define some stopping rules.
my_stopping1 <- StoppingMinCohorts(nCohorts = 3)
my_stopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
my_stopping3 <- StoppingMinPatients(nPatients = 20)
# Create a list of stopping rules (of class `StoppingAny`) which would then be
# summarized by the `any` function, meaning that the study would be stopped if
# any of the single stopping rules is `TRUE`.
my_stopping <- StoppingAny(
stop_list = c(my_stopping1, my_stopping2, my_stopping3)
)
StoppingCohortsNearDose
Description
StoppingCohortsNearDose is the class for stopping based on number of
cohorts near to next best dose.
Usage
StoppingCohortsNearDose(
nCohorts = 2L,
percentage = 50,
report_label = NA_character_
)
.DefaultStoppingCohortsNearDose()
Arguments
nCohorts |
( |
percentage |
( |
report_label |
( |
Slots
nCohorts(
number)
number of required cohorts.percentage(
number)
percentage (between and including 0 and 100) within the next best dose the cohorts must lie.
Note
Typically, end users will not use the .DefaultStoppingCohortsNearDose() function.
Examples
# Here, is the rule for stopping the study if at least 3 cohorts were dosed
# at a dose within (1 +/- 0.2) of the next best dose.
my_stopping <- StoppingCohortsNearDose(
nCohorts = 3,
percentage = 0.2
)
StoppingExternal
Description
StoppingExternal is the class for stopping based on an external flag.
Usage
StoppingExternal(report_label = NA_character_)
.DefaultStoppingExternal(report_label = NA_character_)
Arguments
report_label |
( |
Note
Typically, end users will not use the .DefaultStoppingExternal() function.
Examples
my_stopping <- StoppingExternal()
StoppingHighestDose
Description
StoppingHighestDose is the class for stopping based on the highest dose.
That is, the stopping occurs when the highest dose is reached.
Usage
StoppingHighestDose(report_label = NA_character_)
.DefaultStoppingHighestDose()
Arguments
report_label |
( |
Note
Typically, end users will not use the .DefaultStoppingHighestDose() function.
Examples
# The following stopping rule is met when:
# - next proposed dose is highest dose, and
# - there are already at least 3 patients on that dose, and
# - we are sure that this dose is safe, e.g. the probability to be in (0%, 20%)
# interval of the DLT rate is above 50%.
my_stopping <- StoppingHighestDose() &
StoppingPatientsNearDose(nPatients = 3, percentage = 0) &
StoppingTargetProb(target = c(0, 0.2), prob = 0.5)
# We note that this rule would then need to be combined with the other standard
# stopping rules, when the MTD is found based on being near e.g. a 30% DLT
# probability or having reached maximal sample size, in the manner of:
# stop_rule <- stop_high | stop_low | stop_sample_size # nolintr.
StoppingList
Description
StoppingList is the class for testing a stopping rule that consists of
many single stopping rules that are in turn the objects of class Stopping.
The summary slot stores a function that takes a logical vector of the size
of stop_list and returns a single logical value. For example, if the function
all is specified as a summary function, then that all stopping rules
defined in stop_list must be satisfied in order the result of this rule to
be TRUE.
Usage
StoppingList(stop_list, summary)
.DefaultStoppingList()
Arguments
stop_list |
( |
summary |
( |
Slots
stop_list(
list)
list of stopping rules.summary(
function)
a summary function to combine the results of the stopping rules into a single result.
Note
Typically, end users will not use the .DefaultStoppingList() function.
Examples
# Define some stopping rules.
my_stopping1 <- StoppingMinCohorts(nCohorts = 3)
my_stopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
my_stopping3 <- StoppingMinPatients(nPatients = 20)
# Create a list of stopping rules (of class `StoppingList`) which will then be
# summarized (in this specific example) with the `any` function, meaning that
# the study would be stopped if any of the single stopping rules is `TRUE`.
my_stopping <- StoppingList(
stop_list = c(my_stopping1, my_stopping2, my_stopping3),
summary = any
)
StoppingLowestDoseHSRBeta
Description
StoppingLowestDoseHSRBeta is a class for stopping based on a Hard Safety
Rule using the Beta posterior distribution with Beta(a,b) prior and a
Bin-Beta model based on the observed data at the lowest dose level.
The rule is triggered when the first dose is considered to be toxic
(i.e. above threshold probability) based on the observed data at the
lowest dose level and a Beta(a,b) prior distribution.
The default prior is Beta(1,1).
In case that placebo is used, the rule is evaluated at the second dose of the
dose grid, i.e. at the lowest non-placebo dose.
Usage
StoppingLowestDoseHSRBeta(
target = 0.3,
prob = 0.95,
a = 1,
b = 1,
report_label = NA_character_
)
.DefaultStoppingLowestDoseHSRBeta()
Arguments
target |
( |
prob |
( |
a |
( |
b |
( |
report_label |
( |
Slots
target(
proportion)
the target toxicity.prob(
proportion)
the threshold probability for the lowest dose being toxic.a(
number)
shape parametera > 0of probability distribution Beta (a,b).b(
number)
shape parameterb > 0of probability distribution Beta (a,b).
Note
This stopping rule is independent from the underlying model.
Typically, end users will not use the .DefaultStoppingLowestDoseHSRBeta() function.
Examples
# Stopping the study if the first dose is toxic with more than 90%
# probability based on a Beta posterior distribution with Beta(1,1) prior.
my_stopping <- StoppingLowestDoseHSRBeta(
target = 0.3,
prob = 0.9
)
# Stopping the study if the first dose is toxic with more than 90%
# probability based on a Beta posterior distribution with Beta(0.5,0.5) prior.
my_stopping <- StoppingLowestDoseHSRBeta(
target = 0.3,
prob = 0.9,
a = 0.5,
b = 0.5
)
StoppingMTDCV
Description
StoppingMTDCV is a class for stopping rule based on precision of MTD
which is calculated as the coefficient of variation (CV) of the MTD.
Here, the MTD is defined as the dose that reaches a specific target
probability of the occurrence of a DLT.
Usage
StoppingMTDCV(target = 0.3, thresh_cv = 40, report_label = NA_character_)
.DefaultStoppingMTDCV()
Arguments
target |
( |
thresh_cv |
( |
report_label |
( |
Slots
target(
proportion)
toxicity target of MTD (except 0 or 1).thresh_cv(
number)
threshold (percentage > 0) for CV to be considered accurate enough to stop the trial. The stopping occurs when the CV is less than or equal totresh_cv.
Note
Typically, end users will not use the .DefaultStoppingMTDCV() function.
Examples
# Stopping the study if the MTD estimation is precise enough, i.e. if robust
# coefficient of variation of the MTD is below 40%.
my_stopping <- StoppingMTDCV(target = 0.3, thresh_cv = 40)
StoppingMTDdistribution
Description
StoppingMTDdistribution is the class for stopping based on the posterior
distribution of the MTD. It is used for the cases where the stopping occurs
when the probability of MTD > thresh * next_dose is greater than or equal
to prob, where the next_dose is the recommended next best dose.
Here, the MTD is defined as the dose that reaches a specific target
probability of the occurrence of a DLT.
Usage
StoppingMTDdistribution(
target = 0.33,
thresh = 0.5,
prob = 0.9,
report_label = NA_character_
)
.DefaultStoppingMTDdistribution()
Arguments
target |
( |
thresh |
( |
prob |
( |
report_label |
( |
Slots
target(
proportion)
the target toxicity probability (except 0 or 1) defining the MTD.thresh(
proportion)
the threshold (except 0 or 1) relative to the recommended next best dose.prob(
proportion)
required minimum probability, except 0 or 1.
Note
Typically, end users will not use the .DefaultStoppingMTDDistribution() function.
Examples
# As example, here is the rule for stopping the study if there is at least 0.9
# probability that MTD > 0.5 * next_dose. Here MTD is defined as the dose for
# which prob(DLT) = 0.33
my_stopping <- StoppingMTDdistribution(
target = 0.33,
thresh = 0.5,
prob = 0.9
)
StoppingMaxGainCIRatio
Description
StoppingMaxGainCIRatio is the class for testing a stopping rule that is based
on a target ratio of the 95% credibility interval. Specifically, this is the
ratio of the upper to the lower bound of the 95% credibility interval's
estimate of the:
(1) target dose (i.e. a dose that corresponds to a given target
probability of the occurrence of a DLT prob_target), or
(2) max gain dose (i.e. a dose which gives the maximum gain),
depending on which one out of these two is smaller.
Usage
StoppingMaxGainCIRatio(
target_ratio = 5,
prob_target = 0.3,
report_label = NA_character_
)
.DefaultStoppingMaxGainCIRatio()
Arguments
target_ratio |
( |
prob_target |
( |
report_label |
( |
Slots
target_ratio(
numeric)
target for the ratio of the 95% credibility interval's estimate, that is required to stop a trial.prob_target(
proportion)
the target probability of the occurrence of a DLT.
Examples
# Define the target stopping ratio (5) and the target probability of a DLT to
# be used (0.3).
my_stopping <- StoppingMaxGainCIRatio(target_ratio = 5, prob_target = 0.3)
.DefaultStoppingMaxGainCIRatio()
StoppingMinCohorts
Description
StoppingMinCohorts is the class for stopping based on minimum number of
cohorts.
Usage
StoppingMinCohorts(nCohorts = 2L, report_label = NA_character_)
.DefaultStoppingMinCohorts()
Arguments
nCohorts |
( |
report_label |
( |
Slots
nCohorts(
number)
minimum required number of cohorts.
Note
Typically, end users will not use the .DefaultStoppingMinCohorts() function.
Examples
# As example, here is the rule for stopping the study if at least 6 cohorts
# were already dosed.
my_stopping <- StoppingMinCohorts(nCohorts = 6)
StoppingMinPatients
Description
StoppingMinPatients is the class for stopping based on minimum number of
patients
Usage
StoppingMinPatients(nPatients = 20L, report_label = NA_character_)
.DefaultStoppingMinPatients()
Arguments
nPatients |
( |
report_label |
( |
Slots
nPatients(
number)
minimum allowed number of patients.
Note
Typically, end users will not use the .DefaultStoppingMinPatients() function.
Examples
# As example, here is the rule for stopping the study if at least 20 patients
# were already dosed
my_stopping <- StoppingMinPatients(nPatients = 20)
StoppingMissingDose
Description
StoppingMissingDose is the class for stopping based on NA returned by
next best dose.
Usage
StoppingMissingDose(report_label = NA_character_)
.DefaultStoppingMissingDose()
Arguments
report_label |
( |
Note
Typically, end users will not use the .DefaultStoppingMissingDose() function.
Examples
# The rule for stopping the study if NA or Placebo is returned as
# next best dose.
my_stopping <- StoppingMissingDose()
StoppingOrdinal
Description
StoppingOrdinal is the class for stopping based on a Stopping rule applied
to a specific toxicity grade in an ordinal CRM trial
Usage
StoppingOrdinal(grade, rule)
.DefaultStoppingOrdinal()
Arguments
grade |
( |
rule |
( |
Slots
grade(
integer)
the grade to which the rule should be appliedrule(
Stopping)
the rule to apply
Note
Typically, end users will not use the .DefaultStoppingOrdinal() function.
Examples
StoppingOrdinal(
1L,
StoppingTargetProb(target = c(0.2, 0.35), prob = 0.6)
)
StoppingPatientsNearDose
Description
StoppingPatientsNearDose is the class for stopping based on number of
patients near to next best dose.
Usage
StoppingPatientsNearDose(
nPatients = 10L,
percentage = 50,
report_label = NA_character_
)
.DefaultStoppingPatientsNearDose()
Arguments
nPatients |
( |
percentage |
( |
report_label |
( |
Slots
nPatients(
number)
number of required patients.percentage(
number)
percentage (between and including 0 and 100) within the next best dose the patients must lie.
Note
Typically, end users will not use the .DefaultStoppingPatientsNearDose() function.
Examples
# As example, here is the rule for stopping the study if at least 9 patients
# were dosed at a dose within (1 +/- 0.2) of the next best dose.
my_stopping <- StoppingPatientsNearDose(
nPatients = 9,
percentage = 20
)
StoppingSpecificDose
Description
StoppingSpecificDose is the class for testing a stopping rule at specific
dose of the dose grid and not at the next best dose.
Usage
StoppingSpecificDose(
rule = StoppingTargetProb(target = c(0, 0.3), prob = 0.8),
dose = 80,
report_label = NA_character_
)
.DefaultStoppingSpecificDose()
Arguments
rule |
( |
dose |
( |
report_label |
( |
Slots
rule(
Stopping)
a stopping rule available in this package.dose(
positive_number)
a dose that is defined as part of the dose grid of the data.
Note
Typically, end users will not use the .DefaultStoppingSpecificDose() function.
Examples
# Stop if highest dose 80 is safe.
highest_dose_safe <- StoppingSpecificDose(
rule = StoppingTargetProb(target = c(0, 0.3), prob = 0.8),
dose = 80
)
# Stop if lowest dose 10 is toxic.
lowest_dose_toxic <- StoppingSpecificDose(
rule = StoppingTargetProb(target = c(0.3, 1), prob = 0.8),
dose = 10
)
StoppingTDCIRatio
Description
StoppingTDCIRatio is the class for testing a stopping rule that is based
on a target ratio of the 95% credibility interval. Specifically, this is the
ratio of the upper to the lower bound of the 95% credibility interval's
estimate of the target dose (i.e. a dose that corresponds to a given target
probability of the occurrence of a DLT prob_target).
Usage
StoppingTDCIRatio(
target_ratio = 5,
prob_target = 0.3,
report_label = NA_character_
)
.DefaultStoppingTDCIRatio()
Arguments
target_ratio |
( |
prob_target |
( |
report_label |
( |
Slots
target_ratio(
numeric)
target for the ratio of the 95% credibility interval's estimate, that is required to stop a trial.prob_target(
proportion)
the target probability of the occurrence of a DLT.
Note
Typically, end users will not use the .DefaultStoppingTDCIRatio() function.
Examples
# Define the target stopping ratio (5) and the target probability of a DLT to
# be used (0.3).
my_stopping <- StoppingTDCIRatio(
target_ratio = 5,
prob_target = 0.3
)
StoppingTargetBiomarker
Description
StoppingTargetBiomarker is a class for stopping based on probability of
target biomarker.
Usage
StoppingTargetBiomarker(
target = c(0.9, 1),
prob = 0.3,
is_relative = TRUE,
report_label = NA_character_
)
.DefaultStoppingTargetBiomarker()
Arguments
target |
( |
prob |
( |
is_relative |
( |
report_label |
( |
Slots
target(
numeric)
the biomarker target range that needs to be reached. For example,target = c(0.8, 1.0)withis_relative = TRUEmeans that we target a dose with at least 80% of maximum biomarker level.is_relative(
flag)
is target relative? If it so (default), then thetargetis interpreted relative to the maximum, so it must be a probability range. Otherwise, thetargetis interpreted as absolute biomarker range.prob(
proportion)
required target probability (except 0 or 1) for reaching sufficient precision.
Note
Typically, end users will not use the .DefaultStoppingTargetBiomarker() function.
Examples
# Stopping the study if there is at least 0.5 probability that the biomarker
# (efficacy) is within the biomarker target range of [0.9, 1.0] (relative to the
# maximum for the biomarker).
my_stopping <- StoppingTargetBiomarker(target = c(0.9, 1), prob = 0.5)
StoppingTargetProb
Description
StoppingTargetProb is the class for stopping based on the probability of
the DLT rate being in the target toxicity interval.
Usage
StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.4,
report_label = NA_character_
)
.DefaultStoppingTargetProb()
Arguments
target |
( |
prob |
( |
report_label |
( |
Slots
target(
number)
the target toxicity interval, e.g.c(0.2, 0.35).prob(
proportion)
required target toxicity probability (except 0 or 1) for reaching sufficient precision.
Note
Typically, end users will not use the .DefaultStoppingTargetProb() function.
Examples
# As example, here is the rule for stopping the study if the posterior
# probability that [0.2 =< Prob(DLT | dose) <= 0.35] for the next best dose
# is above 0.5.
my_stopping <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
TDDesign
Description
TDDesign is the class of design based only on DLT responses using
ModelTox class model (i.e. LogisticIndepBeta) without MCMC samples.
Usage
TDDesign(
model,
stopping,
increments,
pl_cohort_size = CohortSizeConst(0L),
...
)
.DefaultTDDesign()
Arguments
model |
( |
stopping |
( |
increments |
( |
pl_cohort_size |
( |
... |
Arguments passed on to
|
Slots
model(
ModelTox)
the pseudo DLT model to be used.stopping(
Stopping)
stopping rule(s) for the trial.increments(
Increments)
how to control increments between dose levels.pl_cohort_size(
CohortSize)
rules for the cohort sizes for placebo, if any planned (defaults to constant 0 placebo patients).
Note
Typically, end users will not use the .DefaultTDDesign() function.
Examples
empty_data <- Data(doseGrid = seq(25, 300, 25))
my_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = empty_data
)
# The escalation rule.
my_next_best <- NextBestTD(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
my_size <- CohortSizeConst(size = 3)
# The increments for the dose-escalation process:
# the maximum increase of 200% for doses up to the maximum dose in grid,
# the maximum increase of 200% for dose above the maximum dose in grid.
my_increments <- IncrementsRelative(
intervals = range(empty_data@doseGrid),
increments = c(2, 2)
)
# Stop when the maximum sample size of 36 patients is reached.
my_stopping <- StoppingMinPatients(nPatients = 36)
# The design with all the above information and starting with a dose of 25.
# This design incorporates only DLT responses and no DLT samples are involved
# during the simulation.
design <- TDDesign(
model = my_model,
stopping = my_stopping,
increments = my_increments,
nextBest = my_next_best,
cohort_size = my_size,
data = empty_data,
startingDose = 25
)
TDsamplesDesign
Description
TDsamplesDesign is the class of design based only on DLT responses using
ModelTox class model (i.e. LogisticIndepBeta) as well as MCMC samples
obtained for this model.
Usage
TDsamplesDesign(
model,
stopping,
increments,
pl_cohort_size = CohortSizeConst(0L),
...
)
.DefaultTDsamplesDesign()
Arguments
model |
( |
stopping |
( |
increments |
( |
pl_cohort_size |
( |
... |
Arguments passed on to
|
Slots
model(
ModelTox)
the pseudo DLT model to be used.stopping(
Stopping)
stopping rule(s) for the trial.increments(
Increments)
how to control increments between dose levels.pl_cohort_size(
CohortSize)
rules for the cohort sizes for placebo, if any planned (defaults to constant 0 placebo patients).
Note
Typically, end users will not use the .DefaultTDsamplesDesign() function.
Examples
empty_data <- Data(doseGrid = seq(25, 300, 25))
my_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = empty_data
)
# The escalation rule.
my_next_best <- NextBestTDsamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, probs = 0.3))
}
)
my_size <- CohortSizeConst(size = 3)
# The increments for the dose-escalation process:
# the maximum increase of 200% for doses up to the maximum dose in grid,
# the maximum increase of 200% for dose above the maximum dose in grid.
my_increments <- IncrementsRelative(
intervals = range(empty_data@doseGrid),
increments = c(2, 2)
)
# Stop when the maximum sample size of 36 patients is reached.
my_stopping <- StoppingMinPatients(nPatients = 36)
# The design with all the above information and starting with a dose of 25.
design <- TDsamplesDesign(
model = my_model,
stopping = my_stopping,
increments = my_increments,
nextBest = my_next_best,
cohort_size = my_size,
data = empty_data,
startingDose = 25
)
TITELogisticLogNormal
Description
TITELogisticLogNormal is the class for TITE-CRM based on a logistic
regression model using a bivariate normal prior on the intercept and log
slope parameters.
This class inherits from the LogisticLogNormal.
Usage
TITELogisticLogNormal(weight_method = "linear", ...)
.DefaultTITELogisticLogNormal()
Arguments
weight_method |
( |
... |
Arguments passed on to
|
Details
Basically, the adaptive function allocates more weight to each record than the linear function when DLTs are observed early and less weight when DLTs are observed late. When DLT times are evenly distributed both weights are similar. In addition, with more DLTs, the adaptive weights become more extreme and different from the linear weights.
Slots
weight_method(
string)
the weight function method: either linear or adaptive; see Liu et al. (2013).
Note
Typically, end users will not use the .DefaultTITELogisticLogNormal() function.
References
Liu S, Yin G, Yuan Y (2013). “Bayesian data augmentation dose finding with continual reassessment method and delayed toxicity.” The Annals of Applied Statistics, 7(4), 2138–2156. doi:10.1214/13-AOAS661.
See Also
Examples
my_model <- TITELogisticLogNormal(
mean = c(0, 1),
cov = diag(2),
ref_dose = 1,
weight_method = "linear"
)
my_model1 <- TITELogisticLogNormal(
mean = c(0, 1),
cov = diag(2),
ref_dose = 1,
weight_method = "adaptive"
)
Validate
Description
The Validate class is a Reference Class
to help programming validation for new S4 classes.
Details
Starting from an empty msg vector, with each check
that is returning FALSE the vector gets a new element - the string
explaining the failure of the validation.
Fields
msg(
character)
the cumulative messages.
Methods
check(test, string = "")Check whether the
testisTRUE; if so, returnNULL. Otherwise, add thestringmessage into the cumulative messages vectormsg.result()Return either cumulative messages vector
msg(which contains the error messages from all the checks), orNULL, ifmsgis empty (i.e. all the checks were successful).
Approximate posterior with (log) normal distribution
Description
To reproduce the resultant approximate model in the future exactly, include
seed = xxxx in the call to approximate.
Usage
approximate(object, model, data, ...)
## S4 method for signature 'Samples'
approximate(
object,
model,
data,
points = seq(from = min(data@doseGrid), to = max(data@doseGrid), length = 5L),
refDose = median(points),
logNormal = FALSE,
verbose = TRUE,
create_plot = TRUE,
...
)
Arguments
object |
the |
model |
the |
data |
the |
... |
additional arguments (see methods) |
points |
optional parameter, which gives the dose values at which the approximation should rely on (default: 5 values equally spaced from minimum to maximum of the dose grid) |
refDose |
the reference dose to be used (default: median of
|
logNormal |
use the log-normal prior? (not default) otherwise, the normal prior for the logistic regression coefficients is used |
verbose |
be verbose (progress statements)? (default) |
create_plot |
add a |
Value
a list containing the approximation model and, if requested, a
ggplot2 object containing a graphical representation of the fitted model
Functions
-
approximate(Samples): Here the ... argument can transport additional arguments forQuantiles2LogisticNormal, e.g. in order to control the approximation quality, etc.
Examples
# nolint start
# Create some data
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),
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 a model
model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Get posterior for all model parameters
options <- McmcOptions(
burnin = 100,
step = 2,
samples = 2000
)
set.seed(94)
samples <- mcmc(data, model, options)
# Approximate the posterior distribution with a bivariate normal
# max.time and maxit are very small only for the purpose of showing the example. They
# should be increased for a real case.
set.seed(94)
approximation <- approximate(
object = samples,
model = model,
data = data,
logNormal = TRUE,
control = list(
threshold.stop = 0.1,
max.time = 1,
maxit = 1
)
)
posterior <- approximation$model
# nolint end
Additional Assertions for checkmate
Description
We provide additional assertion functions that can be used together with
the checkmate functions. These are described in individual help pages
linked below.
Value
Depending on the function prefix.
-
assert_functions return the object invisibly if successful, and otherwise throw an error message. -
check_functions returnTRUEif successful, otherwise a string with the error message. -
test_functions just returnTRUEorFALSE.
See Also
assert_probabilities(), assert_probability(),
assert_probability_range(), assert_length().
Get the Biomarker Levels for a Given Dual-Endpoint Model, Given Dose Levels and Samples
Description
Usage
biomarker(xLevel, model, samples, ...)
## S4 method for signature 'integer,DualEndpoint,Samples'
biomarker(xLevel, model, samples, ...)
Arguments
xLevel |
( |
model |
( |
samples |
( |
... |
not used. |
Details
This function simply returns a specific columns (with the indices equal
to xLevel) of the biomarker samples matrix, which is included in the the
samples object.
Value
The biomarker levels.
Functions
-
biomarker(xLevel = integer, model = DualEndpoint, samples = Samples):
Examples
# Create the data.
my_data <- DataDual(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10, 20, 20, 20, 40, 40, 40, 50, 50, 50),
y = c(0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1),
ID = 1:17,
cohort = c(
1L,
2L,
3L,
4L,
5L,
6L,
6L,
6L,
7L,
7L,
7L,
8L,
8L,
8L,
9L,
9L,
9L
),
w = c(
0.31,
0.42,
0.59,
0.45,
0.6,
0.7,
0.55,
0.6,
0.52,
0.54,
0.56,
0.43,
0.41,
0.39,
0.34,
0.38,
0.21
),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Initialize the Dual-Endpoint model (in this case RW1).
my_model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# 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)
# Obtain the biomarker levels (samples) for the second dose from the dose grid,
# which is 0.5.
biomarker(
xLevel = 2L,
model = my_model,
samples = my_samples
)
Check if All Arguments Are Equal
Description
Elements of
... must be numeric vectors or scalars.
This function performs an element-by-element comparison of the first object
provided in ... with every other object in ... and returns TRUE if all
comparisons are equal within a given tolerance and FALSE otherwise.
Elements of
... must be numeric vectors or scalars.
This function performs an element-by-element comparison of the first object
provided in ... with every other object in ... and throws an error if they
are not.
Usage
check_equal(..., tol = sqrt(.Machine$double.eps))
assert_equal(
...,
tol = sqrt(.Machine$double.eps),
.var.name = vname(x),
add = NULL
)
Arguments
... |
( |
tol |
( |
.var.name |
[ |
add |
[ |
Value
TRUE if all element-by-element differences are less than tolerance
in magnitude, FALSE otherwise.
list(...), invisibly.
Note
If there are any missing or infinite values in ..., this function
returns FALSE, regardless of the values of other elements in ....
If elements in ... are not all of the same length, FALSE is returned.
If there are any missing or infinite values in ..., this function
throws an error, regardless of the values of other elements in ....
If elements in ... are not all of the same length, an error is thrown.
See Also
assertions for more details.
assertions for more details.
Examples
check_equal(1:2, 1:2) # TRUE
check_equal(1:2, 2:3) # "Not all equal"
check_equal(Inf, Inf) # "Not all equal"
check_equal(0.01, 0.02) # "Not all equal"
check_equal(0.01, 0.02, tol = 0.05) # TRUE
check_equal(1, c(1, 1)) # "Not all equal"
assert_equal(1:2, 1:2) # no error
assert_equal(0.01, 0.02, tol = 0.05) # no error
Check that an argument is a valid format specification
Description
Usage
check_format(x, len = NULL, min.len = NULL, max.len = NULL)
assert_format(
x,
len = NULL,
min.len = NULL,
max.len = NULL,
.var.name = checkmate::vname(x),
add = NULL
)
test_format(x, len = NULL, min.len = NULL, max.len = NULL)
expect_format(
x,
len = NULL,
min.len = NULL,
max.len = NULL,
info = NULL,
label = vname(x)
)
Arguments
x |
[ |
len |
[ |
min.len |
[ |
max.len |
[ |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
Value
TRUE if successful, otherwise a string with the error message.
See Also
assertions for more details.
Examples
check_format("%5.2f")
Check if vectors are of compatible lengths
Description
Two vectors are of compatible size if and only if:
At least one vector has size 1
or both vectors are of the same size.
Usage
check_length(x, len)
assert_length(x, len, .var.name = checkmate::vname(x), add = NULL)
test_length(x, len)
Arguments
x |
( |
len |
( |
.var.name |
[ |
add |
[ |
Value
TRUE if successful, otherwise a string with the error message.
See Also
assertions for more details.
Examples
check_length(1:5, 1)
check_length(1:5, 6)
check_length(1:5, 5)
check_length(10, 1)
check_length(10, 9)
Check if an argument is a probability vector
Description
Check if every element in a given numerical vector or matrix represents a probability, that is a number within (0, 1) interval, that can optionally be closed at any side.
Usage
check_probabilities(
x,
bounds_closed = TRUE,
len = NULL,
unique = FALSE,
sorted = FALSE
)
assert_probabilities(
x,
bounds_closed = TRUE,
len = NULL,
unique = FALSE,
sorted = FALSE,
.var.name = checkmate::vname(x),
add = NULL
)
test_probabilities(
x,
bounds_closed = TRUE,
len = NULL,
unique = FALSE,
sorted = FALSE
)
expect_probabilities(
x,
bounds_closed = TRUE,
len = NULL,
unique = FALSE,
sorted = FALSE,
info = NULL,
label = vname(x)
)
Arguments
x |
( |
bounds_closed |
( |
len |
[ |
unique |
[ |
sorted |
[ |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
Value
TRUE if successful, otherwise a string with the error message.
Note
If there are any missing or non-finite values in x, this function
returns FALSE, regardless of the values of other elements in x.
See Also
assertions for more details.
Examples
x <- c(0, 0.2, 0.1, 0.3, 1)
check_probabilities(x)
check_probabilities(x, bounds_closed = FALSE)
check_probabilities(x, bounds_closed = c(FALSE, TRUE))
Check if an argument is a single probability value
Description
Check if a given value represents a probability, that is a number within (0, 1) interval, that can optionally be closed at any side.
Usage
check_probability(x, bounds_closed = TRUE)
assert_probability(
x,
bounds_closed = TRUE,
.var.name = checkmate::vname(x),
add = NULL
)
test_probability(x, bounds_closed = TRUE)
expect_probability(x, bounds_closed = TRUE, info = NULL, label = vname(x))
Arguments
x |
( |
bounds_closed |
( |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
Value
TRUE if successful, otherwise a string with the error message.
See Also
assertions for more details.
Examples
check_probability(0.5)
check_probability(0, bounds_closed = FALSE)
check_probability(0, bounds_closed = c(FALSE, TRUE))
Check if an argument is a probability range
Description
Check if a given numerical interval represents a probability range, that is a sub-interval of (0, 1) interval, that can optionally be closed at any side.
Usage
check_probability_range(x, bounds_closed = TRUE)
assert_probability_range(
x,
bounds_closed = TRUE,
.var.name = checkmate::vname(x),
add = NULL
)
test_probability_range(x, bounds_closed = TRUE)
expect_probability_range(
x,
bounds_closed = TRUE,
info = NULL,
label = vname(x)
)
Arguments
x |
( |
bounds_closed |
( |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
Value
TRUE if successful, otherwise a string with the error message.
See Also
assertions for more details.
Examples
x <- c(0, 0.2)
check_probability_range(x)
check_probability_range(rev(x))
check_probability_range(x, bounds_closed = FALSE)
check_probability_range(x, bounds_closed = c(FALSE, TRUE))
Check that an argument is a numerical range
Description
An argument x is a numerical range if and only if (all conditions must be met):
Is an object of type:
integerordouble.Is a vector or length two such that the value of the first number is not less than the second number. Equalness is allowed if and only if
uniqueflag is set toTRUE.Lower bound of the interval is greater than or equal to
lowerand upper bound of the interval is less than or equal toupper.It contains only finite (given that
finiteisTRUE) and non-missing values.
Usage
check_range(x, lower = -Inf, upper = Inf, finite = FALSE, unique = TRUE)
assert_range(
x,
lower = -Inf,
upper = Inf,
finite = FALSE,
unique = TRUE,
.var.name = checkmate::vname(x),
add = NULL
)
test_range(x, lower = -Inf, upper = Inf, finite = FALSE, unique = TRUE)
expect_range(
x,
lower = -Inf,
upper = Inf,
finite = FALSE,
unique = TRUE,
info = NULL,
label = vname(x)
)
Arguments
x |
[ |
lower |
[ |
upper |
[ |
finite |
[ |
unique |
[ |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
Value
TRUE if successful, otherwise a string with the error message.
See Also
assertions for more details.
Examples
check_range(c(1, 5))
check_range(c(-5, 1))
check_range(c(4, 1))
check_range(c(1, 1))
check_range(c(1, 1), unique = FALSE)
check_range(1:3)
Open the Example PDF for crmPack
Description
Calling this helper function opens the example.pdf document,
residing in the doc subfolder of the package installation directory.
Usage
crmPackExample()
Value
Called for side effects.
Open the Browser with Help Pages for crmPack
Description
This convenience function opens your browser with the help pages for crmPack.
Usage
crmPackHelp()
Value
Called for side effects.
Apply a Function to Subsets of Data Frame.
Description
dapply splits the data df into the subsets defined by f,
and applies function FUN to each of the subset.
All the results are row-binded and returned as data.frame object.
Usage
dapply(df, f, FUN, ...)
Arguments
df |
( |
f |
( |
FUN |
( |
... |
parameters passed to |
Value
The data.frame object with results from FUN.
Examples
df <- data.frame(
dose = c(0.1, 6, 6, 5, 0.1, 5, 6, 6),
cohort = c("B", "B", "B", "A", "A", "A", "B", "B")
)
dapply(
df,
f = ~cohort,
FUN = function(coh) {
data.frame(my_cohort = coh$cohort[1], my_max = max(coh$dose))
}
)
dapply(
df,
f = ~cohort,
FUN = function(coh) {
coh$dose <- sort(coh$dose, decreasing = TRUE)
coh
}
)
Compute the Density of Inverse Gamma Distribution
Description
Usage
dinvGamma(x, a, b, log = FALSE, normalize = TRUE)
Arguments
x |
( |
a |
( |
b |
( |
log |
( |
normalize |
( |
Value
The density value(s).
Computing the Doses for a given independent variable, Model and Samples
Description
A function that computes the dose reaching a specific target value of a given variable that dose depends on. The meaning of this variable depends on the type of the model. For instance, for single agent dose escalation model or pseudo DLE (dose-limiting events)/toxicity model, this variable represents the a probability of the occurrence of a DLE. For efficacy models, it represents expected efficacy. The doses are computed based on the samples of the model parameters (samples).
Usage
dose(x, model, samples, ...)
## S4 method for signature 'numeric,LogisticNormal,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,LogisticLogNormal,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,LogisticLogNormalOrdinal,Samples'
dose(x, model, samples, grade)
## S4 method for signature 'numeric,LogisticLogNormalSub,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,ProbitLogNormal,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,ProbitLogNormalRel,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,LogisticLogNormalGrouped,Samples'
dose(x, model, samples, group)
## S4 method for signature 'numeric,LogisticKadane,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,LogisticKadaneBetaGamma,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,LogisticNormalMixture,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,LogisticNormalFixedMixture,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,LogisticLogNormalMixture,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,DualEndpoint,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,LogisticIndepBeta,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,LogisticIndepBeta,missing'
dose(x, model)
## S4 method for signature 'numeric,Effloglog,missing'
dose(x, model)
## S4 method for signature 'numeric,EffFlexi,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,OneParLogNormalPrior,Samples'
dose(x, model, samples)
## S4 method for signature 'numeric,OneParExpPrior,Samples'
dose(x, model, samples)
Arguments
x |
( |
model |
( |
samples |
( |
... |
model specific parameters when |
grade |
( |
group |
( |
Details
The dose() function computes the doses corresponding to a value of
a given independent variable, using samples of the model parameter(s).
If you work with multivariate model parameters, then assume that your model
specific dose() method receives a samples matrix where the rows
correspond to the sampling index, i.e. the layout is then
nSamples x dimParameter.
Value
A number or numeric vector with the doses.
If non-scalar samples were used, then every element in the returned vector
corresponds to one element of a sample. Hence, in this case, the output
vector is of the same length as the sample vector. If scalar samples were
used or no samples were used, e.g. for pseudo DLE/toxicity model,
then the output is of the same length as the length of the prob.
Functions
-
dose(x = numeric, model = LogisticNormal, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = LogisticLogNormal, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = LogisticLogNormalOrdinal, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x).In the case of a
LogisticLogNormalOrdinalmodel,dosereturns only the probability of toxicity at the given grade or higher -
dose(x = numeric, model = LogisticLogNormalSub, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = ProbitLogNormal, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = ProbitLogNormalRel, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = LogisticLogNormalGrouped, samples = Samples): method forLogisticLogNormalGroupedwhich needsgroupargument in addition. -
dose(x = numeric, model = LogisticKadane, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = LogisticKadaneBetaGamma, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = LogisticNormalMixture, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = LogisticNormalFixedMixture, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = LogisticLogNormalMixture, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = DualEndpoint, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = LogisticIndepBeta, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). -
dose(x = numeric, model = LogisticIndepBeta, samples = missing): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). All model parameters (exceptx) should be present in themodelobject. -
dose(x = numeric, model = Effloglog, samples = missing): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). All model parameters (exceptx) should be present in themodelobject. -
dose(x = numeric, model = EffFlexi, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLE (x). For this methodxmust be a scalar. -
dose(x = numeric, model = OneParLogNormalPrior, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLT (x). -
dose(x = numeric, model = OneParExpPrior, samples = Samples): compute the dose level reaching a specific target probability of the occurrence of a DLT (x).
Note
The dose() and prob() methods are the inverse of each other, for
all dose() methods for which its first argument, i.e. a given independent
variable that dose depends on, represents toxicity probability.
See Also
doseFunction(), prob(), efficacy().
Examples
# Create some 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),
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 a model, e.g. 'LogisticLogNormal'.
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Get samples from posterior.
my_options <- McmcOptions(burnin = 100, step = 2, samples = 20)
my_samples <- mcmc(data = my_data, model = my_model, options = my_options)
# Posterior for the dose achieving Prob(DLT) = 0.45.
dose(x = 0.45, model = my_model, samples = my_samples)
# Create data from the 'Data' (or 'DataDual') class.
dlt_data <- Data(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
doseGrid = seq(from = 25, to = 300, by = 25)
)
# Initialize a toxicity model using 'LogisticIndepBeta' model.
dlt_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = dlt_data
)
# Get samples from posterior.
dlt_sample <- mcmc(data = dlt_data, model = dlt_model, options = my_options)
# Posterior for the dose achieving Prob(DLT) = 0.45.
dose(x = 0.45, model = dlt_model, samples = dlt_sample)
dose(x = c(0.45, 0.6), model = dlt_model)
data_ordinal <- .DefaultDataOrdinal()
model <- .DefaultLogisticLogNormalOrdinal()
options <- .DefaultMcmcOptions()
samples <- mcmc(data_ordinal, model, options)
dose(0.25, model, samples, grade = 2L)
Getting the Dose Function for a Given Model Type
Description
A function that returns a dose() method that computes the dose reaching a
specific target value of a given independent variable, based on the model
specific parameters.
Usage
doseFunction(model, ...)
## S4 method for signature 'GeneralModel'
doseFunction(model, ...)
## S4 method for signature 'ModelPseudo'
doseFunction(model, ...)
## S4 method for signature 'LogisticLogNormalOrdinal'
doseFunction(model, grade, ...)
Arguments
model |
( |
... |
model specific parameters. |
grade |
( |
Value
A dose() method that computes doses.
Functions
-
doseFunction(GeneralModel): -
doseFunction(ModelPseudo): -
doseFunction(LogisticLogNormalOrdinal):
See Also
Examples
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 50
)
dose_fun <- doseFunction(my_model, alpha0 = 2, alpha1 = 3)
dose_fun(0.6)
data_ordinal <- .DefaultDataOrdinal()
model <- .DefaultLogisticLogNormalOrdinal()
options <- .DefaultMcmcOptions()
suppressWarnings({
samples <- mcmc(data_ordinal, model, options)
})
doseFunction(
model,
alpha1 = samples@data$alpha2,
beta = samples@data$beta,
grade = 1L
)(x = 0.75)
doseFunction(
model,
alpha2 = samples@data$alpha2,
beta = samples@data$beta,
grade = 2L
)(x = 0.25)
Getting the Dose Grid Range
Description
A function that returns a vector of length two with the minimum and maximum
dose in a grid. It returns c(-Inf, Inf) if the range cannot be determined,
which happens when the dose grid is empty. User can choose whether the
placebo dose (if any) should be counted or not.
Usage
dose_grid_range(object, ...)
## S4 method for signature 'Data'
dose_grid_range(object, ignore_placebo = TRUE)
## S4 method for signature 'DataOrdinal'
dose_grid_range(object, ignore_placebo = TRUE)
Arguments
object |
( |
... |
further arguments passed to class-specific methods. |
ignore_placebo |
( |
Value
A numeric vector containing the minimum and maximum of all the
doses in a grid or c(-Inf, Inf).
Examples
my_data <- Data(
x = c(10, 50, 90, 100, 0.001, 20, 30, 30),
y = c(0, 0, 0, 0, 0, 0, 1, 0),
ID = 1:8,
cohort = c(1L, 2L, 3L, 4L, 5L, 5L, 6L, 6L),
doseGrid = c(0.001, seq(from = 10, to = 100, by = 10)),
placebo = TRUE
)
dose_grid_range(my_data)
dose_grid_range(my_data, ignore_placebo = FALSE)
data <- DataOrdinal(
x = c(10, 20, 30, 40, 50, 50, 50, 60, 60, 60),
y = as.integer(c(0, 0, 0, 0, 0, 1, 0, 0, 1, 2)),
ID = 1L:10L,
cohort = as.integer(c(1:4, 5, 5, 5, 6, 6, 6)),
doseGrid = c(seq(from = 10, to = 100, by = 10)),
yCategories = c("No tox" = 0L, "Sub-tox AE" = 1L, "DLT" = 2L),
placebo = FALSE
)
dose_grid_range(data)
Computing Expected Efficacy for a Given Dose, Model and Samples
Description
A function that computes the value of expected efficacy at a specified dose level, based on the model specific parameters. The model parameters (samples) are obtained based on prior specified in form of pseudo data combined with observed responses (if any).
Usage
efficacy(dose, model, samples, ...)
## S4 method for signature 'numeric,Effloglog,Samples'
efficacy(dose, model, samples)
## S4 method for signature 'numeric,Effloglog,missing'
efficacy(dose, model)
## S4 method for signature 'numeric,EffFlexi,Samples'
efficacy(dose, model, samples)
Arguments
dose |
( |
model |
( |
samples |
( |
... |
model specific parameters when |
Details
The efficacy() function computes the expected efficacy for given
doses, using samples of the model parameter(s).
If you work with multivariate model parameters, then assume that your model
specific efficacy() method receives a samples matrix where the rows
correspond to the sampling index, i.e. the layout is then
nSamples x dimParameter.
Value
A numeric vector with the values of expected efficacy.
If non-scalar samples were used, then every element in the returned vector
corresponds to one element of a sample. Hence, in this case, the output
vector is of the same length as the sample vector. If scalar samples were
used or no samples were used, e.g. for pseudo DLE/toxicity model,
then the output is of the same length as the length of the dose.
Functions
-
efficacy(dose = numeric, model = Effloglog, samples = Samples): compute the expected efficacy at a specified dose level, based on the samples ofEffloglogmodel parameters. -
efficacy(dose = numeric, model = Effloglog, samples = missing): compute the expected efficacy at a specified dose level, based on theEffloglogmodel parameters. All model parameters (exceptdose) should be present in themodelobject. -
efficacy(dose = numeric, model = EffFlexi, samples = Samples): compute the expected efficacy at a specified dose level, based on the samples ofEffFleximodel parameters. If a given dose in thedosevector is from outside of the dose grid range, theNA_realis returned for this dose and the warning is thrown.
See Also
Examples
# Obtain the expected efficacy value for a given dose, a given pseudo efficacy
# model (in flexible form for prior) and efficacy samples.
# Empty data (i.e. no observed data), dose grid only.
my_data <- DataDual(doseGrid = seq(25, 300, 25))
my_model <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = my_data
)
my_options <- McmcOptions(
burnin = 100,
step = 2,
samples = 200,
rng_kind = "Mersenne-Twister",
rng_seed = 94
)
my_samples <- mcmc(data = my_data, model = my_model, options = my_options)
# Efficacy for dose 75.
efficacy(dose = 75, model = my_model, samples = my_samples)
# Obtain the expected efficacy value for a given dose, a given pseudo efficacy
# model (linear log-log efficacy) and no samples.
my_model_ll <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = my_data,
const = 0
)
efficacy(dose = 75, model = my_model_ll)
Getting the Efficacy Function for a Given Model Type
Description
A function that returns an efficacy() function that computes expected
efficacy for a given dose level, based on the model specific parameters.
Usage
efficacyFunction(model, ...)
## S4 method for signature 'ModelEff'
efficacyFunction(model, ...)
Arguments
model |
( |
... |
model specific parameters. |
Value
A efficacy() function that computes expected efficacy.
Functions
-
efficacyFunction(ModelEff):
See Also
Examples
my_data <- DataDual(
doseGrid = c(0.001, seq(25, 300, 25)),
placebo = TRUE
)
my_model <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = my_data,
const = 2
)
eff_fun <- efficacyFunction(my_model, theta1 = -4.8, theta2 = 3.7)
eff_fun(30)
Verbose Logging
Description
A family of wrappers of selected futile.logger::futile.logger functions that control
the logging mechanism in crmPack. The crmPack uses futile.logger::futile.logger
package for the logging purposes. All the messages logged in crmPack are
logged into crmPack logger at the futile.logger::TRACE level. Hence,
enabling verbose logging means that the logging threshold will be set to
futile.logger::TRACE for the crmPack logger, and disabling verbose
logging means that it will be set to futile.logger::FATAL.
Usage
enable_logging()
disable_logging()
is_logging_enabled()
log_trace(msg, ..., capture = FALSE)
Arguments
msg |
The message to log |
... |
Optional arguments to populate the format string |
capture |
Capture print output of variables instead of interpolate |
Functions
-
enable_logging(): A simple wrapper offutile.logger::flog.threshold()that enablescrmPackverbose logging by setting logging threshold tofutile.logger::TRACEforcrmPacklogger. -
disable_logging(): A simple wrapper offutile.logger::flog.threshold()that disablescrmPackverbose logging by setting logging threshold tofutile.logger::FATALforcrmPacklogger. -
is_logging_enabled(): A simple wrapper offutile.logger::flog.logger()that checks whether current threshold level forcrmPacklogger is verbose, which isfutile.logger::TRACE. It returnsTRUEif the current logging level is verbose,FALSEotherwise. -
log_trace(): A simple wrapper offutile.logger::flog.trace()that prints a log message in thecrmPacklogger.
Obtain Hypothetical Trial Course Table for a Design
Description
This generic function takes a design and generates a data.frame
showing the beginning of several hypothetical trial courses under
the design. This means, from the generated data.frame one can read off:
Usage
examine(object, ..., maxNoIncrement = 100L)
## S4 method for signature 'Design'
examine(object, mcmcOptions = McmcOptions(), ..., maxNoIncrement)
## S4 method for signature 'RuleDesign'
examine(object, ..., maxNoIncrement = 100L)
## S4 method for signature 'DADesign'
examine(object, mcmcOptions = McmcOptions(), ..., maxNoIncrement)
Arguments
object |
( |
... |
additional arguments (see methods) |
maxNoIncrement |
maximum number of contiguous next doses at 0 DLTs that are the same as before, i.e. no increment (default to 100) |
mcmcOptions |
( |
Details
how many cohorts are required in the optimal case (no DLTs observed) in order to reach the highest dose of the specified dose grid (or until the stopping rule is fulfilled)
assuming no DLTs are observed until a certain dose level, what the next recommended dose is for all possible number of DLTs observed
the actual relative increments that will be used in these cases
whether the trial would stop at a certain cohort
Examining the "single trial" behavior of a dose escalation design is the first important step in evaluating a design, and cannot be replaced by studying solely the operating characteristics in "many trials". The cohort sizes are also taken from the design, assuming no DLTs occur until the dose listed.
Value
The data frame
Functions
-
examine(Design): Examine a model-based CRM. -
examine(RuleDesign): Examine a rule-based design. -
examine(DADesign): Examine a model-based CRM.
Examples
# Define the dose-grid.
emptydata <- Data(doseGrid = c(1, 3, 5, 10, 15, 20, 25))
# Initialize the CRM model.
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Choose the rule for selecting the next dose.
my_next_best <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
my_size1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
my_size2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
my_size <- maxSize(my_size1, my_size2)
# Choose the rule for stopping.
my_stopping1 <- StoppingMinCohorts(nCohorts = 3)
my_stopping2 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
my_stopping3 <- StoppingMinPatients(nPatients = 20)
my_stopping <- (my_stopping1 & my_stopping2) | my_stopping3
# Choose the rule for dose increments.
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design.
my_design <- Design(
model = my_model,
nextBest = my_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 3
)
my_options <- McmcOptions(
burnin = 10,
step = 1,
samples = 20,
rng_kind = "Super-Duper",
rng_seed = 94
)
examine(my_design, my_options)
# Example where examine stops because stopping rule already fulfilled.
my_stopping4 <- StoppingMinPatients(nPatients = 3)
my_stopping <- (my_stopping1 & my_stopping2) | my_stopping4
my_design <- Design(
model = my_model,
nextBest = my_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 3
)
examine(my_design, mcmcOptions = my_options)
# Example where examine stops because infinite looping
# (note that here a very low threshold is used for the parameter
# "maxNoIncrement" in "examine" to keep the execution time short).
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.00001)
)
my_stopping <- (my_stopping1 & my_stopping2) | StoppingMissingDose()
design <- Design(
model = my_model,
nextBest = my_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 3
)
examine(my_design, mcmcOptions = my_options, maxNoIncrement = 2)
# Define the dose-grid
emptydata <- Data(doseGrid = c(5, 10, 15, 25, 35, 50, 80))
# inizialing a 3+3 design with constant cohort size of 3 and
# starting dose equal 5
myDesign <- RuleDesign(
nextBest = NextBestThreePlusThree(),
cohort_size = CohortSizeConst(size = 3L),
data = emptydata,
startingDose = 5
)
# Examine the design
set.seed(4235)
examine(myDesign)
# nolint start
# Define the dose-grid and PEM parameters
emptydata <- DataDA(doseGrid = c(
0.1, 0.5, 1, 1.5, 3, 6,
seq(from = 10, to = 80, by = 2)
), Tmax = 60)
# Initialize the mDA-CRM model
npiece_ <- 10
Tmax_ <- 60
lambda_prior <- function(k) {
npiece_ / (Tmax_ * (npiece_ - k + 0.5))
}
model <- DALogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56,
npiece = npiece_,
l = as.numeric(t(apply(as.matrix(c(1:npiece_), 1, npiece_), 2, lambda_prior))),
c_par = 2
)
# Choose the rule for dose increments
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size
mySize1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
mySize2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
mySize <- maxSize(mySize1, mySize2)
# Choose the rule for stopping
myStopping1 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
myStopping2 <- StoppingMinPatients(nPatients = 50)
myStopping <- (myStopping1 | myStopping2)
# Choose the safety window
mysafetywindow <- SafetyWindowConst(c(6, 2), 7, 7)
# Initialize the design
design <- DADesign(
model = model,
increments = myIncrements,
nextBest = myNextBest,
stopping = myStopping,
cohort_size = mySize,
data = emptydata,
safetyWindow = mysafetywindow,
startingDose = 3
)
set.seed(4235)
# MCMC parameters are set to small values only to show this example. They should be
# increased for a real case.
# This procedure will take a while.
options <- McmcOptions(
burnin = 10,
step = 1,
samples = 100,
rng_kind = "Mersenne-Twister",
rng_seed = 12
)
testthat::expect_warning(
result <- examine(design, mcmcOptions = options, maxNoIncrement = 2),
"Stopping because 2 times no increment"
)
# nolint end
Fit method for the Samples class
Description
Note this new generic function is necessary because the fitted
function only allows the first argument object to appear in the
signature. But we need also other arguments in the signature.
Usage
fit(object, model, data, ...)
## S4 method for signature 'Samples,GeneralModel,Data'
fit(
object,
model,
data,
points = data@doseGrid,
quantiles = c(0.025, 0.975),
middle = mean,
...
)
## S4 method for signature 'Samples,DualEndpoint,DataDual'
fit(object, model, data, quantiles = c(0.025, 0.975), middle = mean, ...)
## S4 method for signature 'Samples,LogisticIndepBeta,Data'
fit(
object,
model,
data,
points = data@doseGrid,
quantiles = c(0.025, 0.975),
middle = mean,
...
)
## S4 method for signature 'Samples,Effloglog,DataDual'
fit(
object,
model,
data,
points = data@doseGrid,
quantiles = c(0.025, 0.975),
middle = mean,
...
)
## S4 method for signature 'Samples,EffFlexi,DataDual'
fit(
object,
model,
data,
points = data@doseGrid,
quantiles = c(0.025, 0.975),
middle = mean,
...
)
## S4 method for signature 'Samples,LogisticLogNormalOrdinal,DataOrdinal'
fit(
object,
model,
data,
points = data@doseGrid,
quantiles = c(0.025, 0.975),
middle = mean,
...
)
Arguments
object |
the |
model |
the |
data |
the |
... |
passed down to the |
points |
at which dose levels is the fit requested? default is the dose grid |
quantiles |
the quantiles to be calculated (default: 0.025 and 0.975) |
middle |
the function for computing the middle point. Default:
|
Value
the data frame with required information (see method details)
Functions
-
fit(object = Samples, model = GeneralModel, data = Data): This method returns a data frame with dose, middle, lower and upper quantiles for the dose-toxicity curve -
fit(object = Samples, model = DualEndpoint, data = DataDual): This method returns a data frame with dose, and middle, lower and upper quantiles, for both the dose-tox and dose-biomarker (suffix "Biomarker") curves, for all grid points (Note that currently only the grid points can be used, because the DualEndpointRW models only allow that) -
fit(object = Samples, model = LogisticIndepBeta, data = Data): This method return a data frame with dose, middle lower and upper quantiles for the dose-DLE curve using DLE samples for “LogisticIndepBeta” model class -
fit(object = Samples, model = Effloglog, data = DataDual): This method returns a data frame with dose, middle, lower, upper quantiles for the dose-efficacy curve using efficacy samples for “Effloglog” model class -
fit(object = Samples, model = EffFlexi, data = DataDual): This method returns a data frame with dose, middle, lower and upper quantiles for the dose-efficacy curve using efficacy samples for “EffFlexi” model class -
fit(object = Samples, model = LogisticLogNormalOrdinal, data = DataOrdinal): This method returns a data frame with dose, middle, lower and upper quantiles for the dose-efficacy curve using efficacy samples for the “LogisticLogNormalOrdinal” model class
Examples
# nolint start
# Create some data
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),
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 a model
model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Get posterior for all model parameters
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Extract the posterior mean (and empirical 2.5 and 97.5 percentile)
# for the prob(DLT) by doses
fitted <- fit(
object = samples,
model = model,
data = data,
quantiles = c(0.025, 0.975),
middle = mean
)
# ----------------------------------------------
# A different example using a different model
## we need a data object with doses >= 1:
data <- Data(
x = c(25, 50, 50, 75, 150, 200, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
doseGrid = seq(from = 25, to = 300, by = 25)
)
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
## samples must be from 'Samples' class (object slot in fit)
samples <- mcmc(data, model, options)
fitted <- fit(object = samples, model = model, data = data)
# nolint end
# nolint start
# Create some data
data <- DataDual(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10, 20, 20, 20, 40, 40, 40, 50, 50, 50),
y = c(0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1),
w = c(
0.31,
0.42,
0.59,
0.45,
0.6,
0.7,
0.55,
0.6,
0.52,
0.54,
0.56,
0.43,
0.41,
0.39,
0.34,
0.38,
0.21
),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Initialize the Dual-Endpoint model (in this case RW1)
model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# Set-up some MCMC parameters and generate samples from the posterior
options <- McmcOptions(burnin = 100, step = 2, samples = 500)
set.seed(94)
samples <- mcmc(data, model, options)
# Extract the posterior mean (and empirical 2.5 and 97.5 percentile)
# for the prob(DLT) by doses and the Biomarker by doses
fitted <- fit(
object = samples,
model = model,
data = data,
quantiles = c(0.025, 0.975),
middle = mean
)
# nolint end
##Obtain the 'fit' the middle, uppper and lower quantiles for the dose-DLE curve
## at all dose levels using a DLE sample, a DLE model and the data
## samples must be from 'Samples' class (object slot)
## we need a data object with doses >= 1:
data <- Data(
x = c(25, 50, 50, 75, 150, 200, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
doseGrid = seq(from = 25, to = 300, by = 25)
)
## model must be from 'Model' or 'ModelTox' class e.g using 'LogisticIbdepBeta' model class
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
##options for MCMC
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
## samples must be from 'Samples' class (object slot in fit)
samples <- mcmc(data, model, options)
fit(object = samples, model = model, data = data)
##Obtain the 'fit' the middle, uppper and lower quantiles for the dose-efficacy curve
## at all dose levels using an efficacy sample, a pseudo efficacy model and the data
## data must be from 'DataDual' class
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
## model must be from 'ModelEff' e.g using 'Effloglog' class
Effmodel <- Effloglog(
c(1.223, 2.513),
c(25, 300),
nu = c(a = 1, b = 0.025),
data = data,
c = 0
)
## samples must be from 'Samples' class (object slot in fit)
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
Effsamples <- mcmc(data = data, model = Effmodel, options = options)
fit(object = Effsamples, model = Effmodel, data = data)
# nolint start
##Obtain the 'fit' the middle, uppper and lower quantiles for the dose-efficacy curve
## at all dose levels using an efficacy sample, the 'EffFlexi' efficacy model and the data
## data must be from 'DataDual' class
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
## model must be from 'ModelEff' e.g using 'Effloglog' class
Effmodel <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = data
)
## samples must be from 'Samples' class (object slot in fit)
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
Effsamples <- mcmc(data = data, model = Effmodel, options = options)
fit(object = Effsamples, model = Effmodel, data = data)
# nolint end
model <- .DefaultLogisticLogNormalOrdinal()
ordinal_data <- .DefaultDataOrdinal()
options <- .DefaultMcmcOptions()
samples <- mcmc(ordinal_data, model, options)
grade1_fit <- fit(samples, model, ordinal_data, grade = 1L)
grade2_fit <- fit(samples, model, ordinal_data, grade = 2L)
Get the fitted values for the gain values at all dose levels based on a given pseudo DLE model, DLE sample, a pseudo efficacy model, a Efficacy sample and data. This method returns a data frame with dose, middle, lower and upper quantiles of the gain value samples
Description
Get the fitted values for the gain values at all dose levels based on a given pseudo DLE model, DLE sample, a pseudo efficacy model, a Efficacy sample and data. This method returns a data frame with dose, middle, lower and upper quantiles of the gain value samples
Usage
fitGain(DLEmodel, DLEsamples, Effmodel, Effsamples, data, ...)
## S4 method for signature 'ModelTox,Samples,ModelEff,Samples,DataDual'
fitGain(
DLEmodel,
DLEsamples,
Effmodel,
Effsamples,
data,
points = data@doseGrid,
quantiles = c(0.025, 0.975),
middle = mean,
...
)
Arguments
DLEmodel |
the DLE pseudo model of |
DLEsamples |
the DLE samples of |
Effmodel |
the efficacy pseudo model of |
Effsamples |
the efficacy samples of |
data |
the data input of |
... |
additional arguments for methods |
points |
at which dose levels is the fit requested? default is the dose grid |
quantiles |
the quantiles to be calculated (default: 0.025 and 0.975) |
middle |
the function for computing the middle point. Default:
|
Functions
-
fitGain( DLEmodel = ModelTox, DLEsamples = Samples, Effmodel = ModelEff, Effsamples = Samples, data = DataDual ): This method returns a data frame with dose, middle, lower, upper quantiles for the gain values obtained given the DLE and the efficacy samples
Examples
##Obtain the 'fitGain' the middle, uppper and lower quantiles for the samples of gain values
## at all dose levels using a pseudo DLE model, a DLE sample, a pseudo Efficacy model and
## a efficacy sample
## data must be from 'DataDual' class
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
## DLE model must be from 'ModelTox' class e.g using 'LogisticIndepBeta' model
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## Efficacy model must be from 'ModelEff' class e.g using 'Effloglog' model
Effmodel <- Effloglog(
c(1.223, 2.513),
c(25, 300),
nu = c(a = 1, b = 0.025),
data = data,
c = 0
)
## samples must be from 'Samples' class (object slot in fit)
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
##set up the same data set in class 'Data' for MCMC sampling for DLE
data1 <- Data(x = data@x, y = data@y, doseGrid = data@doseGrid)
DLEsamples <- mcmc(data = data1, model = DLEmodel, options = options)
Effsamples <- mcmc(data = data, model = Effmodel, options = options)
fitGain(
DLEmodel = DLEmodel,
DLEsamples = DLEsamples,
Effmodel = Effmodel,
Effsamples = Effsamples,
data = data
)
##Obtain the 'fitGain' the middle, uppper and lower quantiles for the samples of gain values
## at all dose levels using a pseudo DLE model, a DLE sample, a pseudo Efficacy model and
## a efficacy sample
## data must be from 'DataDual' class
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
## DLE model must be from 'ModelTox' class e.g using 'LogisticIndepBeta' model
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## Efficacy model must be from 'ModelEff' class e.g using 'Effloglog' model
Effmodel <- Effloglog(
c(1.223, 2.513),
c(25, 300),
nu = c(a = 1, b = 0.025),
data = data,
c = 0
)
## samples must be from 'Samples' class (object slot in fit)
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
##set up the same data set in class 'Data' for MCMC sampling for DLE
data1 <- Data(x = data@x, y = data@y, doseGrid = data@doseGrid)
DLEsamples <- mcmc(data = data1, model = DLEmodel, options = options)
Effsamples <- mcmc(data = data, model = Effmodel, options = options)
fitGain(
DLEmodel = DLEmodel,
DLEsamples = DLEsamples,
Effmodel = Effmodel,
Effsamples = Effsamples,
data = data
)
Get the fitted DLT free survival (piecewise exponential model).
This function returns a data frame with dose, middle, lower and upper
quantiles for the PEM curve. If hazard=TRUE,
Description
Get the fitted DLT free survival (piecewise exponential model).
This function returns a data frame with dose, middle, lower and upper
quantiles for the PEM curve. If hazard=TRUE,
Usage
fitPEM(
object,
model,
data,
quantiles = c(0.025, 0.975),
middle = mean,
hazard = FALSE,
...
)
## S4 method for signature 'Samples,DALogisticLogNormal,DataDA'
fitPEM(
object,
model,
data,
quantiles = c(0.025, 0.975),
middle = mean,
hazard = FALSE,
...
)
Arguments
object |
mcmc samples |
model |
the mDA-CRM model |
data |
the data input, a |
quantiles |
the quantiles to be calculated (default: 0.025 and 0.975) |
middle |
the function for computing the middle point. Default:
|
hazard |
should the the hazard over time be plotted based on the |
... |
additional arguments for methods |
Functions
-
fitPEM(object = Samples, model = DALogisticLogNormal, data = DataDA): This method works for theDALogisticLogNormalmodel class.
Examples
# nolint start
# Create the data
data <- DataDA(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 1, 1, 0, 0, 1, 0),
ID = 1L:8L,
cohort = as.integer(c(1:5, 6, 6, 6)),
doseGrid = c(
0.1,
0.5,
1.5,
3,
6,
seq(from = 10, to = 80, by = 2)
),
u = c(42, 30, 15, 5, 20, 25, 30, 60),
t0 = c(0, 15, 30, 40, 55, 70, 75, 85),
Tmax = 60
)
# Initialize the CRM model used to model the data
npiece_ <- 10
lambda_prior <- function(k) {
npiece_ / (data@Tmax * (npiece_ - k + 0.5))
}
model <- DALogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56,
npiece = npiece_,
l = as.numeric(t(apply(
as.matrix(c(1:npiece_), 1, npiece_),
2,
lambda_prior
))),
c_par = 2
)
# Obtain the posterior
options <- McmcOptions(
burnin = 10,
step = 2,
samples = 1e2
)
set.seed(94)
samples <- mcmc(data, model, options)
# Extract the posterior mean hazard (and empirical 2.5 and 97.5 percentile)
# for the piecewise exponential model
# If hazard=FALSE, the posterior PEM will be plot
fitted <- fitPEM(
object = samples,
model = model,
data = data,
middle = mean,
hazard = TRUE,
quantiles = c(0.25, 0.75)
)
# nolint end
Compute Gain Values based on Pseudo DLE and a Pseudo Efficacy Models and Using Optional Samples.
Description
Usage
gain(dose, model_dle, samples_dle, model_eff, samples_eff, ...)
## S4 method for signature 'numeric,ModelTox,Samples,ModelEff,Samples'
gain(dose, model_dle, samples_dle, model_eff, samples_eff, ...)
## S4 method for signature 'numeric,ModelTox,missing,Effloglog,missing'
gain(dose, model_dle, samples_dle, model_eff, samples_eff, ...)
Arguments
dose |
( |
model_dle |
( |
samples_dle |
( |
model_eff |
( |
samples_eff |
( |
... |
not used. |
Details
This function computes the gain values for a given dose level, pseudo DLE and Efficacy models as well as a given DLE and Efficacy samples.
Value
The gain values.
Functions
-
gain( dose = numeric, model_dle = ModelTox, samples_dle = Samples, model_eff = ModelEff, samples_eff = Samples ): -
gain( dose = numeric, model_dle = ModelTox, samples_dle = missing, model_eff = Effloglog, samples_eff = missing ): Compute the gain value for a given dose level, pseudo DLE and Efficacy models without DLE and the Efficacy samples.
Examples
# Obtain the gain value for a given dose, a pseudo DLE and efficacy models
# as well as DLE and efficacy samples.
emptydata <- DataDual(doseGrid = seq(25, 300, 25), placebo = FALSE)
mcmc_opts <- McmcOptions(burnin = 100, step = 2, samples = 200)
# DLE model and samples.
model_dle <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = emptydata
)
samples_dle <- mcmc(emptydata, model_dle, mcmc_opts)
# Efficacy model (Effloglog) and samples.
model_effloglog <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = emptydata
)
samples_effloglog <- mcmc(emptydata, model_effloglog, mcmc_opts)
# Gain values for dose level 75 and Effloglog efficacy model.
gain(
dose = 75,
model_dle = model_dle,
samples_dle = samples_dle,
model_eff = model_effloglog,
samples_eff = samples_effloglog
)
# Efficacy model (EffFlexi) and samples.
model_effflexi <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = emptydata
)
samples_effflexi <- mcmc(emptydata, model_effflexi, mcmc_opts)
# Gain values for dose level 75 and EffFlexi efficacy model.
gain(
dose = 75,
model_dle = model_dle,
samples_dle = samples_dle,
model_eff = model_effflexi,
samples_eff = samples_effflexi
)
# Obtain the gain value for a given dose, a pseudo DLE and efficacy models
# without DLE and efficacy samples.
emptydata <- DataDual(doseGrid = seq(25, 300, 25), placebo = FALSE)
data <- Data(doseGrid = seq(25, 300, 25), placebo = FALSE)
mcmc_opts <- McmcOptions(burnin = 100, step = 2, samples = 200)
# DLE model and samples.
model_dle <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
# Efficacy model and samples.
model_eff <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = emptydata
)
# Gain value for dose level 75.
gain(
dose = 75,
model_dle = model_dle,
model_eff = model_eff
)
Get specific parameter samples and produce a data.frame
Description
Here you have to specify with pos which
parameter you would like to extract from the Samples
object
Usage
## S4 method for signature 'Samples,character'
get(x, pos = -1L, envir = NULL, mode = NULL, inherits = NULL)
Arguments
x |
the |
pos |
the name of the parameter |
envir |
for vectorial parameters, you can give the indices of the
elements you would like to extract. If |
mode |
not used |
inherits |
not used |
Value
the data frame suitable for use with ggmcmc
Examples
# nolint start
# Create some data
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),
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 a model
model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Get posterior for all model parameters
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# now extract the alpha0 samples (intercept of the regression model)
alpha0samples <- get(samples, "alpha0")
# nolint end
Extracting Efficacy Responses for Subjects Categorized by the DLT
Description
A method that extracts efficacy responses for subjects and categorizes it with respect to DLT, i.e. DLT or no DLT. The efficacy responses are reported together with their corresponding dose levels.
Usage
getEff(object, ...)
## S4 method for signature 'DataDual'
getEff(object, no_dlt = FALSE)
Arguments
object |
( |
... |
further arguments passed to class-specific methods. |
no_dlt |
( |
Value
list with efficacy responses categorized by the DLT value.
Examples
# Example data.
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25)
)
# Get the efficacy response and their corresponding dose levels
# categorized by the DLT.
getEff(data)
Helper Function to Obtain Simulation Results List
Description
The function fun can use variables that are visible to itself.
The names of these variables have to be given in the vector vars.
Usage
get_result_list(fun, nsim, vars, parallel, n_cores)
Arguments
fun |
( |
nsim |
number of simulations to be conducted. |
vars |
names of the variables. |
parallel |
should the simulation runs be parallelized across the clusters of the computer? |
n_cores |
how many cores should be used for parallel computing? |
Value
The list with all simulation results (one iteration corresponds to one list element).
Comparison with Numerical Tolerance and Without Name Comparison
Description
This helper function ensures a default tolerance level equal to 1e-10,
and ignores names and other attributes.
In contrast to all.equal(), it always returns a logical type object.
Usage
h_all_equivalent(target, current, tolerance = 1e-10)
Arguments
target |
( |
current |
( |
tolerance |
( |
Value
TRUE when target and current do not differ
up to desired tolerance and without looking at names or other attributes,
FALSE otherwise.
Convenience function to make barplots of percentages
Description
Convenience function to make barplots of percentages
Usage
h_barplot_percentages(x, description, xaxisround = 0)
Arguments
x |
vector of samples |
description |
xlab string |
xaxisround |
rounding for xaxis labels (default: 0, i.e. integers will be used) |
Value
the ggplot2 object
Helper Function to Blind Plot Data
Description
Helper Function to Blind Plot Data
Usage
h_blind_plot_data(df, blind, has_placebo, pbo_dose)
Arguments
df |
( |
blind |
( |
has_placebo |
( |
pbo_dose |
( |
Value
The blinded data
Helper function to calculate percentage of true stopping rules for
report label output
calculates true column means and converts output into percentages
before combining the output with the report label; output is passed
to show() and output with cat to console
Description
Helper function to calculate percentage of true stopping rules for
report label output
calculates true column means and converts output into percentages
before combining the output with the report label; output is passed
to show() and output with cat to console
Usage
h_calc_report_label_percentage(stop_report)
Arguments
stop_report |
object from summary method |
Value
named list with label and percentage of rule activation
Checking Formals of a Function
Description
This helper function checks whether a given function fun has required or
allowed arguments. The argument check is based only on the names of the
arguments. No any further logic is verified here.
Usage
h_check_fun_formals(fun, mandatory = NULL, allowed = NULL)
Arguments
fun |
( |
mandatory |
( |
allowed |
( |
Convert a Ordinal Data to the Equivalent Binary Data for a Specific Grade
Description
A simple helper function that takes a DataOrdinal object and an
integer grade and converts them to the equivalent Data object.
Usage
h_convert_ordinal_data(data_ord, grade)
Arguments
data_ord |
( |
grade |
( |
Value
A Data object.
Convert an ordinal CRM model to the Equivalent Binary CRM Model for a Specific Grade
Description
A simple helper function that takes a LogisticLogNormalOrdinal and an
integer grade and converts them to the equivalent LogisticLogNormal model.
Usage
h_convert_ordinal_model(x, grade)
Arguments
x |
( |
grade |
( |
Value
A LogisticLogNormal model.
Convert a Samples Object from an ordinal Model to the Equivalent Samples Object from a Binary Model
Description
A simple helper function that converts a Samples object from the fit of an
ordinal CRM model to that which would have been obtained from fitting a binary
CRM model for toxicities of a specified grade to the same observed data.
Usage
h_convert_ordinal_samples(obj, grade)
Arguments
obj |
( |
grade |
( |
Value
A Samples object.
Helpers for stripping expressions of covr-inserted trace code
Description
Workarounds to allow the package to continue to work while running covr
with minimal changes to the package code.
Usage
h_covr_active()
h_covr_detrace(expr)
h_is_covr_trace(expr)
h_covr_detrace_call(expr)
Arguments
expr |
( |
Details
When using covr, the source code for package objects are modified to add
callbacks for each expression to log its execution. Given an arbitrary
expression, such as:
expr
The code will be modified before executing any package code to look like:
if (TRUE) {
covr:::count("file.R:1:2:3:4:5:6:7:8")
expr
}
These functions are used for stripping expressions of this code so that the
package continues to work as intended while running tests as part of running
covr to calculate package coverage.
This method is non-exhaustive, covering only a subset of covr's tracing
behaviors necessary for this package.
Value
A logical value or transformed expression with calls to
covr:::count removed.
Functions
-
h_covr_active(): Determine whethercovris currently running -
h_covr_detrace(): Removecovrtraces from an expression -
h_is_covr_trace(): Determine whether the current expression is acovr-modified expression -
h_covr_detrace_call(): Extract the original expression from acovr-modified expression
Getting the default value for an empty object
Description
A simple helper function that sets a default value for an empty or missing object,
that is an object for which length() function returns 0L or it has length 1
and is.na() returns TRUE.
Usage
h_default_if_empty(x, default)
Arguments
x |
( |
default |
( |
Examples
h_default_if_empty(character(0), default = "default label")
h_default_if_empty("custom label", default = "default label")
h_default_if_empty(NA, default = "default label")
Helper function to determine the dlts including first separate and placebo condition
Description
Helper function to determine the dlts including first separate and placebo condition
Usage
h_determine_dlts(
data,
dose,
prob,
prob_placebo,
cohort_size,
cohort_size_placebo,
dose_grid,
first_separate
)
Arguments
data |
( |
dose |
( |
prob |
( |
prob_placebo |
( |
cohort_size |
( |
cohort_size_placebo |
( |
dose_grid |
( |
first_separate |
( |
Value
updated data object
Find Interval Numbers or Indices and Return Custom Number For 0.
Description
A simple wrapper of findInterval() function that invokes
findInterval(), takes its output and replaces all the
elements with 0 value to a custom number as specified in replacement
argument.
Usage
h_find_interval(..., replacement = -Inf)
Arguments
... |
Arguments passed on to
|
replacement |
( |
Examples
h_find_interval(1, c(2, 4, 6))
h_find_interval(3, c(2, 4, 6))
h_find_interval(1, c(2, 4, 6), replacement = -1)
Conditional Formatting Using C-style Formats
Description
This helper function conditionally formats a number with formatC()
function using "E" format and specific number of digits as given by the
user. A number is formatted if and only if its absolute value is less than
0.001 or greater than 10000. Otherwise, the number is not formatted.
Additionally, custom prefix or suffix can be appended to character string
with formatted number, so that the changes are marked.
Usage
h_format_number(x, digits = 5, prefix = "", suffix = "")
Arguments
x |
( |
digits |
( |
prefix |
( |
suffix |
( |
Value
Either formatted x as string or unchanged x if the
formatting condition is not met.
Note
This function was primarily designed as a helper for
h_jags_write_model() function.
Examples
h_format_number(50000)
h_format_number(50000, prefix = "P", suffix = "S")
Format a doseGrid for Printing
Description
Format a doseGrid for Printing
Usage
h_get_formatted_dosegrid(grid, units = NA, fmt = NA, ...)
Arguments
grid |
( |
units |
( |
fmt |
( |
... |
not used at present
measured. Appended to each value in |
Value
A character string containing the formatted dose grid. If the grid
is c(1, 2, 3) and units is "mg", the returned value is "1 mg, 2 mg and 3 mg".
Helper for Minimal Informative Unimodal Beta Distribution
Description
As defined in Neuenschwander et al. (2008), this function
computes the parameters of the minimal informative unimodal beta distribution, given the
request that the p-quantile should be q, i.e. X ~ Be(a, b) with
Pr(X <= q) = p.
Usage
h_get_min_inf_beta(p, q)
Arguments
p |
( |
q |
( |
Value
A list with the two resulting beta parameters a and b.
References
Neuenschwander B, Branson M, Gsponer T (2008). “Critical aspects of the Bayesian approach to phase I cancer trials.” Statistics in Medicine, 27(13), 2420–2439. https://onlinelibrary.wiley.com/doi/10.1002/sim.3230.
Get Starting Values for Quantiles Optimization
Description
Get Starting Values for Quantiles Optimization
Usage
h_get_quantiles_start_values(parstart, median, dosegrid, refDose, logNormal)
Arguments
parstart |
( |
median |
( |
dosegrid |
( |
refDose |
( |
logNormal |
( |
Value
Numeric vector of starting values.
Group Together Mono and Combo Data
Description
This is only used in the simulation method for DesignGrouped to combine
the separately generated data sets from mono and combo arms and to fit the
combined logistic regression model.
Hence the ID and cohort information is not relevant and will be
arbitrarily assigned to avoid problems with the DataGrouped validation.
Usage
h_group_data(mono_data, combo_data)
Arguments
mono_data |
( |
combo_data |
( |
Value
A DataGrouped object containing both mono_data and combo_data,
but with arbitrary ID and cohort slots.
Check which elements are in a given range
Description
A simple helper function that tests whether elements of a given vector or matrix are within specified interval.
Usage
h_in_range(x, range = c(0, 1), bounds_closed = TRUE)
Arguments
x |
( |
range |
( |
bounds_closed |
( |
Value
A logical vector or matrix of length equal to the length of x, that
for every element of x, indicates whether a given element of x is in
the range.
Examples
x <- 1:4
h_in_range(x, range = c(1, 3))
h_in_range(x, range = c(1, 3), bounds_closed = FALSE)
h_in_range(x, range = c(1, 3), bounds_closed = c(FALSE, TRUE))
mat <- matrix(c(2, 5, 3, 10, 4, 9, 1, 8, 7), nrow = 3)
h_in_range(mat, range = c(1, 5))
Calculating the Information Theoretic Distance
Description
Helper function which provides the value of the divergence as given by equation in (7) in the reference at https://doi.org/10.1002/sim.8450.
Usage
h_info_theory_dist(prob, target, asymmetry)
Arguments
prob |
( |
target |
( |
asymmetry |
( |
Examples
h_info_theory_dist(c(0.5, 0.2), 0.4, 1.2)
Testing Matrix for Positive Definiteness
Description
This helper function checks whether a given numerical matrix x is a
positive-definite square matrix of a given size, without any missing
values. This function is used to test if a given matrix is a covariance
matrix, since every symmetric positive semi-definite matrix is a covariance
matrix.
Usage
h_is_positive_definite(x, size = 2, tol = 1e-06)
Arguments
x |
( |
size |
( |
tol |
( |
Details
The positive definiteness test implemented in this function
is based on the following characterization valid for real matrices:
A symmetric matrix is positive-definite if and only if all of its eigenvalues are positive. In this function an eigenvalue is considered
as positive if and only if it is greater than the tol.
Value
TRUE if a given matrix is a positive-definite, FALSE otherwise.
Appending a Dummy Number for Selected Slots in Data
Description
A helper function that appends a dummy value to a given slots in GeneralData
class object, if and only if the total number of observations (as indicated
by object@nObs) equals to 1. Otherwise, the object is not changed.
Usage
h_jags_add_dummy(object, where, dummy = 0)
Arguments
object |
( |
where |
( |
dummy |
( |
Value
A GeneralData object with slots updated with dummy number.
Note
The main motivation behind this function is related to the JAGS.
If there is only one observation, the data is not passed correctly to
JAGS, i.e. e.g. x and y are treated like scalars in the data file.
Therefore it is necessary to add dummy values to the vectors in this case
As we don't change the number of observations (nObs), this addition of
zeros doesn't affect the results of JAGS computations.
Examples
# Create some data of class 'Data'
my_data <- Data(
x = 0.1,
y = 0,
doseGrid = c(0.1, 0.5)
)
my_data_2 <- Data(
x = c(0.1, 0.5),
y = c(0, 1),
doseGrid = c(0.1, 0.5)
)
# Append dummy to `x` and `y`.
h_jags_add_dummy(my_data, where = c("x", "y"))
# Append dummy to `x` and `y`. No effect as `my_data_2@nObs != 1`.
h_jags_add_dummy(my_data_2, where = c("x", "y"))
Extracting Samples from JAGS mcarray Object
Description
A simple helper function that extracts a sample from
rjags::mcarray.object S3 class object. The rjags::mcarray.object
object is used by the rjags::jags.samples() function to represent MCMC
output from a JAGS model.
Usage
h_jags_extract_samples(x)
Arguments
x |
an |
Getting Data for JAGS
Description
A simple helper function that prepares an object for data argument of
rjags::jags.model(), which is invoked by mcmc() method.
Usage
h_jags_get_data(model, data, from_prior)
Arguments
model |
( |
data |
( |
from_prior |
( |
Examples
# Create some data from the class `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),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Initialize the CRM model.
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
jags_data <- h_jags_get_data(my_model, my_data, from_prior = FALSE)
jags_data
Setting Initial Values for JAGS Model Parameters
Description
A simple helper function that prepares an object for inits argument of
rjags::jags.model(), which is invoked by mcmc() method. The inits
argument specifies initial values for model parameters.
Usage
h_jags_get_model_inits(model, data)
Arguments
model |
( |
data |
( |
Value
A list of starting values for parameters required to be initialized
in the MCMC JAGS sampler.
Examples
# Create some data from the class `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),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Initialize the CRM model.
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
h_jags_get_model_inits(model = my_model, data = my_data)
Joining JAGS Models
Description
This helper function joins two JAGS models in the way that the body of the
second model is appended to the body of the first model (in this order).
After that, the first, body-extended model is returned. The arguments of
model1, model2 model functions (if any) are not combined in any way.
Usage
h_jags_join_models(model1, model2)
Arguments
model1 |
( |
model2 |
( |
Value
joined models.
Note
model1 and model2 functions must have a multi-expression
body, i.e. braced expression(s). Environments or any attributes of the
function bodies are not preserved in any way after joining.
Writing JAGS Model to a File
Description
This function converts a R function with JAGS model into a text and then
writes it into a given file. During the "model into text" conversion, the
format of numbers of which absolute value is less than 0.001 or greater
than 10000 is changed. These numbers will be converted into scientific
format with specified number of significant digits using formatC()
function.
Usage
h_jags_write_model(model, file = NULL, digits = 5)
Arguments
model |
( |
file |
( |
digits |
( |
Value
The name of the file where the model was saved.
Note
JAGS syntax allows truncation specification like dnorm(...) I(...),
which is illegal in R. To overcome this incompatibility, use dummy operator
\%_\% before I(...), i.e. dnorm(...) \%_\% I(...) in the model's
code. This dummy operator \%_\% will be removed just before saving the
JAGS code into a file.
Due to technical issues related to conversion of numbers to scientific
format, it is required that the body of a model function does not contain
TEMP_NUM_PREF_ or _TEMP_NUM_SUF character constants in its body.
Examples
# Some model function
my_model <- function() {
alpha0 <- mean(1:10)
alpha1 <- 600000
}
h_jags_write_model(my_model, digits = 5)
Used to obtain expected format.
Description
Used to obtain expected format.
Usage
h_knit_format_func(x)
Update certain components of DualEndpoint model with regard to parameters
of the function that models dose-biomarker relationship defined in the
DualEndpointBeta class.
Description
A simple helper function that takes DualEndpoint object and updates
use_fixed, priormodel, modelspecs, init, sample slots with regard
to a given parameter of the dose-biomarker relationship f(x) defined in
the DualEndpointBeta class. This update solely depends on whether a given
parameter's value param is a fixed-valued scalar or two-elements numeric
vector. In the later case, it is assumed that param represents two
parameters of a probability distribution that will be used in priormodel
function to generate values for the param_name parameter of f(x).
See the help page for DualEndpointBeta class for more details.
Usage
h_model_dual_endpoint_beta(
param,
param_name,
param_suffix = c("_low", "_high"),
priormodel = NULL,
de
)
Arguments
param |
( |
param_name |
( |
param_suffix |
( |
priormodel |
( |
de |
( |
Value
A DualEndpoint model with updated use_fixed, priormodel,
modelspecs, init, sample slots.
Update DualEndpoint class model components with regard to DLT and biomarker
correlation.
Description
A simple helper function that takes DualEndpoint model existing components
(priormodel, modelspecs, init, sample), and updates them with regard to
DLT and biomarker correlation rho.
Usage
h_model_dual_endpoint_rho(use_fixed, rho, comp)
Arguments
use_fixed |
( |
rho |
( |
comp |
( |
Value
A list with updated model components.
Update certain components of DualEndpoint model with regard to prior variance
factor of the random walk.
Description
A simple helper function that takes DualEndpoint object and updates
priormodel, modelspecs, init, sample slots according to the random walk
variance.
Usage
h_model_dual_endpoint_sigma2betaw(use_fixed, sigma2betaW, de)
Arguments
use_fixed |
( |
sigma2betaW |
( |
de |
( |
Value
A DualEndpoint model with updated priormodel, modelspecs,
init, sample slots.
See Also
Update DualEndpoint class model components with regard to biomarker
regression variance.
Description
A simple helper function that takes DualEndpoint model existing components
(priormodel, modelspecs, init, sample), and updates them with regard to
to biomarker regression variance sigma2W.
Usage
h_model_dual_endpoint_sigma2w(use_fixed, sigma2W, comp)
Arguments
use_fixed |
( |
sigma2W |
( |
comp |
( |
Value
list with updated model components.
Get Eligible Doses from the Dose Grid.
Description
Helper function that gets the eligible doses from the dose grid.
The eligible doses are the doses which do not exceed a given
doselimit. For placebo design, if safety allows (i.e. if there is at least
one non-placebo dose which does not exceed the dose limit), the placebo dose
is then excluded from the eligible doses.
Usage
h_next_best_eligible_doses(dose_grid, doselimit, placebo, levels = FALSE)
Arguments
dose_grid |
( |
doselimit |
( |
placebo |
( |
levels |
( |
Value
A numeric vector with eligible doses or eligible dose levels if levels
flag is TRUE.
Examples
dose_grid <- c(0.001, seq(25, 200, 25))
h_next_best_eligible_doses(dose_grid, 79, TRUE)
h_next_best_eligible_doses(dose_grid, 24, TRUE)
Credibility Intervals for Max Gain and Target Doses at nextBest-NextBestMaxGain Method.
Description
Helper function for nextBest-NextBestMaxGain() method. It computes a
95% credibility intervals for given target dose and max gain dose.
It also returns a ratio of upper and lower bounds of the interval.
Usage
h_next_best_mg_ci(dose_target, dose_mg, prob_target, placebo, model, model_eff)
Arguments
dose_target |
( |
dose_mg |
( |
prob_target |
( |
placebo |
( |
model |
( |
model_eff |
( |
References
Yeung WY, Whitehead J, Reigner B, Beyer U, Diack C, Jaki T (2015). “Bayesian adaptive dose-escalation procedure for binary and continuous responses utilizing a gain function.” Pharmaceutical Statistics. doi:10.1002/pst.1706, Published online ahead of print.
Get Closest Grid Doses for a Given Target Doses for nextBest-NextBestMaxGain Method.
Description
Helper function that for a given target doses finds the dose in grid that is
closest and below the target. There are four different targets in the context
of nextBest-NextBestMaxGain() method: min(`dose_mg`, `dose_target_drt`),
dose_mg, dose_target_drt or dose_target_eot.
Usage
h_next_best_mg_doses_at_grid(
dose_target_drt,
dose_target_eot,
dose_mg,
dose_grid,
doselimit,
placebo
)
Arguments
dose_target_drt |
( |
dose_target_eot |
( |
dose_mg |
( |
dose_grid |
( |
doselimit |
( |
placebo |
( |
Building the Plot for nextBest-NextBestMaxGain Method.
Description
Helper function which creates the plot for nextBest-NextBestMaxGain() method.
Usage
h_next_best_mg_plot(
prob_target_drt,
dose_target_drt,
prob_target_eot,
dose_target_eot,
dose_mg,
max_gain,
next_dose,
doselimit,
data,
model,
model_eff
)
Arguments
prob_target_drt |
( |
dose_target_drt |
( |
prob_target_eot |
( |
dose_target_eot |
( |
dose_mg |
( |
max_gain |
( |
next_dose |
( |
doselimit |
( |
data |
( |
model |
( |
model_eff |
( |
Building the Plot for nextBest-NextBestMaxGainSamples Method.
Description
Helper function which creates the plot for nextBest-NextBestMaxGainSamples() method.
Usage
h_next_best_mgsamples_plot(
prob_target_drt,
dose_target_drt,
prob_target_eot,
dose_target_eot,
dose_mg,
dose_mg_samples,
next_dose,
doselimit,
dose_grid_range
)
Arguments
prob_target_drt |
( |
dose_target_drt |
( |
prob_target_eot |
( |
dose_target_eot |
( |
dose_mg |
( |
dose_mg_samples |
( |
next_dose |
( |
doselimit |
( |
dose_grid_range |
( |
Building the Plot for nextBest-NextBestNCRMLoss Method.
Description
Helper function which creates the plot for nextBest-NextBestNCRMLoss()
method.
Usage
h_next_best_ncrm_loss_plot(
prob_mat,
posterior_loss,
max_overdose_prob,
dose_grid,
max_eligible_dose_level,
doselimit,
next_dose,
is_unacceptable_specified
)
Arguments
prob_mat |
( |
posterior_loss |
( |
max_overdose_prob |
( |
dose_grid |
( |
max_eligible_dose_level |
( |
doselimit |
( |
next_dose |
( |
is_unacceptable_specified |
( |
Building the Plot for nextBest-NextBestTD Method.
Description
Helper function which creates the plot for nextBest-NextBestTD() method.
Usage
h_next_best_td_plot(
prob_target_drt,
dose_target_drt,
prob_target_eot,
dose_target_eot,
data,
prob_dlt,
doselimit,
next_dose
)
Arguments
prob_target_drt |
( |
dose_target_drt |
( |
prob_target_eot |
( |
dose_target_eot |
( |
data |
( |
prob_dlt |
( |
doselimit |
( |
next_dose |
( |
Building the Plot for nextBest-NextBestTDsamples Method.
Description
Helper function which creates the plot for nextBest-NextBestTDsamples()
method.
Usage
h_next_best_tdsamples_plot(
dose_target_drt_samples,
dose_target_eot_samples,
dose_target_drt,
dose_target_eot,
dose_grid_range,
nextBest,
doselimit,
next_dose
)
Arguments
dose_target_drt_samples |
( |
dose_target_eot_samples |
( |
dose_target_drt |
( |
dose_target_eot |
( |
dose_grid_range |
( |
nextBest |
( |
doselimit |
( |
next_dose |
( |
Getting NULL for NA
Description
A simple helper function that replaces NA object by NULL object.
Usage
h_null_if_na(x)
Arguments
x |
( |
Value
NULL if x is NA, otherwise, x.
Examples
h_null_if_na(NA)
Helper Function Containing Common Functionality
Description
Used by dose_grid_range-Data and dose_grid_range-DataOrdinal
Usage
h_obtain_dose_grid_range(object, ignore_placebo)
Arguments
object |
( |
ignore_placebo |
( |
Preparing Cohort Lines for Data Plot
Description
This helper function prepares a ggplot geom with reference lines
separating different cohorts on the plot of Data class object.
Lines are either vertical or horizontal of green color and longdash type.
Usage
h_plot_data_cohort_lines(cohort, placebo, vertical = TRUE)
Arguments
cohort |
( |
placebo |
( |
vertical |
( |
Details
The geom object is returned if and only if placebo is equal to
TRUE and there are more than one unique values in cohort. Otherwise,
this function returns NULL object.
Helper Function for the Plot Method of the Data and DataOrdinal Classes
Description
A method that creates a plot for Data and DataOrdinal objects.
A method that creates a plot for Data object.
A method that creates a plot for DataOrdinal object.
Usage
h_plot_data_dataordinal(
x,
blind = FALSE,
legend = TRUE,
tox_labels = c(Yes = "red", No = "black"),
tox_shapes = c(Yes = 17L, No = 16L),
...
)
## S4 method for signature 'Data,missing'
plot(x, y, blind = FALSE, legend = TRUE, ...)
## S4 method for signature 'DataOrdinal,missing'
plot(
x,
y,
blind = FALSE,
legend = TRUE,
tox_labels = NULL,
tox_shapes = NULL,
...
)
Arguments
x |
( |
blind |
( |
legend |
( |
tox_labels |
( |
tox_shapes |
( |
... |
not used. |
y |
( |
Value
The ggplot2::ggplot2 object.
The ggplot2::ggplot2 object.
The ggplot2::ggplot2 object.
Note
The default values of tox_shapes and tox_labels result in DLTs
being displayed as red triangles and other responses as black circles.
With more than 9 toxicity categories, toxicity symbols must be
specified manually.
With more than 5 toxicity categories, toxicity labels
must be specified manually.
Examples
# Create some data of class 'Data'.
my_data <- Data(
x = c(0.001, 0.1, 0.1, 0.5, 0.001, 3, 3, 0.001, 10, 10, 10),
y = c(0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0),
cohort = c(1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 4),
doseGrid = c(0.001, 0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2)),
placeb = TRUE
)
# Plot the data.
plot(my_data)
data <- DataOrdinal(
x = c(10, 20, 30, 40, 50, 50, 50, 60, 60, 60),
y = as.integer(c(0, 0, 0, 0, 0, 1, 0, 0, 1, 2)),
ID = 1L:10L,
cohort = as.integer(c(1:4, 5, 5, 5, 6, 6, 6)),
doseGrid = c(seq(from = 10, to = 100, by = 10)),
yCategories = c("No tox" = 0L, "Sub-tox AE" = 1L, "DLT" = 2L),
placebo = FALSE
)
plot(data)
Preparing Data for Plotting
Description
This helper function prepares a data.frame object based on Data class
object. The resulting data frame is used by the plot function for Data
class objects.
A method that transforms GeneralData objects into a tibble suitable for
plotting with ggplot2 methods
Usage
h_plot_data_df(data, ...)
h_plot_data_df(data, ...)
## S4 method for signature 'Data'
h_plot_data_df(data, blind = FALSE, legend = TRUE, ...)
## S4 method for signature 'DataOrdinal'
h_plot_data_df(data, blind = FALSE, legend = TRUE, ...)
Arguments
data |
( |
... |
further arguments passed to |
blind |
( |
legend |
( |
Value
A data.frame object with values to plot.
data.frame containing columns for patient, cohort, dose and toxicity grade
A data.frame object with columns patient, ID, cohort, dose and
toxicity.
Methods (by class)
-
h_plot_data_df(Data): method forData. -
h_plot_data_df(DataOrdinal): Class specific method forDataOrdinal
Helper Function to Create Doses Tried Plot
Description
Creates a bar plot showing average proportions of doses tested.
Usage
h_plot_doses_tried(sim_doses, dose_grid)
Arguments
sim_doses |
( |
dose_grid |
( |
Value
A ggplot object.
Helper Function to Create Trajectory Plot
Description
Creates a trajectory plot showing dose level statistics across patients.
Usage
h_plot_simulation_trajectory(sim_doses, max_patients, has_placebo)
Arguments
sim_doses |
( |
max_patients |
( |
has_placebo |
( |
Value
A ggplot object.
Check That Labels Are Valid and Useful
Description
A vector of labels is valid and useful if it is of length 2, of type character and its values are distinct.
Usage
h_prepare_labels(x)
Arguments
x |
( |
Details
If x is a scalar, a second element is added, whose value is the value of the
scalar with "s" appended. If x is "toxicity", the plural is handled appropriately.
Value
a character vector of length 2 whose values are distinct
Append Units to a Numeric Dose
Description
Append Units to a Numeric Dose
Usage
h_prepare_units(units = NA)
Arguments
units |
( |
Value
if units is NA, then NA. Otherwise, units, ensuring that exactly
one space precedes the first non-whitespace character
Helper Function to Calculate Fit Summary
Description
Calculates fit summary statistics for pseudo simulations.
Usage
h_pseudo_sim_fit_summary(fit_list, x_most_selected, dose_grid, truth)
Arguments
fit_list |
( |
x_most_selected |
( |
dose_grid |
( |
truth |
( |
Value
A list with fit_at_dose_most_selected and mean_fit components.
Helper Function to Calculate Inverse Dose
Description
Creates an inverse function to find the dose corresponding to a target probability.
Usage
h_pseudo_sim_inverse_dose(f, lower = -100, upper = 100)
Arguments
f |
( |
lower |
( |
upper |
( |
Value
A function that takes a probability and returns the corresponding dose.
Target Function for Quantiles Optimization
Description
Target Function for Quantiles Optimization
Usage
h_quantiles_target_function(
dosegrid,
refDose,
lower,
median,
upper,
level,
logNormal,
seed
)
Arguments
dosegrid |
( |
refDose |
( |
lower |
( |
median |
( |
upper |
( |
level |
( |
logNormal |
( |
seed |
( |
Value
Function that computes target value for optimization.
Recursively Apply a Function to a List
Description
This helper function recursively iterates through a "list-like" object and it
checks whether an element is of a given class. If it so, then it replaces
that element by the result of an execution of a given function. Otherwise,
and if the element is of length greater than 1 (i.e. not a scalar), it
replaces that element by the result of h_rapply(), recursively called for
that element. In the remaining case, that is, the element is not of a given
class and is a scalar, then that element remains unchanged.
Usage
h_rapply(x, fun, classes, ...)
Arguments
x |
( |
fun |
( |
classes |
( |
... |
further arguments passed to function |
Value
"list-like" object of similar structure as x.
Note
This helper function is conceptually similar the same as rapply()
function. However, it differs from rapply() in two major ways. First, the
h_rapply() is not limited to objects of type list or expression only.
It can be any "list-like" object of any type for which subsetting operator
[[ is defined. This can be, for example, an object of type
language, often obtained from the body() function. The second
difference is that the flexibility of rapply() on how the result is
structured is not available with h_rapply() for the user. That is, with
h_rapply() each element of x, which has a class included in classes,
is replaced by the result of applying fun to the element. This behavior
corresponds to rapply() when invoked with fixed how = replace.
This function was primarily designed as a helper for h_jags_write_model()
function.
Examples
# Some model function.
my_model <- function() {
alpha0 <- mean(1:10)
alpha1 <- 600000
}
# Replace format of numbers using `formatC` function.
h_rapply(
x = body(my_model),
fun = formatC,
classes = c("integer", "numeric"),
digits = 3,
format = "E"
)
Helper Function to create return list for Simulations output
Description
Helper Function to create return list for Simulations output
Usage
h_simulations_output_format(resultList)
Arguments
resultList |
( |
Value
aggregated output for simulation object list.
Getting the Slots from a S4 Object
Description
This helper function extracts requested slots from the S4 class object.
It is a simple wrapper of methods::slot() function.
Usage
h_slots(object, names, simplify = FALSE)
Arguments
object |
( |
names |
( |
simplify |
( |
Value
list with the slots extracted from object according to names,
or single slot if simplification is required and possible.
Helper function to calculate average across iterations for each additional
reporting parameter
extracts parameter names as specified by user and averaged the values
for each specified parameter to show() and output with cat to console
Description
Helper function to calculate average across iterations for each additional
reporting parameter
extracts parameter names as specified by user and averaged the values
for each specified parameter to show() and output with cat to console
Usage
h_summarize_add_stats(stats_list)
Arguments
stats_list |
object from simulation with nested parameter values (sublist for each parameter) |
Value
list of parameter names and averaged values for console output
Check that an argument is a named vector of type numeric
Description
A simple helper function that tests whether an object is a named numerical vector.
Usage
h_test_named_numeric(
x,
subset.of = NULL,
must.include = NULL,
permutation.of = NULL,
identical.to = NULL,
disjunct.from = NULL,
lower = 0 + .Machine$double.xmin,
finite = TRUE,
any.missing = FALSE,
len = 2,
...
)
Arguments
x |
( |
subset.of |
[ |
must.include |
[ |
permutation.of |
[ |
identical.to |
[ |
disjunct.from |
[ |
lower |
[ |
finite |
[ |
any.missing |
[ |
len |
[ |
... |
further parameters passed to |
Value
TRUE if x is a named vector of type numeric, otherwise FALSE.
Note
This function is based on checkmate::test_numeric() and
checkmate::test_names() functions.
Examples
h_test_named_numeric(1:2, permutation.of = c("a", "b"))
h_test_named_numeric(c(a = 1, b = 2), permutation.of = c("a", "b"))
h_test_named_numeric(c(a = 1, b = 2), permutation.of = c("b", "a"))
Helper Function to call truth calculation
Description
Helper Function to call truth calculation
Usage
h_this_truth(dose, this_args, truth)
Arguments
dose |
( |
this_args |
( |
truth |
( |
Value
The updated this_truth.
Helper function to recursively unpack stopping rules and return lists with logical value and label given
Description
Helper function to recursively unpack stopping rules and return lists with logical value and label given
Usage
h_unpack_stopit(stopit_tree)
Arguments
stopit_tree |
object from simulate method |
Value
named list
Combining S4 Class Validation Results
Description
A simple helper function that combines two outputs from calls to result()
function which is placed in a slot of Validate() reference class.
Usage
h_validate_combine_results(v1, v2)
Arguments
v1 |
( |
v2 |
( |
Examples
h_validate_combine_results(TRUE, "some_message")
Helper Function performing validation Common to Data and DataOrdinal
Description
Helper Function performing validation Common to Data and DataOrdinal
Usage
h_validate_common_data_slots(object)
Arguments
object |
( |
Value
a Validate object containing the result of the validation
Render a CohortSizeConst Object
Description
We provide additional utility functions to allow human-friendly rendition of crmPack objects in Markdown and Quarto files
We provide additional utility functions to allow human-friendly rendition of
crmPack objects in Markdown and Quarto files. This file contains methods for
all design classes, not just those that are direct descendants of Design.
We provide additional utility functions to allow human-friendly rendition of crmPack objects in Markdown and Quarto files
Usage
## S3 method for class 'CohortSizeConst'
knit_print(x, ..., asis = TRUE, label = c("participant", "participants"))
## S3 method for class 'CohortSizeRange'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'CohortSizeDLT'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'CohortSizeParts'
knit_print(x, ..., asis = TRUE, label = c("participant", "participants"))
## S3 method for class 'CohortSizeMax'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'CohortSizeMin'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'CohortSizeOrdinal'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'StartingDose'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'RuleDesign'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'Design'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'DualDesign'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'DADesign'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'TDDesign'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'DualResponsesDesign'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'DesignOrdinal'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'DesignGrouped'
knit_print(
x,
...,
level = 2L,
title = "Design",
sections = c(model = "Dose toxicity model", mono = "Monotherapy rules", combo =
"Combination therapy rules", other = "Other details"),
asis = TRUE
)
## S3 method for class 'TDsamplesDesign'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'DualResponsesDesign'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'DualResponsesSamplesDesign'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'RuleDesignOrdinal'
knit_print(x, ..., level = 2L, title = "Design", sections = NA, asis = TRUE)
## S3 method for class 'GeneralData'
knit_print(
x,
...,
asis = TRUE,
label = c("participant", "participants"),
full_grid = FALSE,
summarise = c("none", "dose", "cohort"),
summarize = summarise,
units = NA,
format_func = h_knit_format_func
)
## S3 method for class 'DataParts'
knit_print(
x,
...,
asis = TRUE,
label = c("participant", "participants"),
full_grid = FALSE,
summarise = c("none", "dose", "cohort"),
summarize = summarise,
units = NA,
format_func = h_knit_format_func
)
## S3 method for class 'DualEndpoint'
knit_print(
x,
...,
asis = TRUE,
use_values = TRUE,
fmt = "%5.2f",
units = NA,
tox_label = "toxicity",
biomarker_label = "PD biomarker"
)
## S3 method for class 'ModelParamsNormal'
knit_print(
x,
use_values = TRUE,
fmt = "%5.2f",
params = c("alpha", "beta"),
preamble = "The prior for θ is given by\\n",
asis = TRUE,
theta = "\\theta",
...
)
## S3 method for class 'GeneralModel'
knit_print(
x,
...,
params = c("alpha", "beta"),
asis = TRUE,
use_values = TRUE,
fmt = "%5.2f",
units = NA
)
## S3 method for class 'LogisticKadane'
knit_print(
x,
...,
asis = TRUE,
use_values = TRUE,
fmt = "%5.2f",
units = NA,
tox_label = "toxicity"
)
## S3 method for class 'LogisticKadaneBetaGamma'
knit_print(
x,
...,
asis = TRUE,
use_values = TRUE,
fmt = "%5.2f",
tox_label = "toxicity",
units = NA
)
## S3 method for class 'LogisticLogNormal'
knit_print(
x,
...,
use_values = TRUE,
fmt = "%5.2f",
params = c(`\\alpha` = "alpha", `log(\\beta)` = "beta"),
preamble = "The prior for θ is given by\\n",
asis = TRUE
)
## S3 method for class 'LogisticLogNormalMixture'
knit_print(x, ..., asis = TRUE, use_values = TRUE, fmt = "%5.2f", units = NA)
## S3 method for class 'LogisticLogNormalSub'
knit_print(
x,
...,
use_values = TRUE,
fmt = "%5.2f",
params = c(`\\alpha` = "alpha", `log(\\beta)` = "beta"),
preamble = "The prior for θ is given by\\n",
asis = TRUE
)
## S3 method for class 'LogisticNormalMixture'
knit_print(x, ..., asis = TRUE, use_values = TRUE, fmt = "%5.2f", units = NA)
## S3 method for class 'LogisticNormalFixedMixture'
knit_print(x, ..., asis = TRUE, use_values = TRUE, fmt = "%5.2f", units = NA)
## S3 method for class 'OneParLogNormalPrior'
knit_print(
x,
...,
tox_label = "toxicity",
asis = TRUE,
use_values = TRUE,
fmt = "%5.2f"
)
## S3 method for class 'OneParExpPrior'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'LogisticLogNormalGrouped'
knit_print(
x,
...,
use_values = TRUE,
fmt = "%5.2f",
params = c(`\\alpha` = "alpha", `\\beta` = "beta", `log(\\delta_0)` = "delta_0",
`log(\\delta_1)` = "delta_1"),
preamble = "The prior for θ is given by\\n",
asis = TRUE
)
## S3 method for class 'LogisticLogNormalOrdinal'
knit_print(
x,
...,
use_values = TRUE,
fmt = "%5.2f",
params = NA,
preamble = "The prior for θ is given by\\n",
asis = TRUE
)
## S3 method for class 'LogisticIndepBeta'
knit_print(
x,
...,
use_values = TRUE,
fmt = "%5.2f",
params = NA,
tox_label = "DLAE",
preamble = "The prior for θ is given by\\n",
asis = TRUE
)
## S3 method for class 'Effloglog'
knit_print(
x,
...,
use_values = TRUE,
fmt = "%5.2f",
params = NA,
tox_label = "DLAE",
eff_label = "efficacy",
label = "participant",
preamble = "The prior for θ is given by\\n",
asis = TRUE
)
## S3 method for class 'IncrementsRelative'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'IncrementsRelativeDLT'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'IncrementsDoseLevels'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'IncrementsHSRBeta'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'IncrementsMin'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'IncrementsOrdinal'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'IncrementsRelativeParts'
knit_print(x, ..., asis = TRUE, tox_label = c("toxicity", "toxicities"))
## S3 method for class 'IncrementsRelativeDLTCurrent'
knit_print(x, ..., asis = TRUE, tox_label = c("DLT", "DLTs"))
## S3 method for class 'NextBestMTD'
knit_print(
x,
...,
target_label = "the 25th centile",
tox_label = "toxicity",
asis = TRUE
)
## S3 method for class 'NextBestNCRM'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'NextBestThreePlusThree'
knit_print(
x,
...,
tox_label = c("toxicity", "toxicities"),
label = "participant",
asis = TRUE
)
## S3 method for class 'NextBestDualEndpoint'
knit_print(
x,
...,
tox_label = "toxicity",
biomarker_label = "the biomarker",
biomarker_units = ifelse(x@target_relative, "%", ""),
asis = TRUE
)
## S3 method for class 'NextBestMinDist'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'NextBestInfTheory'
knit_print(
x,
...,
tox_label = "toxicity",
citation_text = "Mozgunov & Jaki (2019)",
citation_link = "https://doi.org/10.1002/sim.8450",
asis = TRUE
)
## S3 method for class 'NextBestTD'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'NextBestMaxGain'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'NextBestProbMTDLTE'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'NextBestProbMTDMinDist'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'NextBestNCRMLoss'
knit_print(
x,
...,
tox_label = "toxicity",
asis = TRUE,
format_func = h_knit_format_func
)
## S3 method for class 'NextBestTDsamples'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'NextBestMaxGainSamples'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'NextBestOrdinal'
knit_print(x, ..., tox_label = "toxicity", asis = TRUE)
## S3 method for class 'SafetyWindow'
knit_print(x, ..., asis = TRUE, time_unit = "day", label = "participant")
## S3 method for class 'SafetyWindowConst'
knit_print(
x,
...,
asis = TRUE,
label = "participant",
ordinals = c("first", "second", "third", "fourth", "fifth", "sixth", "seventh",
"eighth", "ninth", "tenth"),
time_unit = "day"
)
## S3 method for class 'SafetyWindowSize'
knit_print(
x,
...,
asis = TRUE,
ordinals = c("first", "second", "third", "fourth", "fifth", "sixth", "seventh",
"eighth", "ninth", "tenth"),
label = "participant",
time_unit = "day",
level = 2L
)
## S3 method for class 'StoppingOrdinal'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'StoppingMaxGainCIRatio'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'StoppingList'
knit_print(x, ..., preamble, indent = 0L, asis = TRUE)
## S3 method for class 'StoppingAny'
knit_print(x, ..., preamble, asis = TRUE)
## S3 method for class 'StoppingAll'
knit_print(x, ..., preamble, asis = TRUE)
## S3 method for class 'StoppingTDCIRatio'
knit_print(
x,
...,
dose_label = "the next best dose",
tox_label = "toxicity",
fmt_string =
paste0("%sIf, at %s, the ratio of the upper to the lower limit of the posterior ",
"95%% credible interval for %s (targetting %2.0f%%) is less than or equal to "),
asis = TRUE
)
## S3 method for class 'StoppingTargetBiomarker'
knit_print(
x,
...,
dose_label = "the next best dose",
biomarker_label = "the target biomarker",
fmt_string =
paste0("%sIf, at %s, the posterior probability that %s is in the range ",
"(%.2f, %.2f)%s is %.0f%% or more.\n\n"),
asis = TRUE
)
## S3 method for class 'StoppingLowestDoseHSRBeta'
knit_print(
x,
...,
tox_label = "toxicity",
fmt_string =
paste0("%sIf, using a Hard Stopping Rule with a prior of Beta(%.0f, %.0f), the ",
"lowest dose in the dose grid has a posterior probability of %s of ",
"%.0f%% or more.\n\n"),
asis = TRUE
)
## S3 method for class 'StoppingMTDCV'
knit_print(
x,
...,
fmt_string =
paste0("%sIf the posterior estimate of the robust coefficient of variation of ",
"the MTD (targetting %2.0f%%), is than or equal to %.0f%%.\n\n"),
asis = TRUE
)
## S3 method for class 'StoppingMTDdistribution'
knit_print(
x,
...,
fmt_string =
"%sIf the mean posterior probability of %s at %.0f%% of %s is at least %4.2f.\n\n",
dose_label = "the next best dose",
tox_label = "toxicity",
asis = TRUE
)
## S3 method for class 'StoppingHighestDose'
knit_print(
x,
...,
dose_label = "the highest dose in the dose grid",
asis = TRUE
)
## S3 method for class 'StoppingSpecificDose'
knit_print(x, ..., dose_label = as.character(x@dose), asis = TRUE)
## S3 method for class 'StoppingTargetProb'
knit_print(
x,
...,
fmt_string =
paste0("%sIf the probability of %s at %s is in the range [%4.2f, %4.2f] ",
"is at least %4.2f.\n\n"),
dose_label = "the next best dose",
tox_label = "toxicity",
asis = TRUE
)
## S3 method for class 'StoppingMinCohorts'
knit_print(x, ..., asis = TRUE)
## S3 method for class 'StoppingMinPatients'
knit_print(x, ..., label = "participant", asis = TRUE)
## S3 method for class 'StoppingPatientsNearDose'
knit_print(
x,
...,
dose_label = "the next best dose",
label = "participants",
asis = TRUE
)
## S3 method for class 'StoppingCohortsNearDose'
knit_print(x, ..., dose_label = "the next best dose", asis = TRUE)
## S3 method for class 'StoppingMissingDose'
knit_print(x, ..., asis = TRUE)
Arguments
x |
( |
... |
passed to |
asis |
( |
label |
( |
tox_label |
( |
level |
( |
title |
( |
sections |
( |
full_grid |
( |
summarise |
( |
summarize |
( |
units |
( |
format_func |
( |
use_values |
( |
fmt |
( |
biomarker_label |
( |
params |
( |
preamble |
( |
theta |
( |
eff_label |
( |
target_label |
( |
biomarker_units |
( |
citation_text |
( |
citation_link |
( |
time_unit |
( |
ordinals |
( |
indent |
( |
dose_label |
( |
fmt_string |
( |
Value
a character string that represents the object in markdown.
The markdown representation of the object, as a character string
a character string that represents the object in markdown.
A character string containing a LaTeX rendition of the object.
a character string that represents the object in markdown.
Usage Notes
label describes the trial's participants.
It should be a character vector of length 1 or 2. If of length 2, the first
element describes a cohort_size of 1 and the second describes all other
cohort_sizes. If of length 1, the character s is appended to the value
when cohort_size is not 1.
The default value of col.names is c("Lower", "Upper", "Cohort size") and
that of caption is "Defined by the dose to be used in the next cohort".
These values can be overridden by passing col.names and caption in the
function call.
The by default, the columns are labelled Lower, Upper and Cohort size.
The table's caption is Defined by the number of <tox_label[2]> so far observed.
These values can be overridden by passing col.names and caption in the
function call.
label describes the trial's participants.
It should be a character vector of length 1 or 2. If of length 2, the first
element describes a single participant and the second describes all other
situations. If of length 1, the character s is appended to the value
when the number of participants is not 1.
The default values of col.names and caption vary depending on the summary
requested. The default values can be overridden by passing col.names and
caption in the function call.
params must be a character vector of length equal to that of x@mean (and
x@cov). Its values represent the parameters of the model as entries in the
vector theta, on the left-hand side of "~" in the definition of the prior.
If named, names should be valid LaTeX, escaped as usual for R character variables.
For example, "\\alpha" or "\\beta_0". If unnamed, names are constructed by
pre-pending an escaped backslash to each value provided.
The default value of col.names is c("Min", "Max", "Increment") and that
of caption is "Defined by highest dose administered so far". These
values can be overridden by passing col.names and caption in the function
call.
The default value of col.names is c("Min", "Max", "Increment") and that
of caption is "Defined by number of DLTs reported so far". These values
can be overridden by passing col.names and caption in the function call.
label defines how toxicities are described.
It should be a character vector of length 1 or 2. If of length 2, the first
element describes a single toxicity and the second describes all other
toxicity counts. If of length 1, the character s is appended to the value
describing a single toxicity.
The default value of col.names is c("Min", "Max", "Increment") and that
of caption is "Defined by number of DLTs in the current cohort". These values
can be overridden by passing col.names and caption in the function call.
tox_label defines how toxicities are described.
It should be a character vector of length 1 or 2. If of length 2, the first
element describes a single toxicity and the second describes all other
toxicity counts. If of length 1, the character s is appended to the value
describing a single toxicity.
This section describes the use of label and tox_label, collectively
referred to as labels.
A label should be a scalar or a vector of length 2. If a scalar, it is
converted by adding a second element that is equal to the first, suffixed by s.
For example, tox_label = "DLT" becomes tox_label = c("DLT", "DLTs"). The
first element of the vector is used to describe a count of 1. The second
is used in all other cases.
To use a BibTeX-style citation, specify (for example) citation_text = "@MOZGUNOV", citation_link = "".
label should be a character vector of length 1 or 2. If of length 2, the first
element describes a count of 1 and the second describes all other counts.
If of length 1, the character s is appended to the value when the count is not 1.
label and time_unit are, collectively, labels.
A label should be a character vector of length 1 or 2. If of length 2, the first
element describes a count of 1 and the second describes all other counts.
If of length 1, the character s is appended to the value when the count is not 1.
label describes the trial's participants.
It should be a character vector of length 1 or 2. If of length 2, the first
element describes a cohort_size of 1 and the second describes all other
cohort_sizes. If of length 1, the character s is appended to the value
when cohort_size is not 1.
The default value of col.names is c("Lower", "Upper", "Cohort size") and
that of caption is "Defined by the dose to be used in the next cohort".
These values can be overridden by passing col.names and caption in the
function call.
The by default, the columns are labelled Lower, Upper and Cohort size.
The table's caption is Defined by the number of <tox_label[2]> so far observed.
These values can be overridden by passing col.names and caption in the
function call.
label describes the trial's participants.
It should be a character vector of length 1 or 2. If of length 2, the first
element describes a single participant and the second describes all other
situations. If of length 1, the character s is appended to the value
when the number of participants is not 1.
The default values of col.names and caption vary depending on the summary
requested. The default values can be overridden by passing col.names and
caption in the function call.
params must be a character vector of length equal to that of x@mean (and
x@cov). Its values represent the parameters of the model as entries in the
vector theta, on the left-hand side of "~" in the definition of the prior.
If named, names should be valid LaTeX, escaped as usual for R character variables.
For example, "\\alpha" or "\\beta_0". If unnamed, names are constructed by
pre-pending an escaped backslash to each value provided.
The default value of col.names is c("Min", "Max", "Increment") and that
of caption is "Defined by highest dose administered so far". These
values can be overridden by passing col.names and caption in the function
call.
The default value of col.names is c("Min", "Max", "Increment") and that
of caption is "Defined by number of DLTs reported so far". These values
can be overridden by passing col.names and caption in the function call.
label defines how toxicities are described.
It should be a character vector of length 1 or 2. If of length 2, the first
element describes a single toxicity and the second describes all other
toxicity counts. If of length 1, the character s is appended to the value
describing a single toxicity.
The default value of col.names is c("Min", "Max", "Increment") and that
of caption is "Defined by number of DLTs in the current cohort". These values
can be overridden by passing col.names and caption in the function call.
tox_label defines how toxicities are described.
It should be a character vector of length 1 or 2. If of length 2, the first
element describes a single toxicity and the second describes all other
toxicity counts. If of length 1, the character s is appended to the value
describing a single toxicity.
This section describes the use of label and tox_label, collectively
referred to as labels.
A label should be a scalar or a vector of length 2. If a scalar, it is
converted by adding a second element that is equal to the first, suffixed by s.
For example, tox_label = "DLT" becomes tox_label = c("DLT", "DLTs"). The
first element of the vector is used to describe a count of 1. The second
is used in all other cases.
To use a BibTeX-style citation, specify (for example) citation_text = "@MOZGUNOV", citation_link = "".
label should be a character vector of length 1 or 2. If of length 2, the first
element describes a count of 1 and the second describes all other counts.
If of length 1, the character s is appended to the value when the count is not 1.
label and time_unit are, collectively, labels.
A label should be a character vector of length 1 or 2. If of length 2, the first
element describes a count of 1 and the second describes all other counts.
If of length 1, the character s is appended to the value when the count is not 1.
See Also
knit_print for more details.
Shorthand for Logit Function
Description
Computes the logit transformation.
Usage
logit(x)
Arguments
x |
( |
Value
The logit of x, computed as log(x / (1 - x)).
Examples
logit(0.5)
logit(c(0.1, 0.5, 0.9))
Helper Function for Value Matching with Tolerance
Description
This is a modified version of match() that supports tolerance.
Usage
match_within_tolerance(x, table, tolerance = 1e-10)
Arguments
x |
( |
table |
( |
tolerance |
( |
Value
An integer vector of the same length as x giving the position
in table of the first match, or an empty integer vector if table is empty.
NA is returned for values in x that have no match.
Examples
match_within_tolerance(c(0.1, 0.2, 0.3), c(0.10000001, 0.5, 0.3))
match_within_tolerance(1.5, numeric(0))
Determine the Maximum Possible Next Dose
Description
This function determines the upper limit of the next dose based on the
incrementsand the data.
Usage
maxDose(increments, data, ...)
## S4 method for signature 'IncrementsRelative,Data'
maxDose(increments, data, ...)
## S4 method for signature 'IncrementsRelativeDLT,Data'
maxDose(increments, data, ...)
## S4 method for signature 'IncrementsRelativeDLTCurrent,Data'
maxDose(increments, data, ...)
## S4 method for signature 'IncrementsRelativeParts,DataParts'
maxDose(increments, data, ...)
## S4 method for signature 'IncrementsDoseLevels,Data'
maxDose(increments, data, ...)
## S4 method for signature 'IncrementsHSRBeta,Data'
maxDose(increments, data, ...)
## S4 method for signature 'IncrementsMin,Data'
maxDose(increments, data, ...)
## S4 method for signature 'IncrementsMin,DataOrdinal'
maxDose(increments, data, ...)
## S4 method for signature 'IncrementsOrdinal,DataOrdinal'
maxDose(increments, data, ...)
## S4 method for signature 'IncrementsMaxToxProb,DataOrdinal'
maxDose(increments, data, model, samples, ...)
## S4 method for signature 'IncrementsMaxToxProb,Data'
maxDose(increments, data, model, samples, ...)
Arguments
increments |
( |
data |
( |
... |
additional arguments without method dispatch. |
model |
( |
samples |
( |
Value
A number, the maximum possible next dose.
Functions
-
maxDose(increments = IncrementsRelative, data = Data): determine the maximum possible next dose based on relative increments. -
maxDose(increments = IncrementsRelativeDLT, data = Data): determine the maximum possible next dose based on relative increments determined by DLTs so far. -
maxDose(increments = IncrementsRelativeDLTCurrent, data = Data): determine the maximum possible next dose based on relative increments determined by DLTs in the current cohort. -
maxDose(increments = IncrementsRelativeParts, data = DataParts): determine the maximum possible next dose based on relative increments as well as part 1 and beginning of part 2. -
maxDose(increments = IncrementsDoseLevels, data = Data): determine the maximum possible next dose based on the number of dose grid levels. That is, the max dose is determined as the one which level is equal to: base dose level + level increment. The base dose level is the level of the last dose in grid or the level of the maximum dose applied, which is defined inincrementsobject. Find out more inIncrementsDoseLevels. -
maxDose(increments = IncrementsHSRBeta, data = Data): determine the maximum possible next dose for escalation. -
maxDose(increments = IncrementsMin, data = Data): determine the maximum possible next dose based on multiple increment rules, taking the minimum across individual increments. -
maxDose(increments = IncrementsMin, data = DataOrdinal): determine the maximum possible next dose based on multiple increment rules, taking the minimum across individual increments. -
maxDose(increments = IncrementsOrdinal, data = DataOrdinal): determine the maximum possible next dose in an ordinal CRM trial -
maxDose(increments = IncrementsMaxToxProb, data = DataOrdinal): determine the maximum possible next dose based on the probability of toxicity -
maxDose(increments = IncrementsMaxToxProb, data = Data): determine the maximum possible next dose based on the probability of toxicity
Examples
# Example of usage for `IncrementsRelative` maxDose class.
# Create the data.
my_data <- Data(
x = c(0.1, 0.5, 1.5, 3, 6, 8, 8, 8),
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, 8, 10:40)
)
# Define a rule for dose increments which allows for:
# - doubling the dose if the last dose was below 20,
# - increasing the dose by 33% of the last dose, only if the last dose was
# above or equal to 20.
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Based on the rule above, the maximum dose allowed is:
max_dose <- maxDose(my_increments, data = my_data)
# Example of usage for `IncrementsRelativeDLT` maxDose class.
# Create the data.
my_data <- Data(
x = c(0.1, 0.5, 1.5, 3, 6, 8, 8, 8),
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, 8, seq(from = 10, to = 80, by = 2))
)
# Define a rule for dose increments which allows for:
# - doubling the dose if no DLTs were yet observed,
# - increasing the dose by 33% if 1 or 2 DLTs were already observed,
# - increasing the dose by 20% if at least 3 DLTs were already observed.
my_increments <- IncrementsRelativeDLT(
intervals = c(0, 1, 3),
increments = c(1, 0.33, 0.2)
)
# Based on the rule above, the maximum dose allowed is:
max_dose <- maxDose(my_increments, data = my_data)
# Example of usage for `IncrementsRelativeDLTCurrent` maxDose 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))
)
# Define a rule for dose increments which allows for:
# - doubling the dose if no DLTs were observed in current (i.e. last) cohort,
# - only increasing the dose by 33% if 1 or 2 DLTs were observed in current cohort,
# - only increasing the dose by 20% if at least 3 DLTs were observed in current cohort.
my_increments <- IncrementsRelativeDLTCurrent(
intervals = c(0, 1, 3),
increments = c(1, 0.33, 0.2)
)
# Based on the rule above, the maximum dose allowed is:
max_dose <- maxDose(my_increments, data = my_data)
# Example of usage for `IncrementsRelativeParts` maxDose class.
# Create an object of class `DataParts`.
my_data <- DataParts(
x = c(0.1, 0.5, 1.5),
y = c(0, 0, 0),
ID = 1:3,
cohort = 1:3,
doseGrid = c(0.1, 0.5, 1.5, 3, 6, 10),
part = c(1L, 1L, 1L),
nextPart = 1L,
part1Ladder = c(0.1, 0.5, 1.5, 3, 6, 10)
)
my_increments <- IncrementsRelativeParts(
dlt_start = 0,
clean_start = 1
)
max_dose <- maxDose(my_increments, data = my_data)
# Example of usage for `IncrementsDoseLevels` maxDose class.
# Create the data.
my_data <- Data(
x = c(0.1, 0.5, 1.5, 3, 6, 8, 8, 12, 12, 12, 16, 16, 10, 10),
y = c(0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1),
ID = 1:14,
cohort = c(1, 2, 3, 4, 5, 6, 6, 7, 7, 7, 8, 8, 9, 9),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, 8, 10:30)
)
# In this first example we define a rule for dose increments which allows for
# maximum skip one dose level, that is 2 dose levels higher than the last dose
# given.
my_increments_1 <- IncrementsDoseLevels(levels = 2, basis_level = "last")
# Based on the rule above, the maximum dose allowed is:
max_dose_1 <- maxDose(my_increments_1, data = my_data)
# In this second example we define a rule for dose increments which allows for
# maximum skip one dose level, that is 2 dose levels higher than the max dose
# given.
my_increments_2 <- IncrementsDoseLevels(levels = 2, basis_level = "max")
# Based on the rule above, the maximum dose allowed is:
max_dose_2 <- maxDose(my_increments_2, data = my_data)
# Create the data.
my_data <- Data(
x = c(0.1, 0.5, 1.5, 3, 6, 8, 8, 8, 6, 6, 6),
y = c(0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1),
cohort = c(0, 1, 2, 3, 4, 5, 5, 5, 6, 6, 6),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, 8, seq(from = 10, to = 80, by = 2))
)
# In this example we define a rule for dose increments that limits the further
# dose escalation to doses below 6, because dose 6 is above the probability
# toxicity threshold.
my_increments <- IncrementsHSRBeta(target = 0.3, prob = 0.95)
# Based on the rule above, we then calculate the maximum dose allowed.
my_next_max_dose <- maxDose(my_increments, data = my_data)
# Example of usage for `IncrementsRelativeDLTCurrent` maxDose class.
# Create the data.
my_data <- Data(
x = c(0.1, 0.5, 1.5, 3, 6, 8, 8, 8),
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, 8, 10:80)
)
# Here, we combine two different increment rules.
# The first rule allows for:
# - doubling the dose if no DLTs were observed at the current dose,
# - increasing the dose by 33% if 1 or 2 DLTs were observed at the current dose,
# - increasing the dose by 22% if 3 or more DLTs were observed.
my_increments_1 <- IncrementsRelativeDLT(
intervals = c(0, 1, 3),
increments = c(1, 0.33, 0.2)
)
# The second rule allows for:
# - doubling the dose if the current dose is <20,
# - increasing the dose by 33% if the current dose is >=20.
my_increments_2 <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Finally, the maximum dose allowed is computed by taking the minimum dose from
# the maximum doses computed by the two rules.
my_increments <- IncrementsMin(
increments_list = list(my_increments_1, my_increments_2)
)
max_dose <- maxDose(my_increments, my_data)
maxDose(
increments = IncrementsOrdinal(2L, .DefaultIncrementsRelative()),
data = .DefaultDataOrdinal()
)
model <- LogisticLogNormalOrdinal(
mean = c(0.25, 0.15, 0.5),
cov = matrix(c(1.5, 0, 0, 0, 2, 0, 0, 0, 1), nrow = 3),
ref_dose = 30
)
emptyData <- DataOrdinal(
doseGrid = c(1, 3, 9, 25, 50, 75, 100),
yCategories = c("No tox" = 0L, "DLAE" = 1L, "CRS" = 2L)
)
# For warning regarding tox, see issue #748 https://github.com/openpharma/crmPack/issues/748
suppressWarnings({
samples <- mcmc(emptyData, model, .DefaultMcmcOptions())
})
toxIncrements <- IncrementsMaxToxProb(prob = c("DLAE" = 0.2, "CRS" = 0.05))
maxDose(toxIncrements, emptyData, model, samples)
model <- LogisticLogNormalOrdinal(
mean = c(0.25, 0.15, 0.5),
cov = matrix(c(1.5, 0, 0, 0, 2, 0, 0, 0, 1), nrow = 3),
ref_dose = 30
)
emptyData <- DataOrdinal(
doseGrid = c(1, 3, 9, 25, 50, 75, 100),
yCategories = c("No tox" = 0L, "DLAE" = 1L, "CRS" = 2L)
)
# For warning regarding tox, see issue #748 https://github.com/openpharma/crmPack/issues/748
suppressWarnings({
samples <- mcmc(emptyData, model, .DefaultMcmcOptions())
})
toxIncrements <- IncrementsMaxToxProb(prob = c("DLAE" = 0.2, "CRS" = 0.05))
maxDose(toxIncrements, emptyData, model, samples)
"MAX" Combination of Cohort Size Rules
Description
This function combines cohort size rules by taking the maximum of all sizes.
Usage
maxSize(...)
## S4 method for signature 'CohortSize'
maxSize(...)
Arguments
... |
Objects of class |
Value
The combination as an object of class CohortSizeMax.
Functions
-
maxSize(CohortSize): The method combining cohort size rules by taking maximum.
See Also
Examples
# Here is the rule for:
# having cohort of size 1 for doses <30
# and having cohort of size 3 for doses >=30
mySize1 <- CohortSizeRange(intervals = c(0, 30), cohort_size = c(1, 3))
# Here is the rule for:
# having cohort of size 1 until no DLT were observed
# and having cohort of size 3 as soon as 1 DLT is observed
mySize2 <- CohortSizeDLT(intervals = c(0, 1), cohort_size = c(1, 3))
# This is combining the two rules above by taking the maximum of the sample sizes of
# the single rules
mySize <- maxSize(mySize1, mySize2)
Obtaining Posterior Samples for all Model Parameters
Description
This is the function that actually runs the JAGS MCMC machinery to produce
posterior samples from all model parameters and required derived values.
It is a generic function, so that customized versions may be conveniently
defined for specific subclasses of GeneralData, GeneralModel, and
McmcOptions input.
Usage
mcmc(data, model, options, ...)
## S4 method for signature 'GeneralData,GeneralModel,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)
## S4 method for signature 'GeneralData,DualEndpointRW,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)
## S4 method for signature 'GeneralData,DualEndpointBeta,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)
## S4 method for signature 'GeneralData,DualEndpointEmax,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)
## S4 method for signature 'GeneralData,OneParLogNormalPrior,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)
## S4 method for signature 'GeneralData,OneParExpPrior,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)
## S4 method for signature 'DataMixture,GeneralModel,McmcOptions'
mcmc(
data,
model,
options,
from_prior = data@nObs == 0L & data@nObsshare == 0L,
...
)
## S4 method for signature 'Data,LogisticIndepBeta,McmcOptions'
mcmc(data, model, options, ...)
## S4 method for signature 'DataDual,Effloglog,McmcOptions'
mcmc(data, model, options, ...)
## S4 method for signature 'DataDual,EffFlexi,McmcOptions'
mcmc(data, model, options, ...)
## S4 method for signature 'DataOrdinal,LogisticLogNormalOrdinal,McmcOptions'
mcmc(data, model, options, ...)
Arguments
data |
( |
model |
( |
options |
( |
... |
not used. |
from_prior |
( |
Value
The posterior samples, an object of class Samples.
Functions
-
mcmc(data = GeneralData, model = GeneralModel, options = McmcOptions): Standard method which uses JAGS. -
mcmc(data = GeneralData, model = DualEndpointRW, options = McmcOptions): Standard method which uses JAGS. For theDualEndpointRWmodel, it is required that there are at least two (in case of random walk prior of the first order on the biomarker level) or three doses in the grid. -
mcmc(data = GeneralData, model = DualEndpointBeta, options = McmcOptions): Standard method which uses JAGS. For theDualEndpointBetamodel, it is required that the value ofref_dose_betaslot is greater than the maximum dose in a grid. This requirement comes from definition of the beta function that is used to model dose-biomarker relationship inDualEndpointBetamodel. The other requirement is that there must be at least one dose in the grid. -
mcmc(data = GeneralData, model = DualEndpointEmax, options = McmcOptions): Standard method which uses JAGS. For theDualEndpointEmaxmodel, it is required that there is at least one dose in the grid. -
mcmc(data = GeneralData, model = OneParLogNormalPrior, options = McmcOptions): Standard method which uses JAGS. For theOneParLogNormalPriormodel, it is required that the length of skeleton prior probabilities vector should be equal to the length of the number of doses. -
mcmc(data = GeneralData, model = OneParExpPrior, options = McmcOptions): Standard method which uses JAGS. For theOneParExpPriormodel, it is required that the length of skeleton prior probabilities vector should be equal to the length of the number of doses. -
mcmc(data = DataMixture, model = GeneralModel, options = McmcOptions): Method forDataMixturewith differentfrom_priordefault. Samples from the prior only when both the number of observations and the number of shared observations are zero. -
mcmc(data = Data, model = LogisticIndepBeta, options = McmcOptions): Obtain posterior samples for the model parameters based on the pseudoLogisticIndepBetaDLE model. The joint prior and posterior probability density function of the intercept\phi_1(phi1) and the slope\phi_2(phi2) are given in Whitehead and Williamson (1998). However, since asymptotically, the joint posterior probability density will be bivariate normal, we use the bivariate normal distribution to generate posterior samples of the intercept and the slope parameters. For the prior samples of the intercept and the slope, a bivariate normal distribution with mean and the covariance matrix given in Whitehead and Williamson (1998) is used. -
mcmc(data = DataDual, model = Effloglog, options = McmcOptions): Obtain the posterior samples for the model parameters in theEffloglogmodel. Given the value of\nu, the precision of the efficacy responses, the joint prior or the posterior probability of the intercept\theta_1(theta1) and the slope\theta_2(theta2) is a bivariate normal distribution. The\nu(nu), the precision of the efficacy responses is either a fixed value or has a gamma distribution. If a gamma distribution is used, the samples ofnuwill be first generated. Then the mean of thenusamples will be used to generate samples of the intercept and slope parameters of the model. -
mcmc(data = DataDual, model = EffFlexi, options = McmcOptions): Obtain the posterior samples for the estimates in theEffFleximodel. This is the MCMC procedure based on what is described in Lang and Brezger (2004) such that samples of the mean efficacy responses at all dose levels, samples ofsigma2\sigma^2, the variance of the efficacy response and samples ofsigma2betaW\sigma^2_{\beta_W}, the variance of the random walk model will be generated. Please refer to Lang and Brezger (2004) for the procedures and the form of the joint prior and posterior probability density for the mean efficacy responses. In addition, bothsigma2andsigma2betaWcan be fixed or have an inverse-gamma prior and posterior distribution. Therefore, if the inverse gamma distribution(s) are used, the parameters in the distribution will be first updated and then samples ofsigma2andsigma2betaWwill be generated using the updated parameters. -
mcmc( data = DataOrdinal, model = LogisticLogNormalOrdinal, options = McmcOptions ): Obtain the posterior samples for the model parameters in theLogisticLogNormalOrdinalmodel.The generic
mcmcmethod returns aSamplesobject with elements of thedataslot namedalpha[1],alpha[2], ...,alpha[k]andbetawhen passed aLogisticLogNormalOrdinalobject. This makes the "alpha elements" awkward to access and is inconsistent with other model objects. So rename the alpha elements toalpha1,alpha2, ...,alpha<k>for ease and consistency.
Note
The type of Random Number Generator (RNG) and its initial seed used by
JAGS are taken from the options argument. If no initial values are
supplied (i.e RNG kind or seed slot in options has NA), then they will
be generated automatically by JAGS.
References
Lang S, Brezger A (2004).
“Bayesian P-Splines.”
Journal of Computational and Graphical Statistics, 13(1), 183–212.
ISSN 10618600, doi:10.1198/1061860043010, http://www.jstor.org/stable/1391151.
Whitehead J, Williamson D (1998).
“Bayesian decision procedures based on logistic regression models for dose-finding studies.”
Journal of Biopharmaceutical Statistics, 8(3), 445–467.
Examples
# Create some data from the class `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),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Initialize the CRM model.
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Sample from the posterior distribution.
my_options <- McmcOptions(
burnin = 100,
step = 2,
samples = 1000
)
samples <- mcmc(data = my_data, model = my_model, options = my_options)
samples
# Create some data from the class `DataDual`.
plcb <- 0.001
my_data <- DataDual(
w = c(13, 77, 86, 26, 27, 36, 37, 97, 21, 49, 87, 48),
x = c(plcb, 25, 25, 25, plcb, 50, 50, 50, plcb, 100, 100, 100),
y = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L),
doseGrid = c(plcb, seq(25, 300, 25)),
placebo = TRUE,
ID = 1:12,
cohort = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L)
)
# Initialize the CRM model.
my_model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
sigma2betaW = 0.01,
rw1 = TRUE
)
# Sample from the posterior distribution.
my_options <- McmcOptions(
burnin = 50,
step = 2,
samples = 4,
rng_kind = "Mersenne-Twister",
rng_seed = 1
)
samples <- mcmc(data = my_data, model = my_model, options = my_options)
samples
# Create some data from the class `DataDual`.
plcb <- 0.001
my_data <- DataDual(
w = c(13, 77, 86, 26, 27, 36, 37, 97, 21, 49, 87, 48),
x = c(plcb, 25, 25, 25, plcb, 50, 50, 50, plcb, 100, 100, 100),
y = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L),
doseGrid = c(plcb, seq(25, 300, 25)),
placebo = TRUE,
ID = 1:12,
cohort = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L)
)
# Initialize the CRM model.
my_model <- DualEndpointBeta(
mean = c(0, 1),
cov = diag(2),
ref_dose = 2,
use_log_dose = FALSE,
sigma2W = c(a = 1, b = 2),
rho = c(a = 1.5, b = 2.5),
E0 = 2,
Emax = 50,
delta1 = 6,
mode = 9,
ref_dose_beta = my_data@doseGrid[my_data@nGrid] + 10
)
# Sample from the posterior distribution.
my_options <- McmcOptions(
burnin = 50,
step = 2,
samples = 4,
rng_kind = "Mersenne-Twister",
rng_seed = 1
)
samples <- mcmc(data = my_data, model = my_model, options = my_options)
samples
##obtain mcmc DLE samples given the data, LogisticIndepBeta (DLE model) and mcmc simulations options
## data must be of 'Data' class
data <- Data(
x = c(25, 50, 50, 75, 100, 100, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
doseGrid = seq(25, 300, 25)
)
## model must be of 'LogisticIndepBeta' class
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## options must be ''McmcOptions' class
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
set.seed(94)
samples <- mcmc(data = data, model = model, options = options)
# nolint start
##obtain mcmc efficacy samples given the data, 'Effloglog' model (efficacy model) and
## mcmc simulations options data must be of 'DataDual' class
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
## model must be of 'Effloglog' class
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data
)
## options must be ''McmcOptions' class
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
set.seed(94)
samples <- mcmc(data = data, model = Effmodel, options = options)
# nolint end
## obtain mcmc efficacy samples given the data, 'EffFlexi' model (efficacy model) and
## mcmc simulations options
## data must be of 'DataDual' class
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25)
)
## model must be of 'EffFlexi' class
effmodel <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = data
)
## options must be ''McmcOptions' class
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
set.seed(94)
samples <- mcmc(data = data, model = effmodel, options = options)
ordinal_data <- .DefaultDataOrdinal()
ordinal_model <- .DefaultLogisticLogNormalOrdinal()
mcmc_options <- .DefaultMcmcOptions()
samples <- mcmc(ordinal_data, ordinal_model, mcmc_options)
"MIN" Combination of Cohort Size Rules
Description
This function combines cohort size rules by taking the minimum of all sizes.
Usage
minSize(...)
## S4 method for signature 'CohortSize'
minSize(...)
Arguments
... |
Objects of class |
Value
The combination as an object of class CohortSizeMin.
Functions
-
minSize(CohortSize): The method combining cohort size rules by taking minimum.
See Also
Examples
# Here is the rule for:
# having cohort of size 1 for doses <30
# and having cohort of size 3 for doses >=30
mySize1 <- CohortSizeRange(intervals = c(0, 30), cohort_size = c(1, 3))
# Here is the rule for:
# having cohort of size 1 until no DLT were observed
# and having cohort of size 3 as soon as 1 DLT is observed
mySize2 <- CohortSizeDLT(intervals = c(0, 1), cohort_size = c(1, 3))
# This is combining the two rules above by taking the minimum of the sample sizes of
# the single rules
mySize <- minSize(mySize1, mySize2)
MCMC Sampling for Bayesian Logistic Regression Model
Description
Replacement for BayesLogit::logit. Performs MCMC sampling for Bayesian
logistic regression using JAGS.
Usage
myBayesLogit(y, X, m0, P0, options)
Arguments
y |
( |
X |
( |
m0 |
( |
P0 |
( |
options |
( |
Value
The matrix of samples (samples x parameters).
The Names of the Sampled Parameters
Description
A method that returns names of the parameters that are sampled.
Usage
## S4 method for signature 'Samples'
names(x)
Arguments
x |
( |
Examples
my_samples <- Samples(
data = list(alpha = 1:5, beta = 15:19),
options = McmcOptions(burnin = 2, step = 2, samples = 5)
)
names(my_samples)
Finding the Next Best Dose
Description
A function that computes the recommended next best dose based on the
corresponding rule nextBest, the posterior samples from the model and
the underlying data.
Usage
nextBest(nextBest, doselimit, samples, model, data, ...)
## S4 method for signature 'NextBestEWOC,numeric,Samples,GeneralModel,Data'
nextBest(nextBest, doselimit = Inf, samples, model, data, ...)
## S4 method for signature 'NextBestMTD,numeric,Samples,GeneralModel,Data'
nextBest(nextBest, doselimit = Inf, samples, model, data, ...)
## S4 method for signature 'NextBestNCRM,numeric,Samples,GeneralModel,Data'
nextBest(nextBest, doselimit = Inf, samples, model, data, ...)
## S4 method for signature
## 'NextBestNCRM,numeric,Samples,GeneralModel,DataParts'
nextBest(nextBest, doselimit = Inf, samples, model, data, ...)
## S4 method for signature 'NextBestNCRMLoss,numeric,Samples,GeneralModel,Data'
nextBest(nextBest, doselimit = Inf, samples, model, data, ...)
## S4 method for signature
## 'NextBestThreePlusThree,missing,missing,missing,Data'
nextBest(nextBest, doselimit, samples, model, data, ...)
## S4 method for signature
## 'NextBestDualEndpoint,numeric,Samples,DualEndpoint,Data'
nextBest(nextBest, doselimit = Inf, samples, model, data, ...)
## S4 method for signature 'NextBestMinDist,numeric,Samples,GeneralModel,Data'
nextBest(nextBest, doselimit = Inf, samples, model, data, ...)
## S4 method for signature
## 'NextBestInfTheory,numeric,Samples,GeneralModel,Data'
nextBest(nextBest, doselimit = Inf, samples, model, data, ...)
## S4 method for signature 'NextBestTD,numeric,missing,LogisticIndepBeta,Data'
nextBest(nextBest, doselimit = Inf, model, data, in_sim = FALSE, ...)
## S4 method for signature
## 'NextBestTDsamples,numeric,Samples,LogisticIndepBeta,Data'
nextBest(nextBest, doselimit = Inf, samples, model, data, in_sim, ...)
## S4 method for signature 'NextBestMaxGain,numeric,missing,ModelTox,DataDual'
nextBest(
nextBest,
doselimit = Inf,
model,
data,
model_eff,
in_sim = FALSE,
...
)
## S4 method for signature
## 'NextBestMaxGainSamples,numeric,Samples,ModelTox,DataDual'
nextBest(
nextBest,
doselimit = Inf,
samples,
model,
data,
model_eff,
samples_eff,
in_sim = FALSE,
...
)
## S4 method for signature
## 'NextBestProbMTDLTE,numeric,Samples,GeneralModel,Data'
nextBest(nextBest, doselimit, samples, model, data, ...)
## S4 method for signature
## 'NextBestProbMTDMinDist,numeric,Samples,GeneralModel,Data'
nextBest(nextBest, doselimit, samples, model, data, ...)
## S4 method for signature 'NextBestOrdinal,numeric,Samples,GeneralModel,Data'
nextBest(nextBest, doselimit = Inf, samples, model, data, ...)
## S4 method for signature
## 'NextBestOrdinal,numeric,Samples,LogisticLogNormalOrdinal,DataOrdinal'
nextBest(nextBest, doselimit = Inf, samples, model, data, ...)
Arguments
nextBest |
( |
doselimit |
( |
samples |
( |
model |
( |
data |
( |
... |
additional arguments without method dispatch. |
in_sim |
( |
model_eff |
( |
samples_eff |
( |
Value
A list with the next best dose recommendation (element named value)
from the grid defined in data, and a plot depicting this recommendation
(element named plot). In case of multiple plots also an element
named singlePlots is included. The singlePlots is itself a list with
single plots. An additional list with elements describing the outcome
of the rule can be contained too.
Functions
-
nextBest( nextBest = NextBestEWOC, doselimit = numeric, samples = Samples, model = GeneralModel, data = Data ): find the next best dose based on the EWOC rule. -
nextBest( nextBest = NextBestMTD, doselimit = numeric, samples = Samples, model = GeneralModel, data = Data ): find the next best dose based on the MTD rule. -
nextBest( nextBest = NextBestNCRM, doselimit = numeric, samples = Samples, model = GeneralModel, data = Data ): find the next best dose based on the NCRM method. The additional elementprobsin the output's list contains the target and overdosing probabilities (across all doses in the dose grid) used in the derivation of the next best dose. -
nextBest( nextBest = NextBestNCRM, doselimit = numeric, samples = Samples, model = GeneralModel, data = DataParts ): find the next best dose based on the NCRM method when two parts trial is used. -
nextBest( nextBest = NextBestNCRMLoss, doselimit = numeric, samples = Samples, model = GeneralModel, data = Data ): find the next best dose based on the NCRM method and loss function. -
nextBest( nextBest = NextBestThreePlusThree, doselimit = missing, samples = missing, model = missing, data = Data ): find the next best dose based on the 3+3 method. -
nextBest( nextBest = NextBestDualEndpoint, doselimit = numeric, samples = Samples, model = DualEndpoint, data = Data ): find the next best dose based on the dual endpoint model. The additional list elementprobscontains the target and overdosing probabilities (across all doses in the dose grid) used in the derivation of the next best dose. -
nextBest( nextBest = NextBestMinDist, doselimit = numeric, samples = Samples, model = GeneralModel, data = Data ): gives the dose which is below the dose limit and has an estimated DLT probability which is closest to the target dose. -
nextBest( nextBest = NextBestInfTheory, doselimit = numeric, samples = Samples, model = GeneralModel, data = Data ): gives the appropriate dose within an information theoretic framework. -
nextBest( nextBest = NextBestTD, doselimit = numeric, samples = missing, model = LogisticIndepBeta, data = Data ): find the next best dose based only on the DLT responses and forLogisticIndepBetamodel class object without DLT samples. -
nextBest( nextBest = NextBestTDsamples, doselimit = numeric, samples = Samples, model = LogisticIndepBeta, data = Data ): find the next best dose based only on the DLT responses and forLogisticIndepBetamodel class object involving DLT samples. -
nextBest( nextBest = NextBestMaxGain, doselimit = numeric, samples = missing, model = ModelTox, data = DataDual ): find the next best dose based only on pseudo DLT modelModelToxandEffloglogefficacy model without samples. -
nextBest( nextBest = NextBestMaxGainSamples, doselimit = numeric, samples = Samples, model = ModelTox, data = DataDual ): find the next best dose based on DLT and efficacy responses with DLT and efficacy samples. -
nextBest( nextBest = NextBestProbMTDLTE, doselimit = numeric, samples = Samples, model = GeneralModel, data = Data ): find the next best dose based with the highest probability of having a toxicity rate less or equal to the target toxicity level. -
nextBest( nextBest = NextBestProbMTDMinDist, doselimit = numeric, samples = Samples, model = GeneralModel, data = Data ): find the next best dose based with the highest probability of having a toxicity rate with minimum distance to the target toxicity level. -
nextBest( nextBest = NextBestOrdinal, doselimit = numeric, samples = Samples, model = GeneralModel, data = Data ): find the next best dose for ordinal CRM models. -
nextBest( nextBest = NextBestOrdinal, doselimit = numeric, samples = Samples, model = LogisticLogNormalOrdinal, data = DataOrdinal ): find the next best dose for ordinal CRM models.
Examples
# Example of usage for `NextBestEWOC` 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 'NextBestEWOC' class.
ewoc_next_best <- NextBestEWOC(
target = 0.30,
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose.
dose_recommendation <- nextBest(
nextBest = ewoc_next_best,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
# See the probabilities.
dose_recommendation$probs
# Example of usage for `NextBestMTD` 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 'NextBestMTD' class.
mtd_next_best <- NextBestMTD(
target = 0.33,
derive = function(mtd_samples) {
quantile(mtd_samples, probs = 0.25)
}
)
# Calculate the next best dose.
dose_recommendation <- nextBest(
nextBest = mtd_next_best,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
# Example of usage for `NextBestNCRM` 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 'NextBestNCRM' class.
nrcm_next_best <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose.
dose_recommendation <- nextBest(
nextBest = nrcm_next_best,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
# See the probabilities.
dose_recommendation$probs
# Example of usage for `NextBestNCRM-DataParts` NextBest class.
# Create the data.
my_data <- DataParts(
x = c(0.1, 0.5, 1.5),
y = c(0, 0, 0),
ID = 1:3,
cohort = 1:3,
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2)),
part = c(1L, 1L, 1L),
nextPart = 1L,
part1Ladder = c(0.1, 0.5, 1.5, 3, 6, 10)
)
# 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 <- IncrementsRelativeParts(
dlt_start = 0,
clean_start = 1
)
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 'NextBestNCRM' class.
nrcm_next_best <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose.
dose_recommendation <- nextBest(
nextBest = nrcm_next_best,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
dose_recommendation
# 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
# Example of usage for `NextBestThreePlusThree` NextBest class.
# Create the data.
my_data <- Data(
x = c(5, 5, 5, 10, 10, 10),
y = c(0, 0, 0, 0, 1, 0),
ID = 1:6,
cohort = c(0, 0, 0, 1, 1, 1),
doseGrid = c(0.1, 0.5, 1.5, 3, 5, seq(from = 10, to = 80, by = 2))
)
# The rule to select the next best dose will be based on the 3+3 method.
my_next_best <- NextBestThreePlusThree()
# Calculate the next best dose.
dose_recommendation <- nextBest(my_next_best, data = my_data)
# Example of usage for `NextBestDualEndpoint` NextBest class.
# Create the data.
my_data <- DataDual(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10, 20, 20, 20, 40, 40, 40, 50, 50, 50),
y = c(0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1),
ID = 1:17,
cohort = c(
1L,
2L,
3L,
4L,
5L,
6L,
6L,
6L,
7L,
7L,
7L,
8L,
8L,
8L,
9L,
9L,
9L
),
w = c(
0.31,
0.42,
0.59,
0.45,
0.6,
0.7,
0.55,
0.6,
0.52,
0.54,
0.56,
0.43,
0.41,
0.39,
0.34,
0.38,
0.21
),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Initialize the Dual-Endpoint model (in this case RW1).
my_model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# 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. In this case,
# target a dose achieving at least 0.9 of maximum biomarker level (efficacy)
# and with a probability below 0.25 that prob(DLT)>0.35 (safety).
de_next_best <- NextBestDualEndpoint(
target = c(0.9, 1),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose.
dose_recommendation <- nextBest(
nextBest = de_next_best,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
# See the probabilities.
dose_recommendation$probs
# Joint plot.
print(dose_recommendation$plot)
# Show customization of single plot.
variant1 <- dose_recommendation$singlePlots$plot1 + xlim(0, 20)
print(variant1)
# Example of usage for `NextBestTD` NextBest class.
my_data <- Data(
x = c(25, 50, 50, 75, 150, 200, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
ID = 1:8,
cohort = c(1L, 2L, 2L, 3L, 4L, 5L, 6L, 7L),
doseGrid = seq(from = 25, to = 300, by = 25)
)
my_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = my_data
)
# Target probabilities of the occurrence of a DLT during trial and
# at the end of the trial are defined as 0.35 and 0.3, respectively.
td_next_best <- NextBestTD(prob_target_drt = 0.35, prob_target_eot = 0.3)
# doselimit is the maximum allowable dose level to be given to subjects.
dose_recommendation <- nextBest(
nextBest = td_next_best,
doselimit = max(my_data@doseGrid),
model = my_model,
data = my_data
)
dose_recommendation$next_dose_drt
dose_recommendation$plot
# Example of usage for `NextBestTDsamples` NextBest class.
my_data <- Data(
x = c(25, 50, 50, 75, 150, 200, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
ID = 1:8,
cohort = c(1L, 2L, 2L, 3L, 4L, 5L, 6L, 7L),
doseGrid = seq(from = 25, to = 300, by = 25)
)
my_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = my_data
)
# Set-up some MCMC parameters and generate samples.
my_options <- McmcOptions(burnin = 100, step = 2, samples = 800)
my_samples <- mcmc(my_data, my_model, my_options)
# Target probabilities of the occurrence of a DLT during trial and
# at the end of the trial are defined as 0.35 and 0.3, respectively.
# 'derive' is specified such that the 30% posterior quantile of the TD35 and
# TD30 samples will be used as TD35 and TD30 estimates.
tds_next_best <- NextBestTDsamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, probs = 0.3))
}
)
# doselimit is the maximum allowable dose level to be given to subjects.
dose_recommendation <- nextBest(
nextBest = tds_next_best,
doselimit = max(my_data@doseGrid),
samples = my_samples,
model = my_model,
data = my_data
)
dose_recommendation$next_dose_drt
dose_recommendation$plot
# Example of usage for `NextBestMaxGain` NextBest class.
# Create the data.
my_data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
ID = 1:8,
cohort = 1:8,
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
# 'ModelTox' DLT model, e.g 'LogisticIndepBeta'.
my_model_dlt <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = my_data
)
# 'ModelEff' efficacy model, e.g. 'Effloglog'.
my_model_eff <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = my_data
)
# Target probabilities of the occurrence of a DLT during trial and at the
# end of trial are defined as 0.35 and 0.3, respectively.
mg_next_best <- NextBestMaxGain(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
# doselimit is the maximum allowable dose level to be given to subjects.
dose_recommendation <- nextBest(
nextBest = mg_next_best,
doselimit = 300,
model = my_model_dlt,
model_eff = my_model_eff,
data = my_data
)
dose_recommendation$next_dose
dose_recommendation$plot
# Example of usage for `NextBestMaxGainSamples` NextBest class.
# Create the data.
my_data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
ID = 1:8,
cohort = 1:8,
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
# 'ModelTox' DLT model, e.g 'LogisticIndepBeta'.
my_model_dlt <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = my_data
)
# 'ModelEff' efficacy model, e.g 'Effloglog'.
my_model_effll <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = my_data
)
# Set-up some MCMC parameters and generate samples from the posterior.
my_options <- McmcOptions(burnin = 100, step = 2, samples = 500)
my_samples_dlt <- mcmc(my_data, my_model_dlt, my_options)
my_samples_effll <- mcmc(my_data, my_model_effll, my_options)
# Target probabilities of the occurrence of a DLT during trial and at the end of
# trial are defined as 0.35 and 0.3, respectively.
# Use 30% posterior quantile of the TD35 and TD30 samples as estimates of TD35
# and TD30.
# Use 50% posterior quantile of the Gstar (the dose which gives the maxim gain value)
# samples as Gstar estimate.
mgs_next_best <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
dose_recommendation <- nextBest(
nextBest = mgs_next_best,
doselimit = max(my_data@doseGrid),
samples = my_samples_dlt,
model = my_model_dlt,
data = my_data,
model_eff = my_model_effll,
samples_eff = my_samples_effll
)
dose_recommendation$next_dose
dose_recommendation$plot
# Now using the 'EffFlexi' class efficacy model:
my_model_effflexi <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = my_data
)
my_samples_effflexi <- mcmc(my_data, my_model_effflexi, my_options)
dose_recommendation <- nextBest(
nextBest = mgs_next_best,
doselimit = max(my_data@doseGrid),
samples = my_samples_dlt,
model = my_model_dlt,
data = my_data,
model_eff = my_model_effflexi,
samples_eff = my_samples_effflexi
)
dose_recommendation$next_dose
dose_recommendation$plot
# Example of usage for `NextBestProbMTDLTE` 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 'NextBestProbMTDLTE' class.
nb_mtd_lte <- NextBestProbMTDLTE(target = 0.33)
# Calculate the next best dose.
dose_recommendation <- nextBest(
nextBest = nb_mtd_lte,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
# Example of usage for `NextBestProbMTDMinDist` NextBest class.
# Create the data.
my_data <- Data(
x = c(1.5, 1.5, 1.5, 2.5, 2.5, 2.5, 3.5, 3.5, 3.5),
y = c(0, 0, 0, 0, 0, 0, 1, 1, 0),
ID = 1:9,
cohort = c(1, 1, 1, 2, 2, 2, 3, 3, 3),
doseGrid = c(1.5, 2.5, 3.5, 4.5, 6, 7)
)
# Initialize the CRM model used to model the data.
my_model <- my_model <- LogisticKadaneBetaGamma(
theta = 0.3,
xmin = 1.5,
xmax = 7,
alpha = 1,
beta = 19,
shape = 0.5625,
rate = 0.125
)
# 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 <- IncrementsDoseLevels(levels = 1)
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 'NextBestProbMTDMinDist' class.
nb_mtd_min_dist <- NextBestProbMTDMinDist(target = 0.3)
# Calculate the next best dose.
dose_recommendation <- nextBest(
nextBest = nb_mtd_min_dist,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
ordinal_data <- .DefaultDataOrdinal()
ordinal_model <- .DefaultLogisticLogNormalOrdinal()
options <- .DefaultMcmcOptions()
ordinal_samples <- mcmc(ordinal_data, ordinal_model, options)
nextBest(
nextBest = NextBestOrdinal(2L, .DefaultNextBestNCRM()),
samples = ordinal_samples,
doselimit = Inf,
model = ordinal_model,
data = ordinal_data
)
ordinal_data <- .DefaultDataOrdinal()
ordinal_model <- .DefaultLogisticLogNormalOrdinal()
options <- .DefaultMcmcOptions()
ordinal_samples <- mcmc(ordinal_data, ordinal_model, options)
nextBest(
nextBest = NextBestOrdinal(2L, .DefaultNextBestNCRM()),
samples = ordinal_samples,
doselimit = Inf,
model = ordinal_model,
data = ordinal_data
)
Number of Doses in Grid
Description
A function that gets the number of doses in grid. User can choose whether the placebo dose (if any) should be counted or not.
Usage
ngrid(object, ignore_placebo = TRUE, ...)
## S4 method for signature 'Data'
ngrid(object, ignore_placebo = TRUE, ...)
Arguments
object |
( |
ignore_placebo |
( |
... |
further arguments passed to class-specific methods. |
Value
integer the number of doses in grid.
Examples
my_data <- Data(
x = c(10, 50, 90, 100, 0.001, 20, 30, 30),
y = c(0, 0, 0, 0, 0, 0, 1, 0),
ID = 1:8,
cohort = c(1L, 2L, 3L, 4L, 5L, 5L, 6L, 6L),
doseGrid = c(0.001, seq(from = 10, to = 100, by = 10)),
placebo = TRUE
)
ngrid(my_data)
ngrid(my_data, ignore_placebo = FALSE)
Combine Two Stopping Rules with OR
Description
The method combining two atomic stopping rules.
Usage
## S4 method for signature 'Stopping,Stopping'
e1 | e2
Arguments
e1 |
( |
e2 |
( |
Value
The StoppingAny object.
Examples
## Example of combining two atomic stopping rules with an OR ('|') operator
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
myStopping <- myStopping1 | myStopping2
Combine an Atomic Stopping Rule and a Stopping List with OR
Description
The method combining an atomic stopping rule and a stopping list.
Usage
## S4 method for signature 'Stopping,StoppingAny'
e1 | e2
Arguments
e1 |
( |
e2 |
( |
Value
The modified StoppingAny object.
Examples
## Example of combining an atomic stopping rule with a list of stopping rules
## with an OR ('|') operator
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
myStopping3 <- StoppingMinPatients(nPatients = 20)
myStopping <- myStopping3 | (myStopping1 & myStopping2)
Combine a Stopping List and an Atomic Stopping Rule with OR
Description
The method combining a stopping list and an atomic stopping rule.
Usage
## S4 method for signature 'StoppingAny,Stopping'
e1 | e2
Arguments
e1 |
( |
e2 |
( |
Value
The modified StoppingAny object.
Examples
## Example of combining a list of stopping rules with an atomic stopping rule
## with an OR ('|') operator
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
myStopping3 <- StoppingMinPatients(nPatients = 20)
myStopping <- (myStopping1 & myStopping2) | myStopping3
Compute the Distribution Function of Inverse Gamma Distribution
Description
Usage
pinvGamma(q, a, b, lower.tail = TRUE, log.p = FALSE)
Arguments
q |
( |
a |
( |
b |
( |
lower.tail |
( |
log.p |
( |
Value
The distribution function value(s).
Plot of the fitted dose-tox based with a given pseudo DLE model and data without samples
Description
Plot of the fitted dose-tox based with a given pseudo DLE model and data without samples
Usage
## S4 method for signature 'Data,ModelTox'
plot(
x,
y,
xlab = "Dose level",
ylab = "Probability of DLE",
showLegend = TRUE,
...
)
Arguments
x |
the data of |
y |
the model of the |
xlab |
the x axis label |
ylab |
the y axis label |
showLegend |
should the legend be shown? (default) |
... |
not used |
Value
This returns the ggplot
object for the dose-DLE model plot
Examples
## plot the dose-DLE curve given a pseudo DLE model using data without samples
## data must be of 'Data' class
## define the data
data <- Data(
x = c(25, 50, 50, 75, 100, 100, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
ID = 1L:8L,
cohort = as.integer(c(1, 2, 2, 3, 4, 4, 5, 6)),
doseGrid = seq(25, 300, 25)
)
## model must be from 'ModelTox' class e.g 'LogisticIndepBeta' class model
## define the model (see LogisticIndepBeta example)
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## plot the dose-DLE curve
## 'x' is the data and 'y' is the model in plot
plot(x = data, y = model)
Plot Method for the DataDA Class
Description
A method that creates a plot for DataDA object.
Usage
## S4 method for signature 'DataDA,missing'
plot(x, y, blind = FALSE, ...)
Arguments
x |
( |
y |
( |
blind |
( |
... |
passed to the first inherited method |
Value
The ggplot2::ggplot2 object.
Examples
# Create some data of class 'DataDA'.
my_data <- DataDA(
u = c(42, 30, 15, 5, 20, 25, 30, 60),
t0 = c(0, 15, 30, 40, 55, 70, 75, 85),
Tmax = 60,
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 1, 1, 0, 0, 1, 0),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Plot the data.
plot(my_data)
Plot of the fitted dose-efficacy based with a given pseudo efficacy model and data without samples
Description
Plot of the fitted dose-efficacy based with a given pseudo efficacy model and data without samples
Usage
## S4 method for signature 'DataDual,ModelEff'
plot(
x,
y,
...,
xlab = "Dose level",
ylab = "Expected Efficacy",
showLegend = TRUE
)
Arguments
x |
the data of |
y |
the model of the |
... |
not used |
xlab |
the x axis label |
ylab |
the y axis label |
showLegend |
should the legend be shown? (default) |
Value
This returns the ggplot
object for the dose-efficacy model plot
Examples
# nolint start
##plot the dose-efficacy curve given a pseudo efficacy model using data without samples
##data must be of 'DataDual' class
##define the data
data <- DataDual(
x = c(25, 50, 50, 75, 100, 100, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
##model must be from 'ModelEff' class e.g 'Effloglog' class model
##define the model (see Effloglog example)
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data
)
## plot the dose-efficacy curve
## 'x' is the data and 'y' is the model in plot
plot(x = data, y = Effmodel)
# nolint end
Plot Method for the DataDual Class
Description
A method that creates a plot for DataDual object.
Usage
## S4 method for signature 'DataDual,missing'
plot(x, y, blind = FALSE, ...)
Arguments
x |
( |
y |
( |
blind |
( |
... |
passed to the first inherited method |
Value
The ggplot2::ggplot2 object.
Examples
# Create some data of class 'DataDual'.
my_data <- DataDual(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 0, 0, 0, 0, 1, 0),
w = rnorm(8),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Plot the data.
plot(my_data)
Plot DualSimulations
Description
This plot method can be applied to DualSimulations objects in order to
summarize them graphically. In addition to the standard plot types, there is:
- sigma2W
Plot a boxplot of the final biomarker variance estimates in the simulated trials
- rho
Plot a boxplot of the final correlation estimates in the simulated trials
Usage
## S4 method for signature 'DualSimulations,missing'
plot(x, y, type = c("trajectory", "dosesTried", "sigma2W", "rho"), ...)
Arguments
x |
( |
y |
( |
type |
( |
... |
not used. |
Value
A single ggplot object if a single plot is asked for,
otherwise a gtable object.
Examples
# Define the dose-grid.
emptydata <- DataDual(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Create some data.
my_data <- DataDual(
x = c(
0.1,
0.5,
1.5,
3,
6,
10,
10,
10,
20,
20,
20,
40,
40,
40,
50,
50,
50
),
y = c(
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
1,
0,
0,
1,
0,
1,
1
),
ID = 1:17,
cohort = c(
1L,
2L,
3L,
4L,
5L,
6L,
6L,
6L,
7L,
7L,
7L,
8L,
8L,
8L,
9L,
9L,
9L
),
w = c(
0.31,
0.42,
0.59,
0.45,
0.6,
0.7,
0.55,
0.6,
0.52,
0.54,
0.56,
0.43,
0.41,
0.39,
0.34,
0.38,
0.21
),
doseGrid = c(
0.1,
0.5,
1.5,
3,
6,
seq(from = 10, to = 80, by = 2)
)
)
# Initialize the CRM model.
my_model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# Choose the rule for selecting the next dose.
my_next_best <- NextBestDualEndpoint(
target = c(0.9, 1),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size
mySize1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
mySize2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
mySize <- maxSize(mySize1, mySize2)
# Choose the rule for stopping
myStopping4 <- StoppingTargetBiomarker(
target = c(0.9, 1),
prob = 0.5
)
myStopping <- myStopping4 | StoppingMinPatients(40)
my_size1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
my_size2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
my_size <- maxSize(my_size1, my_size2)
# Choose the rule for stopping
my_stopping4 <- StoppingTargetBiomarker(
target = c(0.9, 1),
prob = 0.5
)
my_stopping <- my_stopping4 | StoppingMinPatients(40) | StoppingMissingDose()
# Choose the rule for dose increments
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design
my_design <- DualDesign(
model = my_model,
data = emptydata,
nextBest = my_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = CohortSizeConst(3),
startingDose = 3
)
# Define scenarios for the TRUE toxicity and efficacy profiles.
beta_mod <- function(dose, e0, eMax, delta1, delta2, scal) {
maxDens <- (delta1^delta1) *
(delta2^delta2) /
((delta1 + delta2)^(delta1 + delta2))
dose <- dose / scal
e0 + eMax / maxDens * (dose^delta1) * (1 - dose)^delta2
}
true_biomarker <- function(dose) {
beta_mod(
dose,
e0 = 0.2,
eMax = 0.6,
delta1 = 5,
delta2 = 5 * 0.5 / 0.5,
scal = 100
)
}
true_tox <- function(dose) {
pnorm((dose - 60) / 10)
}
# Draw the TRUE profiles
par(mfrow = c(1, 2))
curve(true_tox(x), from = 0, to = 80)
curve(true_biomarker(x), from = 0, to = 80)
# Run the simulation on the desired design.
# We only generate 1 trial outcome here for illustration, for the actual study.
# Also for illustration purpose, we will use 5 burn-ins to generate 20 samples,
# this should be increased of course.
my_sims <- simulate(
object = my_design,
trueTox = true_tox,
trueBiomarker = true_biomarker,
sigma2W = 0.01,
rho = 0,
nsim = 1,
parallel = FALSE,
seed = 9,
startingDose = 6,
mcmcOptions = McmcOptions(
burnin = 1,
step = 1,
samples = 2
)
)
# Plot the results of the simulation.
print(plot(my_sims))
Plot Dual-Endpoint Design Simulation Summary
Description
Graphical display of dual-endpoint simulation summary.
This plot method can be applied to DualSimulationsSummary objects in
order to summarize them graphically. Possible type of plots at the moment
are those listed in plot,SimulationsSummary,missing-method plus:
- meanBiomarkerFit
Plot showing the average fitted dose-biomarker curve across the trials, together with 95% credible intervals, and comparison with the assumed truth (as specified by the
trueBiomarkerargument tosummary,DualSimulations-method)
You can specify any subset of these in the type argument.
Usage
## S4 method for signature 'DualSimulationsSummary,missing'
plot(
x,
y,
type = c("nObs", "doseSelected", "propDLTs", "nAboveTarget", "meanFit",
"meanBiomarkerFit"),
...
)
Arguments
x |
( |
y |
( |
type |
( |
... |
not used. |
Value
A single ggplot object if a single plot is
asked for, otherwise a gtable object.
Examples
# Define the dose-grid.
emptydata <- DataDual(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Initialize the CRM model.
my_model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# Choose the rule for selecting the next dose.
my_next_best <- NextBestDualEndpoint(
target = c(0.9, 1),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size.
my_size1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
my_size2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
my_size <- maxSize(my_size1, my_size2)
# Choose the rule for stopping.
my_stopping4 <- StoppingTargetBiomarker(
target = c(0.9, 1),
prob = 0.5
)
# Only 10 patients here for illustration!
my_stopping <- my_stopping4 | StoppingMinPatients(10) | StoppingMissingDose()
# Choose the rule for dose increments.
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design.
my_design <- DualDesign(
model = my_model,
data = emptydata,
nextBest = my_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = CohortSizeConst(3),
startingDose = 3
)
# Define scenarios for the TRUE toxicity and efficacy profiles.
beta_mod <- function(dose, e0, eMax, delta1, delta2, scal) {
maxDens <- (delta1^delta1) *
(delta2^delta2) /
((delta1 + delta2)^(delta1 + delta2))
dose <- dose / scal
e0 + eMax / maxDens * (dose^delta1) * (1 - dose)^delta2
}
true_biomarker <- function(dose) {
beta_mod(
dose,
e0 = 0.2,
eMax = 0.6,
delta1 = 5,
delta2 = 5 * 0.5 / 0.5,
scal = 100
)
}
true_tox <- function(dose) {
pnorm((dose - 60) / 10)
}
# Draw the TRUE profiles.
par(mfrow = c(1, 2))
curve(true_tox(x), from = 0, to = 80)
curve(true_biomarker(x), from = 0, to = 80)
# Run the simulation on the desired design.
# We only generate 1 trial outcome here for illustration, for the actual study.
# For illustration purpose we will use 5 burn-ins to generate 20 samples,
# this should be increased of course.
my_sims <- simulate(
object = my_design,
trueTox = true_tox,
trueBiomarker = true_biomarker,
sigma2W = 0.01,
rho = 0,
nsim = 1,
parallel = FALSE,
seed = 3,
startingDose = 6,
mcmcOptions = McmcOptions(
burnin = 5,
step = 1,
samples = 20
)
)
# Plot the summary of the Simulations.
plot(summary(my_sims, trueTox = true_tox, trueBiomarker = true_biomarker))
Plot GeneralSimulations
Description
Summarize the simulations with plots.
This plot method can be applied to GeneralSimulations objects in order
to summarize them graphically. Possible types of plots at the moment are:
- trajectory
Summary of the trajectory of the simulated trials
- dosesTried
Average proportions of the doses tested in patients
You can specify one or both of these in the type argument.
Usage
## S4 method for signature 'GeneralSimulations,missing'
plot(x, y, type = c("trajectory", "dosesTried"), ...)
Arguments
x |
( |
y |
( |
type |
( |
... |
not used. |
Value
A single ggplot object if a single plot is
asked for, otherwise a gtable object.
Examples
# nolint start
## obtain the plot for the simulation results
## If only DLE responses are considered in the simulations
## Specified your simulations when no DLE samples are used
## Define your data set first using an empty data set
## with dose levels from 25 to 300 with increments 25
data <- Data(doseGrid = seq(25, 300, 25))
## Specified the model of 'ModelTox' class eg 'LogisticIndepBeta' class model
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## Then the escalation rule
tdNextBest <- NextBestTD(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
## The cohort size, size of 3 subjects
mySize <- CohortSizeConst(size = 3)
## Deifne the increments for the dose-escalation process
## The maximum increase of 200% for doses up to the maximum of the dose specified in the doseGrid
## The maximum increase of 200% for dose above the maximum of the dose specified in the doseGrid
## This is to specified a maximum of 3-fold restriction in dose-esclation
myIncrements <- IncrementsRelative(
intervals = c(min(data@doseGrid), max(data@doseGrid)),
increments = c(2, 2)
)
## Specified the stopping rule e.g stop when the maximum sample size of 12 patients has been reached
myStopping <- StoppingMinPatients(nPatients = 12)
## Now specified the design with all the above information and starting with a dose of 25
design <- TDDesign(
model = model,
nextBest = tdNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = data,
startingDose = 25
)
## Specify the truth of the DLE responses
myTruth <- probFunction(model, phi1 = -53.66584, phi2 = 10.50499)
## Then specified the simulations and generate the trial
## For illustration purpose only 1 simulation is produced (nsim=1).
## The simulations
mySim <- simulate(
design,
args = NULL,
truth = myTruth,
nsim = 1,
seed = 819,
parallel = FALSE
)
## plot the simulations
print(plot(mySim))
## If DLE samples are involved
## The escalation rule
tdNextBest <- NextBestTDsamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, probs = 0.3))
}
)
## specify the design
design <- TDsamplesDesign(
model = model,
nextBest = tdNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = data,
startingDose = 25
)
## options for MCMC
## The simulations
## For illustration purpose only 1 simulation is produced (nsim=1).
# mySim <- simulate(design,
# args=NULL,
# truth=myTruth,
# nsim=1,
# seed=819,
# mcmcOptions=options,
# parallel=FALSE)
#
# ##plot the simulations
# print(plot(mySim))
#
# nolint end
Plot GeneralSimulationsSummary
Description
Graphical display of the general simulation summary.
This plot method can be applied to GeneralSimulationsSummary objects in
order to summarize them graphically. Possible types of plots at the moment
are:
- nObs
Distribution of the number of patients in the simulated trials
- doseSelected
Distribution of the final selected doses in the trials. Note that this can include zero entries, meaning that the trial was stopped because all doses in the dose grid appeared too toxic.
- propDLTs
Distribution of the proportion of patients with DLTs in the trials
- nAboveTarget
Distribution of the number of patients treated at doses which are above the target toxicity interval (as specified by the
truthandtargetarguments tosummary,GeneralSimulations-method)
You can specify any subset of these in the type argument.
Usage
## S4 method for signature 'GeneralSimulationsSummary,missing'
plot(x, y, type = c("nObs", "doseSelected", "propDLTs", "nAboveTarget"), ...)
Arguments
x |
( |
y |
( |
type |
( |
... |
not used. |
Value
A single ggplot object if a single plot is
asked for, otherwise a gtable object.
Plot PseudoDualFlexiSimulations
Description
Summarize the simulations with plots.
This plot method can be applied to PseudoDualFlexiSimulations objects in
order to summarize them graphically. Possible types of plots at the moment
are:
- trajectory
Summary of the trajectory of the simulated trials
- dosesTried
Average proportions of the doses tested in patients
- sigma2
The variance of the efficacy responses
- sigma2betaW
The variance of the random walk model
You can specify one or both of these in the type argument.
Usage
## S4 method for signature 'PseudoDualFlexiSimulations,missing'
plot(x, y, type = c("trajectory", "dosesTried", "sigma2", "sigma2betaW"), ...)
Arguments
x |
( |
y |
( |
type |
( |
... |
not used. |
Value
A single ggplot2 object if a single plot is asked for, otherwise a
gtable object.
Examples
# Obtain the plot for the simulation results if DLE and efficacy responses
# are considered in the simulations.
emptydata <- DataDual(doseGrid = seq(25, 300, 25))
# The DLE model must be of 'ModelTox' (e.g 'LogisticIndepBeta') class.
dle_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = emptydata
)
# The efficacy model must be of 'EffFlexi' class.
eff_model <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = emptydata
)
# The escalation rule using the 'NextBestMaxGainSamples' class.
my_next_best <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
# The cohort size, size of 3 subjects.
my_size <- CohortSizeConst(size = 3)
# Allow increase of 200%.
my_increments <- IncrementsRelative(intervals = 0, increments = 2)
# Define the stopping rule. Stop when the maximum sample size of 36 patients has
# been reached or when the next dose is NA.
my_stopping <- StoppingMinPatients(nPatients = 36) | StoppingMissingDose()
# Specify the design.
design <- DualResponsesSamplesDesign(
nextBest = my_next_best,
cohort_size = my_size,
startingDose = 25,
model = dle_model,
eff_model = eff_model,
data = emptydata,
stopping = my_stopping,
increments = my_increments
)
# Specify the true DLE curve and the true expected efficacy values
# at all dose levels.
my_truth_dle <- probFunction(dle_model, phi1 = -53.66584, phi2 = 10.50499)
my_truth_eff <- c(
-0.5478867,
0.1645417,
0.5248031,
0.7604467,
0.9333009,
1.0687031,
1.1793942,
1.2726408,
1.3529598,
1.4233411,
1.4858613,
1.5420182
)
# The true gain curve.
my_truth_gain <- function(dose) {
return((myTruthEff(dose)) / (1 + (myTruthDLE(dose) / (1 - myTruthDLE(dose)))))
}
# MCMC options.
my_options <- McmcOptions(burnin = 10, step = 1, samples = 20)
# For illustration purpose only 1 simulation is produced.
my_sim <- simulate(
object = design,
args = NULL,
trueDLE = my_truth_dle,
trueEff = my_truth_eff,
trueSigma2 = 0.025,
trueSigma2betaW = 1,
mcmcOptions = my_options,
nsim = 1,
seed = 819,
parallel = FALSE
)
# Plot the simulated results.
print(plot(my_sim))
Plot PseudoDualSimulations
Description
Summarize the simulations with plots.
This plot method can be applied to PseudoDualSimulations objects in
order to summarize them graphically. Possible types of plots at the moment
are:
- trajectory
Summary of the trajectory of the simulated trials
- dosesTried
Average proportions of the doses tested in patients
- sigma2
The variance of the efficacy responses
You can specify one or both of these in the type argument.
Usage
## S4 method for signature 'PseudoDualSimulations,missing'
plot(x, y, type = c("trajectory", "dosesTried", "sigma2"), ...)
Arguments
x |
( |
y |
( |
type |
( |
... |
not used. |
Value
A single ggplot2 object if a single plot is asked for, otherwise a
gtable object.
Examples
# Obtain the plot for the simulation results if DLE and efficacy responses
# are considered in the simulations.
# Example to run simulations when no samples are used. The data object
# must be defined with doses >= 1:
emptydata <- DataDual(doseGrid = seq(25, 300, 25), placebo = FALSE)
# The DLE model must be of 'ModelTox' (e.g 'LogisticIndepBeta') class.
dle_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = emptydata
)
# The efficacy model must be of 'ModelEff' (e.g 'Effloglog') class.
eff_model <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = emptydata
)
# The escalation rule using the 'NextBestMaxGain' class.
my_next_best <- NextBestMaxGain(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
# Allow increase of 200%.
my_increments <- IncrementsRelative(intervals = 0, increments = 2)
# Cohort size of 3.
my_size <- CohortSizeConst(size = 3)
# Stop only when 36 subjects are treated or next dose is NA.
my_stopping <- StoppingMinPatients(nPatients = 36) | StoppingMissingDose()
# Now specify the design with all the above information and starting with a
# dose of 25 (for details please refer to the 'DualResponsesDesign' example).
my_design <- DualResponsesDesign(
nextBest = my_next_best,
model = dle_model,
eff_model = eff_model,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 25
)
# Specify the true DLE and efficacy curves.
my_truth_dle <- probFunction(dle_model, phi1 = -53.66584, phi2 = 10.50499)
my_truth_eff <- efficacyFunction(
eff_model,
theta1 = -4.818429,
theta2 = 3.653058
)
# Run simulations (for illustration purpose only 1 simulation is produced).
my_sim <- simulate(
object = my_design,
args = NULL,
trueDLE = my_truth_dle,
trueEff = my_truth_eff,
trueNu = 1 / 0.025,
nsim = 1,
seed = 819,
parallel = FALSE
)
# Plot the simulation results.
print(plot(my_sim))
# Example if DLE and efficacy samples are involved.
# The escalation rule using the 'NextBestMaxGainSamples' class.
my_next_best <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
# The design of 'DualResponsesSamplesDesign' class.
my_design <- DualResponsesSamplesDesign(
nextBest = my_next_best,
cohort_size = my_size,
startingDose = 25,
model = dle_model,
eff_model = eff_model,
data = emptydata,
stopping = my_stopping,
increments = my_increments
)
# Options for MCMC.
my_options <- McmcOptions(burnin = 10, step = 1, samples = 20)
# For illustration purpose only 1 simulation is produced (nsim = 1).
my_sim <- simulate(
object = my_design,
args = NULL,
trueDLE = my_truth_dle,
trueEff = my_truth_eff,
trueNu = 1 / 0.025,
nsim = 1,
mcmcOptions = my_options,
seed = 819,
parallel = FALSE
)
# Plot the simulation results.
print(plot(my_sim))
Plot PseudoDualSimulationsSummary
Description
Plot the summary of PseudoDualSimulations.
This plot method can be applied to PseudoDualSimulationsSummary objects
in order to summarize them graphically. Possible type of plots at the
moment are those listed in plot,PseudoSimulationsSummary,missing-method
plus:
- meanEffFit
Plot showing the fitted dose-efficacy curve. If no samples are involved, only the average fitted dose-efficacy curve across the trials will be plotted. If samples (DLE and efficacy) are involved, the average fitted dose-efficacy curve across the trials, together with the 95% credibility interval; and comparison with the assumed truth (as specified by the
trueEffargument tosummary,PseudoDualSimulations-method)
You can specify any subset of these in the type argument.
Usage
## S4 method for signature 'PseudoDualSimulationsSummary,missing'
plot(
x,
y,
type = c("nObs", "doseSelected", "propDLE", "nAboveTargetEndOfTrial", "meanFit",
"meanEffFit"),
...
)
Arguments
x |
( |
y |
( |
type |
( |
... |
not used. |
Value
A single ggplot2 object if a single plot is asked for, otherwise a
gtable object.
Examples
# Obtain the summary plot for the simulation results if DLE and efficacy
# responses are considered in the simulations.
# In the example when no samples are used a data object with doses >= 1
# needs to be defined.
emptydata <- DataDual(doseGrid = seq(25, 300, 25), placebo = FALSE)
# The DLE model must be of 'ModelTox' (e.g 'LogisticIndepBeta') class.
dle_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = emptydata
)
# The efficacy model of 'ModelEff' (e.g 'Effloglog') class.
eff_model <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = emptydata
)
# The escalation rule using the 'NextBestMaxGain' class.
my_next_best <- NextBestMaxGain(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
# Allow increase of 200%.
my_increments <- IncrementsRelative(intervals = 0, increments = 2)
# Cohort size of 3.
my_size <- CohortSizeConst(size = 3)
# Stop when 10 subjects are treated (for illustration only).
my_stopping <- StoppingMinPatients(nPatients = 10)
## Now specified the design with all the above information and starting with a dose of 25
# Specify the design. (For details please refer to the 'DualResponsesDesign' example.)
my_design <- DualResponsesDesign(
nextBest = my_next_best,
model = dle_model,
eff_model = eff_model,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 25
)
# Specify the true DLE and efficacy curves.
my_truth_dle <- probFunction(dle_model, phi1 = -53.66584, phi2 = 10.50499)
my_truth_eff <- efficacyFunction(eff_model, theta1 = -4.818429, theta2 = 3.653058)
# For illustration purpose only 1 simulation is produced.
my_sim <- simulate(
object = my_design,
args = NULL,
trueDLE = my_truth_dle,
trueEff = my_truth_eff,
trueNu = 1 / 0.025,
nsim = 1,
mcmcOptions = McmcOptions(burnin = 10, step = 1, samples = 50),
seed = 819,
parallel = FALSE
)
# Summary of the simulations.
my_sum <- summary(
my_sim,
trueDLE = my_truth_dle,
trueEff = my_truth_eff
)
# Plot the summary of the simulations.
print(plot(my_sum))
# Example where DLE and efficacy samples are involved.
# Please refer to design-method 'simulate DualResponsesSamplesDesign' examples
# for details.
# Specify the next best method.
my_next_best <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
# Specify the design.
my_design <- DualResponsesSamplesDesign(
nextBest = my_next_best,
cohort_size = my_size,
startingDose = 25,
model = dle_model,
eff_model = eff_model,
data = emptydata,
stopping = my_stopping,
increments = my_increments
)
# MCMC options.
my_options <- McmcOptions(burnin = 10, step = 2, samples = 50)
# For illustration purpose only 1 simulation is produced.
my_sim <- simulate(
object = my_design,
args = NULL,
trueDLE = my_truth_dle,
trueEff = my_truth_eff,
trueNu = 1 / 0.025,
nsim = 1,
mcmcOptions = my_options,
seed = 819,
parallel = FALSE
)
# Generate a summary of the simulations.
my_sum <- summary(
my_sim,
trueDLE = my_truth_dle,
trueEff = my_truth_eff
)
# Plot the summary of the simulations.
print(plot(my_sum))
# Example where the 'EffFlexi' class is used for the efficacy model.
eff_model <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = emptydata
)
# Specify the design.
my_design <- DualResponsesSamplesDesign(
nextBest = my_next_best,
cohort_size = my_size,
startingDose = 25,
model = dle_model,
eff_model = eff_model,
data = emptydata,
stopping = my_stopping,
increments = my_increments
)
# Specify the true DLE curve and the true expected efficacy values at all dose levels.
my_truth_dle <- probFunction(dle_model, phi1 = -53.66584, phi2 = 10.50499)
my_truth_eff <- c(
-0.5478867, 0.1645417, 0.5248031, 0.7604467,
0.9333009, 1.0687031, 1.1793942, 1.2726408,
1.3529598, 1.4233411, 1.4858613, 1.5420182
)
# Define the true gain curve.
my_truth_gain <- function(dose) {
return((my_truth_eff(dose)) / (1 + (my_truth_dle(dose) / (1 - my_truth_dle(dose)))))
}
## The simulations
## For illustration purpose only 1 simulation is produced (nsim=1).
mySim <- simulate(
object = my_design,
args = NULL,
trueDLE = my_truth_dle,
trueEff = my_truth_eff,
trueSigma2 = 0.025,
trueSigma2betaW = 1,
nsim = 1,
mcmcOptions = my_options,
seed = 819,
parallel = FALSE
)
# Produce a summary of the simulations.
my_sum <- summary(
my_sim,
trueDLE = my_truth_dle,
trueEff = my_truth_eff
)
# Plot the summary of the simulations.
print(plot(my_sim))
Plot PseudoSimulationsSummary
Description
Graphical display of the simulation summary.
This plot method can be applied to PseudoSimulationsSummary objects in
order to summarize them graphically. This can be used when only DLE responses
are involved in the simulations. This also applied to results with or without
samples generated during the simulations.
Usage
## S4 method for signature 'PseudoSimulationsSummary,missing'
plot(
x,
y,
type = c("nObs", "doseSelected", "propDLE", "nAboveTargetEndOfTrial", "meanFit"),
...
)
Arguments
x |
( |
y |
( |
type |
( |
... |
not used. |
Value
A single ggplot2 object if a single plot is asked for, otherwise a
gtable object.
Examples
# nolint start
## obtain the plot for the simulation results
## If only DLE responses are considered in the simulations
## Specified your simulations when no DLE samples are used
## Define your data set first using an empty data set
## with dose levels from 25 to 300 with increments 25
data <- Data(doseGrid = seq(25, 300, 25))
## Specified the model of 'ModelTox' class eg 'LogisticIndepBeta' class model
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## Then the escalation rule
tdNextBest <- NextBestTD(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
## The cohort size, size of 3 subjects
mySize <- CohortSizeConst(size = 3)
## Deifne the increments for the dose-escalation process
## The maximum increase of 200% for doses up to the maximum of the dose specified in the doseGrid
## The maximum increase of 200% for dose above the maximum of the dose specified in the doseGrid
## This is to specified a maximum of 3-fold restriction in dose-esclation
myIncrements <- IncrementsRelative(
intervals = c(min(data@doseGrid), max(data@doseGrid)),
increments = c(2, 2)
)
## Specified the stopping rule e.g stop when the maximum sample size of 12 patients has been reached
myStopping <- StoppingMinPatients(nPatients = 12)
## Now specified the design with all the above information and starting with a dose of 25
design <- TDDesign(
model = model,
nextBest = tdNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = data,
startingDose = 25
)
## Specify the truth of the DLE responses
myTruth <- probFunction(model, phi1 = -53.66584, phi2 = 10.50499)
## Then specified the simulations and generate the trial
## For illustration purpose only 1 simulation is produced (nsim=1).
## The simulations
mySim <- simulate(
design,
args = NULL,
truth = myTruth,
nsim = 1,
seed = 819,
parallel = FALSE
)
## Then produce a summary of your simulations
MYSUM <- summary(mySim, truth = myTruth)
## plot the summary of the simulations
print(plot(MYSUM))
## If DLE samples are involved
## The escalation rule
tdNextBest <- NextBestTDsamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, probs = 0.3))
}
)
## specify the design
design <- TDsamplesDesign(
model = model,
nextBest = tdNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = data,
startingDose = 25
)
## options for MCMC
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
## The simulations
## For illustration purpose only 1 simulation is produced (nsim=1).
# mySim <- simulate(design,
# args=NULL,
# truth=myTruth,
# nsim=1,
# seed=819,
# mcmcOptions=options,
# parallel=FALSE)
# ##Then produce a summary of your simulations
# MYSUM <- summary(mySim,
# truth=myTruth)
# ##plot the summary of the simulations
# print(plot(MYSUM))
# nolint end
Plotting dose-toxicity model fits
Description
Plotting dose-toxicity model fits
Usage
## S4 method for signature 'Samples,DALogisticLogNormal'
plot(x, y, data, hazard = FALSE, ..., showLegend = TRUE)
Arguments
x |
the |
y |
the |
data |
the |
hazard |
see |
... |
not used |
showLegend |
should the legend be shown? (default) |
Value
This returns the ggplot
object for the dose-toxicity model fit
Plotting dose-toxicity and dose-biomarker model fits
Description
When we have the dual endpoint model, also the dose-biomarker fit is shown in the plot
Usage
## S4 method for signature 'Samples,DualEndpoint'
plot(x, y, data, extrapolate = TRUE, showLegend = FALSE, ...)
Arguments
x |
the |
y |
the |
data |
the |
extrapolate |
should the biomarker fit be extrapolated to the whole dose grid? (default) |
showLegend |
should the legend be shown? (not default) |
... |
additional arguments for the parent method
|
Value
This returns the ggplot
object with the dose-toxicity and dose-biomarker model fits
Examples
# nolint start
# Create some data
data <- DataDual(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10, 20, 20, 20, 40, 40, 40, 50, 50, 50),
y = c(0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1),
w = c(
0.31,
0.42,
0.59,
0.45,
0.6,
0.7,
0.55,
0.6,
0.52,
0.54,
0.56,
0.43,
0.41,
0.39,
0.34,
0.38,
0.21
),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Initialize the Dual-Endpoint model (in this case RW1)
model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# Set-up some MCMC parameters and generate samples from the posterior
options <- McmcOptions(burnin = 100, step = 2, samples = 500)
set.seed(94)
samples <- mcmc(data, model, options)
# Plot the posterior mean (and empirical 2.5 and 97.5 percentile)
# for the prob(DLT) by doses and the Biomarker by doses
#grid.arrange(plot(x = samples, y = model, data = data))
plot(x = samples, y = model, data = data)
# nolint end
Plotting dose-toxicity model fits
Description
Plotting dose-toxicity model fits
Usage
## S4 method for signature 'Samples,GeneralModel'
plot(
x,
y,
data,
...,
xlab = "Dose level",
ylab = "Probability of DLT [%]",
showLegend = TRUE
)
Arguments
x |
the |
y |
the |
data |
the |
... |
not used |
xlab |
the x axis label |
ylab |
the y axis label |
showLegend |
should the legend be shown? (default) |
Value
This returns the ggplot
object for the dose-toxicity model fit
Examples
# nolint start
# Create some data
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),
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 a model
model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Get posterior for all model parameters
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Plot the posterior mean (and empirical 2.5 and 97.5 percentile)
# for the prob(DLT) by doses
plot(x = samples, y = model, data = data)
# nolint end
Plot the fitted dose-efficacy curve using a model from ModelEff class
with samples
Description
Plot the fitted dose-efficacy curve using a model from ModelEff class
with samples
Usage
## S4 method for signature 'Samples,ModelEff'
plot(
x,
y,
data,
...,
xlab = "Dose level",
ylab = "Expected Efficacy",
showLegend = TRUE
)
Arguments
x |
the |
y |
the |
data |
the |
... |
not used |
xlab |
the x axis label |
ylab |
the y axis label |
showLegend |
should the legend be shown? (default) |
Value
This returns the ggplot
object for the dose-efficacy model fit
Examples
# nolint start
## we need a data object with doses >= 1:
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
##plot the dose-efficacy curve with samples using the model from 'ModelEff'
##class e.g. 'Effloglog' class model
##define the model (see Effloglog example)
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data
)
## define the samples obtained using the 'Effloglog' model (see details in 'Samples' example)
##options for MCMC
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
## samples must be of 'Samples' class
samples <- mcmc(data = data, model = Effmodel, options = options)
## plot the fitted dose-efficacy curve including the 95% credibility interval of the samples
## 'x' should be of 'Samples' class and 'y' of 'ModelEff' class
plot(x = samples, y = Effmodel, data = data)
# nolint end
Plot the fitted dose-DLE curve using a ModelTox class model with samples
Description
Plot the fitted dose-DLE curve using a ModelTox class model with samples
Usage
## S4 method for signature 'Samples,ModelTox'
plot(
x,
y,
data,
...,
xlab = "Dose level",
ylab = "Probability of DLT [%]",
showLegend = TRUE
)
Arguments
x |
the |
y |
the |
data |
the |
... |
not used |
xlab |
the x axis label |
ylab |
the y axis label |
showLegend |
should the legend be shown? (default) |
Value
This returns the ggplot
object for the dose-DLE model fit
Examples
## we need a data object with doses >= 1:
data <- Data(
x = c(25, 50, 50, 75, 150, 200, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
doseGrid = seq(from = 25, to = 300, by = 25)
)
## plot the dose-DLE curve with samples using the model from 'ModelTox'
## class e.g. 'LogisticIndepBeta' class model
## define the model (see LogisticIndepBeta example)
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## define the samples obtained using the 'LogisticIndepGBeta' model
## Define options for MCMC
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
## (see details in 'Samples' example) samples must be of 'Samples' class
samples <- mcmc(data = data, model = model, options = options)
## plot the fitted dose-DLE curve including the 95% credibility interval of the samples
## 'x' should be of 'Samples' class and 'y' of 'ModelTox' class
plot(x = samples, y = model, data = data)
Plot Model-Based Design Simulation Summary
Description
Graphical display of the simulation summary.
This plot method can be applied to SimulationsSummary objects in order
to summarize them graphically. Possible type of plots at the moment are
those listed in plot,GeneralSimulationsSummary,missing-method plus:
- meanFit
Plot showing the average fitted dose-toxicity curve across the trials, together with 95% credible intervals, and comparison with the assumed truth (as specified by the
truthargument tosummary,Simulations-method)
You can specify any subset of these in the type argument.
Usage
## S4 method for signature 'SimulationsSummary,missing'
plot(
x,
y,
type = c("nObs", "doseSelected", "propDLTs", "nAboveTarget", "meanFit"),
...
)
Arguments
x |
( |
y |
( |
type |
( |
... |
not used. |
Value
A single ggplot object if a single plot is
asked for, otherwise a gtable object.
Examples
# nolint start
# Define the dose-grid
emptydata <- Data(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Initialize the CRM model
model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Choose the rule for selecting the next dose
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size
mySize1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
mySize2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
mySize <- maxSize(mySize1, mySize2)
# Choose the rule for stopping
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
myStopping3 <- StoppingMinPatients(nPatients = 20)
myStopping <- (myStopping1 & myStopping2) | myStopping3
# Choose the rule for dose increments
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design
design <- Design(
model = model,
nextBest = myNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = emptydata,
startingDose = 3
)
## define the true function
myTruth <- probFunction(model, alpha0 = 7, alpha1 = 8)
# Run the simulation on the desired design
# We only generate 1 trial outcomes here for illustration, for the actual study
# this should be increased of course
options <- McmcOptions(
burnin = 10,
step = 1,
samples = 100
)
time <- system.time(
mySims <- simulate(
design,
args = NULL,
truth = myTruth,
nsim = 1,
seed = 819,
mcmcOptions = options,
parallel = FALSE
)
)[3]
# Plot the Summary of the Simulations
plot(summary(mySims, truth = myTruth))
# nolint end
Plot gtable Objects
Description
This is needed because crmPack uses gridExtra::arrangeGrob() to combine
ggplot2 plots, and the resulting gtable object is not plotted otherwise
when implicitly printing it in the console.
Usage
## S3 method for class 'gtable'
plot(x, ...)
## S3 method for class 'gtable'
print(x, ...)
Arguments
x |
( |
... |
additional parameters passed to |
Value
Called for side effects.
Plot of the DLE and efficacy curve side by side given a DLE pseudo model, a DLE sample, an efficacy pseudo model and a given efficacy sample
Description
Plot of the DLE and efficacy curve side by side given a DLE pseudo model, a DLE sample, an efficacy pseudo model and a given efficacy sample
Plot of the dose-DLE and dose-efficacy curve side by side given a DLE pseudo model and a given pseudo efficacy model without DLE and efficacy samples
Usage
plotDualResponses(DLEmodel, DLEsamples, Effmodel, Effsamples, data, ...)
## S4 method for signature 'ModelTox,Samples,ModelEff,Samples'
plotDualResponses(
DLEmodel,
DLEsamples,
Effmodel,
Effsamples,
data,
extrapolate = TRUE,
showLegend = FALSE,
...
)
## S4 method for signature 'ModelTox,missing,ModelEff,missing'
plotDualResponses(DLEmodel, DLEsamples, Effmodel, Effsamples, data, ...)
Arguments
DLEmodel |
the pseudo DLE model of |
DLEsamples |
the DLE samples of |
Effmodel |
the pseudo efficacy model of |
Effsamples |
the Efficacy samples of |
data |
the data input of |
... |
additional arguments for the parent method
|
extrapolate |
should the biomarker fit be extrapolated to the whole dose grid? (default) |
showLegend |
should the legend be shown? (not default) |
Value
This returns the ggplot
object with the dose-toxicity and dose-efficacy model fits
Functions
-
plotDualResponses( DLEmodel = ModelTox, DLEsamples = Samples, Effmodel = ModelEff, Effsamples = Samples ): function still to be documented -
plotDualResponses( DLEmodel = ModelTox, DLEsamples = missing, Effmodel = ModelEff, Effsamples = missing ): Plot the DLE and efficacy curve side by side given a DLE model and an efficacy model without any samples
Examples
# nolint start
## we need a data object with doses >= 1:
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
##plot the dose-DLE and dose-efficacy curves in two plots with DLE and efficacy samples
##define the DLE model which must be of 'ModelTox' class
##(e.g 'LogisticIndepBeta' class model)
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## define the efficacy model which must be of 'ModelEff' class
## (e.g 'Effloglog' class)
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data
)
##define the DLE sample of 'Samples' class
##set up the same data set in class 'Data' for MCMC sampling for DLE
data1 <- Data(x = data@x, y = data@y, doseGrid = data@doseGrid)
##Specify the options for MCMC
options <- McmcOptions(burnin = 100, step = 2, samples = 1000)
DLEsamples <- mcmc(data = data1, model = DLEmodel, options = options)
##define the efficacy sample of 'Samples' class
Effsamples <- mcmc(data = data, model = Effmodel, options = options)
##plot the dose-DLE and dose-efficacy curves with two plot side by side.
##For each curve the 95% credibility interval of the two samples are alos given
plotDualResponses(
DLEmodel = DLEmodel,
DLEsamples = DLEsamples,
Effmodel = Effmodel,
Effsamples = Effsamples,
data = data
)
# nolint end
# nolint start
## we need a data object with doses >= 1:
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
##plot the dose-DLE and dose-efficacy curves in two plots without DLE and efficacy samples
##define the DLE model which must be of 'ModelTox' class
##(e.g 'LogisticIndepBeta' class model)
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## define the efficacy model which must be of 'ModelEff' class
## (e.g 'Effloglog' class)
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data
)
##plot the dose-DLE and dose-efficacy curves with two plot side by side.
plotDualResponses(DLEmodel = DLEmodel, Effmodel = Effmodel, data = data)
# nolint end
Plot the gain curve in addition with the dose-DLE and dose-efficacy curve using a given DLE pseudo model, a DLE sample, a given efficacy pseudo model and an efficacy sample
Description
Plot the gain curve in addition with the dose-DLE and dose-efficacy curve using a given DLE pseudo model, a DLE sample, a given efficacy pseudo model and an efficacy sample
Plot the gain curve in addition with the dose-DLE and dose-efficacy curve using a given DLE pseudo model, and a given efficacy pseudo model
Usage
plotGain(DLEmodel, DLEsamples, Effmodel, Effsamples, data, ...)
## S4 method for signature 'ModelTox,Samples,ModelEff,Samples'
plotGain(DLEmodel, DLEsamples, Effmodel, Effsamples, data, ...)
## S4 method for signature 'ModelTox,missing,ModelEff,missing'
plotGain(DLEmodel, Effmodel, data, size = c(8L, 8L), shape = c(16L, 17L), ...)
Arguments
DLEmodel |
the dose-DLE model of |
DLEsamples |
the DLE sample of |
Effmodel |
the dose-efficacy model of |
Effsamples |
the efficacy sample of of |
data |
the data input of |
... |
not used |
size |
( |
shape |
( |
Value
This returns the ggplot
object for the plot
Functions
-
plotGain( DLEmodel = ModelTox, DLEsamples = Samples, Effmodel = ModelEff, Effsamples = Samples ): Standard method -
plotGain( DLEmodel = ModelTox, DLEsamples = missing, Effmodel = ModelEff, Effsamples = missing ): Standard method
Examples
# nolint start
## we need a data object with doses >= 1:
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
##plot the dose-DLE , dose-efficacy and gain curve in the same plot with DLE and efficacy samples
##define the DLE model which must be of 'ModelTox' class
##(e.g 'LogisticIndepBeta' class model)
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## define the efficacy model which must be of 'ModelEff' class
## (e.g 'Effloglog' class)
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data,
const = 0
)
##define the DLE sample of 'Samples' class
##set up the same data set in class 'Data' for MCMC sampling for DLE
data1 <- Data(x = data@x, y = data@y, doseGrid = data@doseGrid)
##Define the options for MCMC
options <- McmcOptions(burnin = 100, step = 2, samples = 1000)
DLEsamples <- mcmc(data = data1, model = DLEmodel, options = options)
##define the efficacy sample of 'Samples' class
Effsamples <- mcmc(data = data, model = Effmodel, options = options)
##plot the three curves of mean values of the DLEsamples, Effsamples and
##gain value samples (obtained within this plotGain function) at all dose levels
plotGain(
DLEmodel = DLEmodel,
DLEsamples = DLEsamples,
Effmodel = Effmodel,
Effsamples = Effsamples,
data = data
)
# nolint end
# nolint start
## we need a data object with doses >= 1:
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
##plot the dose-DLE , dose-efficacy and gain curve in the same plot with DLE and efficacy samples
##define the DLE model which must be of 'ModelTox' class
##(e.g 'LogisticIndepBeta' class model)
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## define the efficacy model which must be of 'ModelEff' class
## (e.g 'Effloglog' class)
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data
)
##plot the three curves of using modal estimates of model parameters at all dose levels
plotGain(DLEmodel = DLEmodel, Effmodel = Effmodel, data = data)
# nolint end
positive_number
Description
The positive_number class is a class to store not NULL, non NA,
finite and strictly positive numerical value. It is mainly used to store
reference dose value in model classes.
Print Vignette
Description
Taken from utils package (print.vignette).
Usage
printVignette(x, ...)
Arguments
x |
( |
... |
not used. |
Value
x invisibly.
Computing Toxicity Probabilities for a Given Dose, Model and Samples
Description
A function that computes the probability of the occurrence of a DLE at a specified dose level, based on the model parameters (samples).
Usage
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticNormal,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticLogNormal,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticLogNormalSub,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,ProbitLogNormal,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,ProbitLogNormalRel,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticLogNormalGrouped,Samples'
prob(dose, model, samples, group, ...)
## S4 method for signature 'numeric,LogisticKadane,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticKadaneBetaGamma,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticNormalMixture,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticNormalFixedMixture,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticLogNormalMixture,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,DualEndpoint,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticIndepBeta,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticIndepBeta,missing'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,OneParLogNormalPrior,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,OneParExpPrior,Samples'
prob(dose, model, samples, ...)
## S4 method for signature 'numeric,LogisticLogNormalOrdinal,Samples'
prob(dose, model, samples, grade, cumulative = TRUE, ...)
Arguments
dose |
( |
model |
( |
samples |
( |
... |
model specific parameters when |
group |
( |
grade |
( |
cumulative |
( |
Details
The prob() function computes the probability of toxicity for given
doses, using samples of the model parameter(s).
If you work with multivariate model parameters, then assume that your model
specific prob() method receives a samples matrix where the rows
correspond to the sampling index, i.e. the layout is then
nSamples x dimParameter.
Value
A proportion or numeric vector with the toxicity probabilities.
If non-scalar samples were used, then every element in the returned vector
corresponds to one element of a sample. Hence, in this case, the output
vector is of the same length as the sample vector. If scalar samples were
used or no samples were used, e.g. for pseudo DLE/toxicity model,
then the output is of the same length as the length of the dose. In the
case of LogisticLogNormalOrdinal, the probabilities relate to toxicities
of grade given by grade.
Functions
-
prob(dose = numeric, model = LogisticNormal, samples = Samples): -
prob(dose = numeric, model = LogisticLogNormal, samples = Samples): -
prob(dose = numeric, model = LogisticLogNormalSub, samples = Samples): -
prob(dose = numeric, model = ProbitLogNormal, samples = Samples): -
prob(dose = numeric, model = ProbitLogNormalRel, samples = Samples): -
prob(dose = numeric, model = LogisticLogNormalGrouped, samples = Samples): method forLogisticLogNormalGroupedwhich needsgroupargument in addition. -
prob(dose = numeric, model = LogisticKadane, samples = Samples): -
prob(dose = numeric, model = LogisticKadaneBetaGamma, samples = Samples): -
prob(dose = numeric, model = LogisticNormalMixture, samples = Samples): -
prob(dose = numeric, model = LogisticNormalFixedMixture, samples = Samples): -
prob(dose = numeric, model = LogisticLogNormalMixture, samples = Samples): -
prob(dose = numeric, model = DualEndpoint, samples = Samples): -
prob(dose = numeric, model = LogisticIndepBeta, samples = Samples): compute toxicity probabilities of the occurrence of a DLE at a specified dose level, based on the samples ofLogisticIndepBetamodel parameters. -
prob(dose = numeric, model = LogisticIndepBeta, samples = missing): compute toxicity probabilities of the occurrence of a DLE at a specified dose level, based on theLogisticIndepBetamodel parameters. All model parameters (exceptdose) should be present in themodelobject. -
prob(dose = numeric, model = OneParLogNormalPrior, samples = Samples): -
prob(dose = numeric, model = OneParExpPrior, samples = Samples): -
prob(dose = numeric, model = LogisticLogNormalOrdinal, samples = Samples):
Note
The prob() and dose() functions are the inverse of
each other, for all dose() methods for which its first argument, i.e. a
given independent variable that dose depends on, represents toxicity
probability.
See Also
probFunction(), dose(), efficacy().
Examples
# Create some 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),
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 a model, e.g. 'LogisticLogNormal'.
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Get samples from posterior.
my_options <- McmcOptions(burnin = 100, step = 2, samples = 20)
my_samples <- mcmc(data = my_data, model = my_model, options = my_options)
# Posterior for Prob(DLT | dose = 50).
prob(dose = 50, model = my_model, samples = my_samples)
# Create data from the 'DataDual' class.
data_dual <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(from = 25, to = 300, by = 25)
)
# Initialize a toxicity model using 'LogisticIndepBeta' model.
dlt_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data_dual
)
# Get samples from posterior.
dlt_sample <- mcmc(data = data_dual, model = dlt_model, options = my_options)
# Posterior for Prob(DLT | dose = 100).
prob(dose = 100, model = dlt_model, samples = dlt_sample)
prob(dose = c(50, 150), model = dlt_model)
Getting the Prob Function for a Given Model Type
Description
A function that returns a prob() function that computes the toxicity
probabilities for a given dose level, based on the model specific parameters.
Usage
probFunction(model, ...)
## S4 method for signature 'GeneralModel'
probFunction(model, ...)
## S4 method for signature 'ModelTox'
probFunction(model, ...)
## S4 method for signature 'LogisticLogNormalOrdinal'
probFunction(model, grade, ...)
Arguments
model |
( |
... |
model specific parameters. |
grade |
( |
Value
A prob() function that computes toxicity probabilities.
Functions
-
probFunction(GeneralModel): -
probFunction(ModelTox): -
probFunction(LogisticLogNormalOrdinal):
See Also
Examples
my_model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 50
)
prob_fun <- probFunction(my_model, alpha0 = 2, alpha1 = 3)
prob_fun(30)
ordinal_data <- .DefaultDataOrdinal()
ordinal_model <- .DefaultLogisticLogNormalOrdinal()
opts <- .DefaultMcmcOptions()
samples <- mcmc(ordinal_data, ordinal_model, opts)
probFunction(
ordinal_model,
grade = 2L,
alpha2 = samples@data$alpha1,
beta = samples@data$beta
)(50)
Shorthand for Probit Function
Description
Computes the probit (inverse cumulative distribution function of standard normal) transformation.
Usage
probit(x)
Arguments
x |
( |
Value
The probit of x, the quantile function of the standard normal distribution.
Examples
probit(0.5)
probit(c(0.025, 0.5, 0.975))
Compute the Quantile Function of Inverse Gamma Distribution
Description
Usage
qinvGamma(p, a, b, lower.tail = TRUE, log.p = FALSE)
Arguments
p |
( |
a |
( |
b |
( |
lower.tail |
( |
log.p |
( |
Value
The quantile value(s).
Random Generation for the Inverse Gamma Distribution
Description
Usage
rinvGamma(n, a, b)
Arguments
n |
( |
a |
( |
b |
( |
Value
A vector of random values from the inverse gamma distribution.
Determining if this Sample Should be Saved
Description
A method that determines if a sample from a given iteration should be
saved. The sample should be saved if and only if:
it is not in burn-in period and it matches the step.
Usage
saveSample(object, iteration, ...)
## S4 method for signature 'McmcOptions'
saveSample(object, iteration, ...)
Arguments
object |
( |
iteration |
( |
... |
not used. |
Value
TRUE if this sample should be saved.
Functions
-
saveSample(McmcOptions): determine if a sample should be saved.
Examples
# Set up the MCMC option in order to have a burn-in of 10000 iterations and
# then take every other iteration up to a collection of 10000 samples.
my_options <- McmcOptions(burnin = 10000, step = 2, samples = 10000)
size(my_options)
saveSample(my_options, iteration = 5)
Helper Function to Set and Save the RNG Seed
Description
This code is basically copied from stats:::simulate.lm.
Usage
set_seed(seed = NULL)
Arguments
seed |
an object specifying if and how the random number generator
should be initialized ("seeded"). Either |
Value
The integer vector containing the random number generate state will be returned, in order to call this function with this input to reproduce the obtained simulation results.
Show the Summary of Dual-Endpoint Simulations
Description
Display a summary of dual-endpoint simulation results.
Usage
## S4 method for signature 'DualSimulationsSummary'
show(object)
Arguments
object |
( |
Value
Invisibly returns a data frame of the results with one row and appropriate column names.
Examples
# Define the dose-grid.
emptydata <- DataDual(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 30))
# Initialize the CRM model.
my_model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# Choose the rule for selecting the next dose.
my_next_best <- NextBestDualEndpoint(
target = c(0.9, 1),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size.
my_size1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
my_size2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
my_size <- maxSize(my_size1, my_size2)
# Choose the rule for stopping.
my_stopping1 <- StoppingTargetBiomarker(
target = c(0.9, 1),
prob = 0.5
)
# Stop with a small number of patients for illustration.
my_stopping <- my_stopping1 | StoppingMinPatients(10) | StoppingMissingDose()
# Choose the rule for dose increments.
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design.
my_design <- DualDesign(
model = my_model,
data = emptydata,
nextBest = my_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = CohortSizeConst(3),
startingDose = 3
)
# Define scenarios for the TRUE toxicity and efficacy profiles.
beta_mod <- function(dose, e0, eMax, delta1, delta2, scal) {
maxDens <- (delta1^delta1) *
(delta2^delta2) /
((delta1 + delta2)^(delta1 + delta2))
dose <- dose / scal
e0 + eMax / maxDens * (dose^delta1) * (1 - dose)^delta2
}
true_biomarker <- function(dose) {
beta_mod(
dose,
e0 = 0.2,
eMax = 0.6,
delta1 = 5,
delta2 = 5 * 0.5 / 0.5,
scal = 100
)
}
true_tox <- function(dose) {
pnorm((dose - 60) / 10)
}
# Draw the TRUE profiles.
par(mfrow = c(1, 2))
curve(true_tox(x), from = 0, to = 80)
curve(true_biomarker(x), from = 0, to = 80)
# Run the simulation on the desired design.
# For illustration purposes only 1 trial outcome is generated and 5 burn-ins
# to generate 20 samples are used here.
my_sims <- simulate(
object = my_design,
trueTox = true_tox,
trueBiomarker = true_biomarker,
sigma2W = 0.01,
rho = 0,
nsim = 1,
parallel = FALSE,
seed = 3,
startingDose = 6,
mcmcOptions = McmcOptions(
burnin = 5,
step = 1,
samples = 20
)
)
# Show the summary of the simulations.
show(summary(
my_sims,
trueTox = true_tox,
trueBiomarker = true_biomarker
))
Show the Summary of the Simulations
Description
Display a summary of general simulation results.
Usage
## S4 method for signature 'GeneralSimulationsSummary'
show(object)
Arguments
object |
( |
Value
Invisibly returns a data frame of the results with one row and appropriate column names.
Show the Summary of PseudoDualSimulations
Description
Display a summary of pseudo dual simulation results.
Usage
## S4 method for signature 'PseudoDualSimulationsSummary'
show(object)
Arguments
object |
( |
Value
Invisibly returns a data frame of the results with one row and appropriate column names.
Examples
# Example where DLE and efficacy responses are considered in the simulations.
# In simulations where no samples are used a data object with doses >= 1 needs
# to be generated.
emptydata <- DataDual(doseGrid = seq(25, 300, 25), placebo = FALSE)
# The DLE model must be of 'ModelTox' (e.g 'LogisticIndepBeta') class.
dle_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = emptydata
)
# The efficacy model of 'ModelEff' (e.g 'Effloglog') class.
eff_model <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = emptydata
)
# The escalation rule using the 'NextBestMaxGain' class.
my_next_best <- NextBestMaxGain(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
# Allow increase of 200%.
my_increments <- IncrementsRelative(intervals = 0, increments = 2)
# Cohort size of 3.
my_size <- CohortSizeConst(size = 3)
# Stop when 36 subjects are treated or next dose is NA.
my_stopping <- StoppingMinPatients(nPatients = 36) | StoppingMissingDose()
# Specify the design. (For details please refer to the 'DualResponsesDesign' example.)
my_design <- DualResponsesDesign(
nextBest = my_next_best,
model = dle_model,
eff_model = eff_model,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 25
)
# Specify the true DLE and efficacy curves.
my_truth_dle <- probFunction(dle_model, phi1 = -53.66584, phi2 = 10.50499)
my_truth_eff <- efficacyFunction(eff_model, theta1 = -4.818429, theta2 = 3.653058)
# For illustration purpose only 2 simulations are produced.
my_sim <- simulate(
object = my_design,
args = NULL,
trueDLE = my_truth_dle,
trueEff = my_truth_eff,
trueNu = 1 / 0.025,
nsim = 2,
seed = 819,
parallel = FALSE
)
# Summary of the simulations.
my_sum <- summary(
my_sim,
trueDLE = my_truth_dle,
trueEff = my_truth_eff
)
# Show the summary of the simulations in a data frame.
show(my_sum)
# Example when DLE and efficacy samples are involved.
# The escalation rule using the 'NextBestMaxGainSamples' class.
my_next_best <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
# The design of 'DualResponsesSamplesDesign' class.
my_design <- DualResponsesSamplesDesign(
nextBest = my_next_best,
cohort_size = my_size,
startingDose = 25,
model = dle_model,
eff_model = eff_model,
data = emptydata,
stopping = my_stopping,
increments = my_increments
)
# MCMC options.
# For illustration purpose 50 burn-ins to generate 200 samples are used.
my_options <- McmcOptions(burnin = 50, step = 2, samples = 200)
# For illustration purpose 2 trials are simulated.
my_sim <- simulate(
object = my_design,
args = NULL,
trueDLE = my_truth_dle,
trueEff = my_truth_eff,
trueNu = 1 / 0.025,
nsim = 2,
mcmcOptions = my_options,
seed = 819,
parallel = FALSE
)
# Produce a summary of the simulations.
my_sum <- summary(
my_sim,
trueDLE = my_truth_dle,
trueEff = my_truth_eff
)
# Show the summary in data frame for the simulations.
show(my_sum)
Show the Summary of PseudoSimulations
Description
Display a summary of pseudo simulation results.
Usage
## S4 method for signature 'PseudoSimulationsSummary'
show(object)
Arguments
object |
( |
Value
Invisibly returns a data frame of the results with one row and appropriate column names.
Examples
# Obtain the plot for the simulation results if only DLE responses are
# considered in the simulations.
# Specified simulations when no DLE samples are used.
emptydata <- Data(doseGrid = seq(25, 300, 25))
# The design only incorporate DLE responses and DLE samples are involved.
# Specify the model of 'ModelTox' class eg 'LogisticIndepBeta' class model.
my_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = emptydata
)
# The escalation rule.
td_next_best <- NextBestTD(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
# The cohort size is 3 subjects.
my_size <- CohortSizeConst(size = 3)
# Allow increase of 200%.
my_increments <- IncrementsRelative(intervals = 0, increments = 2)
# Specify the stopping rule with maximum sample size of 36 patients or when the
# next dose is NA.
my_stopping <- StoppingMinPatients(nPatients = 36) | StoppingMissingDose()
# Specify the design. (For details please refer to the 'TDDesign' example.)
my_design <- TDDesign(
model = my_model,
nextBest = td_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 25
)
# Specify the truth of the DLE responses.
my_truth <- probFunction(my_model, phi1 = -53.66584, phi2 = 10.50499)
# For illustration purpose only 1 simulation is produced.
my_sim <- simulate(
object = my_design,
args = NULL,
truth = my_truth,
nsim = 1,
seed = 819,
parallel = FALSE
)
# Summary of the simulations.
my_sum <- summary(
my_sim,
truth = my_truth
)
# Show the summary of the simulated results in a data frame.
show(my_sum)
# Example where DLE samples are involved.
# The escalation rule.
td_next_best <- NextBestTDsamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, probs = 0.3))
}
)
# The design.
my_design <- TDsamplesDesign(
model = my_model,
nextBest = td_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 25
)
# For illustration purposes 2 trails are simulated with 50 burn-ins to generate
# 200 samples.
my_options <- McmcOptions(burnin = 50, step = 2, samples = 200)
my_sim <- simulate(
object = my_design,
args = NULL,
truth = my_truth,
nsim = 2,
seed = 819,
mcmcOptions = my_options,
parallel = FALSE
)
# Produce a summary of the simulations.
my_sum <- summary(
my_sim,
truth = my_truth
)
# Show the summary of the simulated results in a data frame.
show(my_sum)
Show the Summary of Model-Based Design Simulations
Description
Display a summary of model-based design simulation results.
Usage
## S4 method for signature 'SimulationsSummary'
show(object)
Arguments
object |
( |
Value
Invisibly returns a data frame of the results with one row and appropriate column names.
Examples
# nolint start
# Define the dose-grid
emptydata <- Data(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Initialize the CRM model
model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Choose the rule for selecting the next dose
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size
mySize1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
mySize2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
mySize <- maxSize(mySize1, mySize2)
# Choose the rule for stopping
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
myStopping3 <- StoppingMinPatients(nPatients = 20)
myStopping <- (myStopping1 & myStopping2) | myStopping3
# Choose the rule for dose increments
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design
design <- Design(
model = model,
nextBest = myNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = emptydata,
startingDose = 3
)
## define the true function
myTruth <- probFunction(model, alpha0 = 7, alpha1 = 8)
# Run the simulation on the desired design
# We only generate 1 trial outcome here for illustration, for the actual study
# this should be increased of course
options <- McmcOptions(
burnin = 100,
step = 2,
samples = 1000
)
time <- system.time(
mySims <- simulate(
design,
args = NULL,
truth = myTruth,
nsim = 1,
seed = 819,
mcmcOptions = options,
parallel = FALSE
)
)[3]
# Show the Summary of the Simulations
show(summary(mySims, truth = myTruth))
# nolint end
Simulate outcomes from a time-to-DLT augmented CRM design
Description
This method simulates dose escalation trials using time-to-DLT data, where the timing of dose-limiting toxicities is explicitly modeled.
Usage
## S4 method for signature 'DADesign'
simulate(
object,
nsim = 1L,
seed = NULL,
truthTox,
truthSurv,
trueTmax = NULL,
args = NULL,
firstSeparate = FALSE,
deescalate = TRUE,
mcmcOptions = McmcOptions(),
DA = TRUE,
parallel = FALSE,
nCores = min(parallel::detectCores(), 5),
derive = list(),
...
)
Arguments
object |
the |
nsim |
( |
seed |
see |
truthTox |
( |
truthSurv |
( |
trueTmax |
( |
args |
( |
firstSeparate |
( |
deescalate |
( |
mcmcOptions |
(McmcOptions) |
DA |
( |
parallel |
( |
nCores |
( |
derive |
( |
... |
not used |
Value
an object of class Simulations
Examples
# nolint start
# Define the dose-grid and PEM parameters
emptydata <- DataDA(
doseGrid = c(0.1, 0.5, 1, 1.5, 3, 6, seq(from = 10, to = 80, by = 2)),
Tmax = 60
)
# Initialize the mDA-CRM model
npiece_ <- 10
Tmax_ <- 60
lambda_prior <- function(k) {
npiece_ / (Tmax_ * (npiece_ - k + 0.5))
}
model <- DALogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56,
npiece = npiece_,
l = as.numeric(t(apply(as.matrix(c(1:npiece_), 1, npiece_), 2, lambda_prior))),
c_par = 2
)
# Choose the rule for dose increments
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size
mySize1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
mySize2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
mySize <- maxSize(mySize1, mySize2)
# Choose the rule for stopping
myStopping1 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
myStopping2 <- StoppingMinPatients(nPatients = 50)
myStopping <- (myStopping1 | myStopping2)
# Choose the safety window
mysafetywindow <- SafetyWindowConst(c(6, 2), 7, 7)
# Initialize the design
design <- DADesign(
model = model,
increments = myIncrements,
nextBest = myNextBest,
stopping = myStopping,
cohort_size = mySize,
data = emptydata,
safetyWindow = mysafetywindow,
startingDose = 3
)
## set up truth curves
myTruth <- probFunction(model, alpha0 = 2, alpha1 = 3)
curve(myTruth(x), from = 0, to = 100, ylim = c(0, 1))
exp_cond.cdf <- function(x, onset = 15) {
a <- pexp(28, 1 / onset, lower.tail = FALSE)
1 - (pexp(x, 1 / onset, lower.tail = FALSE) - a) / (1 - a)
}
# set up simulation settings
options <- McmcOptions(
burnin = 10,
step = 1,
samples = 200
)
mySims <- simulate(design,
args = NULL,
truthTox = myTruth,
truthSurv = exp_cond.cdf,
trueTmax = 80,
nsim = 2,
seed = 819,
mcmcOptions = options,
firstSeparate = TRUE,
deescalate = FALSE,
parallel = FALSE
)
# nolint end
Simulate outcomes from a CRM design
Description
Usage
## S4 method for signature 'Design'
simulate(
object,
nsim = 1L,
seed = NULL,
truth,
args = NULL,
firstSeparate = FALSE,
mcmcOptions = McmcOptions(),
parallel = FALSE,
nCores = min(parallel::detectCores(), 5),
derive = list(),
...
)
Arguments
object |
the |
nsim |
( |
seed |
see |
truth |
( |
args |
( |
firstSeparate |
( |
mcmcOptions |
(McmcOptions) |
parallel |
( |
nCores |
( |
derive |
( |
... |
not used |
Value
an object of class Simulations
Examples
# nolint start
# Define the dose-grid
emptydata <- Data(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Initialize the CRM model
model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Choose the rule for selecting the next dose
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size
mySize1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
mySize2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
mySize <- maxSize(mySize1, mySize2)
# Choose the rule for stopping
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
myStopping3 <- StoppingMinPatients(nPatients = 20)
myStopping <- (myStopping1 & myStopping2) | myStopping3
# Choose the rule for dose increments
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design
design <- Design(
model = model,
nextBest = myNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = emptydata,
startingDose = 3
)
## define the true function
myTruth <- probFunction(model, alpha0 = 7, alpha1 = 8)
# Run the simulation on the desired design
# We only generate 1 trial outcomes here for illustration, for the actual study
# this should be increased of course
options <- McmcOptions(
burnin = 100,
step = 1,
samples = 2000
)
time <- system.time(
mySims <- simulate(
design,
args = NULL,
truth = myTruth,
nsim = 1,
seed = 819,
mcmcOptions = options,
parallel = FALSE
)
)[3]
# nolint end
Simulate Method for the DesignGrouped Class
Description
A simulate method for DesignGrouped designs.
Usage
## S4 method for signature 'DesignGrouped'
simulate(
object,
nsim = 1L,
seed = NULL,
truth,
combo_truth,
args = data.frame(),
firstSeparate = FALSE,
mcmcOptions = McmcOptions(),
parallel = FALSE,
nCores = min(parallelly::availableCores(), 5),
...
)
Arguments
object |
( |
nsim |
( |
seed |
( |
truth |
( |
combo_truth |
( |
args |
( |
firstSeparate |
( |
mcmcOptions |
( |
parallel |
( |
nCores |
( |
... |
not used. |
Value
A list of mono and combo simulation results as Simulations objects.
Examples
# Assemble ingredients for our group design.
my_stopping <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5) |
StoppingMinPatients(10) |
StoppingMissingDose()
my_increments <- IncrementsDoseLevels(levels = 3L)
my_next_best <- NextBestNCRM(
target = c(0.2, 0.3),
overdose = c(0.3, 1),
max_overdose_prob = 0.3
)
my_cohort_size <- CohortSizeConst(3)
empty_data <- Data(
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
my_model <- LogisticLogNormalGrouped(
mean = c(-4, -4, -4, -4),
cov = diag(rep(6, 4)),
ref_dose = 0.1
)
# Put together the design. Note that if we only specify the mono arm,
# then the combo arm is having the same settings.
my_design <- DesignGrouped(
model = my_model,
mono = Design(
model = my_model,
stopping = my_stopping,
increments = my_increments,
nextBest = my_next_best,
cohort_size = my_cohort_size,
data = empty_data,
startingDose = 0.1
),
first_cohort_mono_only = TRUE,
same_dose_for_all = TRUE
)
# Set up a realistic simulation scenario.
my_truth <- function(x) plogis(-4 + 0.2 * log(x / 0.1))
my_combo_truth <- function(x) plogis(-4 + 0.5 * log(x / 0.1))
matplot(
x = empty_data@doseGrid,
y = cbind(
mono = my_truth(empty_data@doseGrid),
combo = my_combo_truth(empty_data@doseGrid)
),
type = "l",
ylab = "true DLT prob",
xlab = "dose"
)
legend("topright", c("mono", "combo"), lty = c(1, 2), col = c(1, 2))
# Start the simulations.
set.seed(123)
my_sims <- simulate(
my_design,
nsim = 1, # This should be at least 100 in actual applications.
seed = 123,
truth = my_truth,
combo_truth = my_combo_truth
)
# Looking at the summary of the simulations:
mono_sims_sum <- summary(my_sims$mono, truth = my_truth)
combo_sims_sum <- summary(my_sims$combo, truth = my_combo_truth)
mono_sims_sum
combo_sims_sum
plot(mono_sims_sum)
plot(combo_sims_sum)
# Looking at specific simulated trials:
trial_index <- 1
plot(my_sims$mono@data[[trial_index]])
plot(my_sims$combo@data[[trial_index]])
Simulate outcomes from a dual-endpoint design
Description
Usage
## S4 method for signature 'DualDesign'
simulate(
object,
nsim = 1L,
seed = NULL,
trueTox,
trueBiomarker,
args = NULL,
sigma2W,
rho = 0,
firstSeparate = FALSE,
mcmcOptions = McmcOptions(),
parallel = FALSE,
nCores = min(parallel::detectCores(), 5),
derive = list(),
...
)
Arguments
object |
the |
nsim |
( |
seed |
see |
trueTox |
( |
trueBiomarker |
( |
args |
( |
sigma2W |
( |
rho |
( |
firstSeparate |
( |
mcmcOptions |
(McmcOptions) |
parallel |
( |
nCores |
( |
derive |
( |
... |
not used |
Value
an object of class DualSimulations
Examples
# nolint start
# Define the dose-grid
emptydata <- DataDual(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Initialize the CRM model
model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
use_log_dose = TRUE,
ref_dose = 2,
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# Choose the rule for selecting the next dose
myNextBest <- NextBestDualEndpoint(
target = c(0.9, 1),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size
mySize1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
mySize2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
mySize <- maxSize(mySize1, mySize2)
# Choose the rule for stopping
myStopping4 <- StoppingTargetBiomarker(
target = c(0.9, 1),
prob = 0.5
)
myStopping <- myStopping4 | StoppingMinPatients(10)
# Choose the rule for dose increments
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design
design <- DualDesign(
model = model,
data = emptydata,
nextBest = myNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
startingDose = 3
)
# define scenarios for the TRUE toxicity and efficacy profiles
betaMod <- function(dose, e0, eMax, delta1, delta2, scal) {
maxDens <- (delta1^delta1) *
(delta2^delta2) /
((delta1 + delta2)^(delta1 + delta2))
dose <- dose / scal
e0 + eMax / maxDens * (dose^delta1) * (1 - dose)^delta2
}
trueBiomarker <- function(dose) {
betaMod(
dose,
e0 = 0.2,
eMax = 0.6,
delta1 = 5,
delta2 = 5 * 0.5 / 0.5,
scal = 100
)
}
trueTox <- function(dose) {
pnorm((dose - 60) / 10)
}
# Draw the TRUE profiles
par(mfrow = c(1, 2))
curve(trueTox(x), from = 0, to = 80)
curve(trueBiomarker(x), from = 0, to = 80)
# Run the simulation on the desired design
# We only generate 1 trial outcome here for illustration, for the actual study
# this should be increased of course, similarly for the McmcOptions -
# they also need to be increased.
mySims <- simulate(
design,
trueTox = trueTox,
trueBiomarker = trueBiomarker,
sigma2W = 0.01,
rho = 0,
nsim = 1,
parallel = FALSE,
seed = 3,
startingDose = 6,
mcmcOptions = McmcOptions(
burnin = 100,
step = 1,
samples = 300
)
)
# nolint end
Simulate dose escalation procedure using both DLE and efficacy responses without samples
Description
This is a method to simulate dose escalation procedure using both DLE and efficacy responses.
This is a method based on the DualResponsesDesign where DLE model used are of
ModelTox class object and efficacy model used are of ModelEff
class object. In addition, no DLE and efficacy samples are involved or generated in the simulation
process.
Usage
## S4 method for signature 'DualResponsesDesign'
simulate(
object,
nsim = 1L,
seed = NULL,
trueDLE,
trueEff,
trueNu,
args = NULL,
firstSeparate = FALSE,
parallel = FALSE,
nCores = min(parallel::detectCores(), 5L),
...
)
Arguments
object |
the |
nsim |
( |
seed |
see |
trueDLE |
( |
trueEff |
( |
trueNu |
( |
args |
( |
firstSeparate |
( |
parallel |
( |
nCores |
( |
... |
not used |
Value
an object of class PseudoDualSimulations
Examples
# nolint start
## Simulate dose-escalation procedure based on DLE and efficacy responses where no DLE
## and efficacy samples are used
## we need a data object with doses >= 1:
data <- DataDual(doseGrid = seq(25, 300, 25), placebo = FALSE)
## First for the DLE model
## The DLE model must be of 'ModelTox' (e.g 'LogisticIndepBeta') class
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## The efficacy model of 'ModelEff' (e.g 'Effloglog') class
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data
)
## The escalation rule using the 'NextBestMaxGain' class
mynextbest <- NextBestMaxGain(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
## The increments (see Increments class examples)
## 200% allowable increase for dose below 300 and 200% increase for dose above 300
myIncrements <- IncrementsRelative(
intervals = c(25, 300),
increments = c(2, 2)
)
## cohort size of 3
mySize <- CohortSizeConst(size = 3)
## Stop only when 36 subjects are treated
myStopping <- StoppingMinPatients(nPatients = 36)
## Now specified the design with all the above information and starting with a dose of 25
## Specified the design(for details please refer to the 'DualResponsesDesign' example)
design <- DualResponsesDesign(
nextBest = mynextbest,
model = DLEmodel,
eff_model = Effmodel,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = data,
startingDose = 25
)
## Specify the true DLE and efficacy curves
myTruthDLE <- probFunction(DLEmodel, phi1 = -53.66584, phi2 = 10.50499)
myTruthEff <- efficacyFunction(Effmodel, theta1 = -4.818429, theta2 = 3.653058)
## The true gain curve can also be seen
myTruthGain <- function(dose) {
return((myTruthEff(dose)) / (1 + (myTruthDLE(dose) / (1 - myTruthDLE(dose)))))
}
## Then specified the simulations and generate the trial
## For illustration purpose only 1 simulation is produced (nsim=1).
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
mySim <- simulate(
object = design,
args = NULL,
trueDLE = myTruthDLE,
trueEff = myTruthEff,
trueNu = 1 / 0.025,
nsim = 1,
seed = 819,
parallel = FALSE
)
# nolint end
Simulate dose escalation procedure using DLE and efficacy responses with samples
Description
This is a method to simulate dose escalation procedure using both DLE and efficacy responses.
This is a method based on the DualResponsesSamplesDesign where DLE model used are of
ModelTox class object and efficacy model used are of ModelEff
class object (special case is EffFlexi class model object).
In addition, DLE and efficacy samples are involved or generated in the simulation
process.
Usage
## S4 method for signature 'DualResponsesSamplesDesign'
simulate(
object,
nsim = 1L,
seed = NULL,
trueDLE,
trueEff,
trueNu = NULL,
trueSigma2 = NULL,
trueSigma2betaW = NULL,
args = NULL,
firstSeparate = FALSE,
mcmcOptions = McmcOptions(),
parallel = FALSE,
nCores = min(parallel::detectCores(), 5L),
...
)
Arguments
object |
the |
nsim |
( |
seed |
see |
trueDLE |
( |
trueEff |
( |
trueNu |
( |
trueSigma2 |
( |
trueSigma2betaW |
( |
args |
( |
firstSeparate |
( |
mcmcOptions |
(McmcOptions) |
parallel |
( |
nCores |
( |
... |
not used |
Value
an object of class PseudoDualSimulations or
PseudoDualFlexiSimulations
Examples
# nolint start
## Simulate dose-escalation procedure based on DLE and efficacy responses where DLE
## and efficacy samples are used
data <- DataDual(doseGrid = seq(25, 300, 25), placebo = FALSE)
## First for the DLE model
## The DLE model must be of 'ModelTox' (e.g 'LogisticIndepBeta') class
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## The efficacy model of 'ModelEff' (e.g 'Effloglog') class
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data
)
## The escalation rule using the 'NextBestMaxGainSamples' class
mynextbest <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
## The increments (see Increments class examples)
## 200% allowable increase for dose below 300 and 200% increase for dose above 300
myIncrements <- IncrementsRelative(
intervals = c(25, 300),
increments = c(2, 2)
)
## cohort size of 3
mySize <- CohortSizeConst(size = 3)
## Stop only when 10 subjects are treated (only for illustration such a low
## sample size)
myStopping <- StoppingMinPatients(nPatients = 10)
## Now specified the design with all the above information and starting with
## a dose of 25
## Specified the design
design <- DualResponsesSamplesDesign(
nextBest = mynextbest,
cohort_size = mySize,
startingDose = 25,
model = DLEmodel,
eff_model = Effmodel,
data = data,
stopping = myStopping,
increments = myIncrements
)
## specified the true DLE and efficacy curve
myTruthDLE <- probFunction(DLEmodel, phi1 = -53.66584, phi2 = 10.50499)
myTruthEff <- efficacyFunction(Effmodel, theta1 = -4.818429, theta2 = 3.653058)
## The true gain curve can also be seen
myTruthGain <- function(dose) {
return((myTruthEff(dose)) / (1 + (myTruthDLE(dose) / (1 - myTruthDLE(dose)))))
}
## simulate the trial for 10 times involving samples
## for illustration purpose we use 10 burn-ins to generate 50 samples
options <- McmcOptions(burnin = 10, step = 1, samples = 50)
## For illustration purpose only 1 simulations are produced (nsim=1).
mySim <- simulate(
design,
args = NULL,
trueDLE = myTruthDLE,
trueEff = myTruthEff,
trueNu = 1 / 0.025,
nsim = 1,
mcmcOptions = options,
seed = 819,
parallel = FALSE
)
## Simulate dose-escalation procedure based on DLE and efficacy responses where DLE
## and efficacy samples are used
## when the efficacy model is of 'EffFlexi' class
Effmodel <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = data
)
## Specified the design
design <- DualResponsesSamplesDesign(
nextBest = mynextbest,
cohort_size = mySize,
startingDose = 25,
model = DLEmodel,
eff_model = Effmodel,
data = data,
stopping = myStopping,
increments = myIncrements
)
## specified the true DLE curve and the true expected efficacy values at all dose levels
myTruthDLE <- probFunction(DLEmodel, phi1 = -53.66584, phi2 = 10.50499)
myTruthEff <- c(
-0.5478867,
0.1645417,
0.5248031,
0.7604467,
0.9333009,
1.0687031,
1.1793942,
1.2726408,
1.3529598,
1.4233411,
1.4858613,
1.5420182
)
## The true gain curve can also be seen
d1 <- data@doseGrid
myTruthGain <- (myTruthEff) / (1 + (myTruthDLE(d1) / (1 - myTruthDLE(d1))))
mySim <- simulate(
object = design,
args = NULL,
trueDLE = myTruthDLE,
trueEff = myTruthEff,
trueSigma2 = 0.025,
trueSigma2betaW = 1,
mcmcOptions = options,
nsim = 1,
seed = 819,
parallel = FALSE
)
# nolint end
Simulate outcomes from a rule-based design
Description
Usage
## S4 method for signature 'RuleDesign'
simulate(
object,
nsim = 1L,
seed = NULL,
truth,
args = NULL,
parallel = FALSE,
nCores = min(parallel::detectCores(), 5L),
...
)
Arguments
object |
the |
nsim |
( |
seed |
see |
truth |
( |
args |
( |
parallel |
( |
nCores |
( |
... |
not used |
Value
an object of class GeneralSimulations
Examples
# nolint start
# Define the dose-grid
emptydata <- Data(doseGrid = c(5, 10, 15, 25, 35, 50, 80))
# inizialing a 3+3 design with constant cohort size of 3 and
# starting dose equal 5
myDesign <- RuleDesign(
nextBest = NextBestThreePlusThree(),
cohort_size = CohortSizeConst(size = 3L),
data = emptydata,
startingDose = 5
)
model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 50
)
## define the true function
myTruth <- probFunction(model, alpha0 = 7, alpha1 = 8)
# Perform the simulation
## For illustration purpose only 10 simulation is produced (nsim=10).
threeSims <- simulate(
myDesign,
nsim = 10,
seed = 35,
truth = myTruth,
parallel = FALSE
)
# nolint end
Simulate dose escalation procedure using DLE responses only without samples
Description
This is a method to simulate dose escalation procedure only using the DLE responses.
This is a method based on the TDDesign where model used are of
ModelTox class object and no samples are involved.
Usage
## S4 method for signature 'TDDesign'
simulate(
object,
nsim = 1L,
seed = NULL,
truth,
args = NULL,
firstSeparate = FALSE,
parallel = FALSE,
nCores = min(parallel::detectCores(), 5L),
...
)
Arguments
object |
the |
nsim |
( |
seed |
see |
truth |
( |
args |
( |
firstSeparate |
( |
parallel |
( |
nCores |
( |
... |
not used |
Value
an object of class PseudoSimulations
Examples
# nolint start
## Simulate dose-escalation procedure based only on DLE responses and no DLE samples are used
## The design comprises a model, the escalation rule, starting data,
## a cohort size and a starting dose
## Define your data set first using an empty data set
## with dose levels from 25 to 300 with increments 25
data <- Data(doseGrid = seq(25, 300, 25))
## The design only incorporate DLE responses and DLE samples are involved
## Specified the model of 'ModelTox' class eg 'LogisticIndepBeta' class model
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## Then the escalation rule
tdNextBest <- NextBestTD(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
doseRecommendation <- nextBest(
tdNextBest,
doselimit = max(data@doseGrid),
model = model,
data = data
)
## Then the starting data, an empty data set
emptydata <- Data(doseGrid = seq(25, 300, 25))
## The cohort size, size of 3 subjects
mySize <- CohortSizeConst(size = 3)
## Deifne the increments for the dose-escalation process
## The maximum increase of 200% for doses up to the maximum of the dose specified in the doseGrid
## The maximum increase of 200% for dose above the maximum of the dose specified in the doseGrid
## This is to specified a maximum of 3-fold restriction in dose-esclation
myIncrements <- IncrementsRelative(
intervals = c(min(data@doseGrid), max(data@doseGrid)),
increments = c(2, 2)
)
## Specified the stopping rule e.g stop when the maximum sample size of 36 patients has been reached
myStopping <- StoppingMinPatients(nPatients = 36)
## Specified the design(for details please refer to the 'TDDesign' example)
design <- TDDesign(
model = model,
nextBest = tdNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = data,
startingDose = 25
)
## Specify the truth of the DLE responses
myTruth <- probFunction(model, phi1 = -53.66584, phi2 = 10.50499)
## then plot the truth to see how the truth dose-DLE curve look like
curve(myTruth(x), from = 0, to = 300, ylim = c(0, 1))
## For illustration purpose only 1 simulation is produced (nsim=1).
mySim <- simulate(
object = design,
args = NULL,
truth = myTruth,
nsim = 1,
seed = 819,
parallel = FALSE
)
# nolint end
Simulate dose escalation procedure using DLE responses only with DLE samples
Description
This is a method to simulate dose escalation procedure only using the DLE responses.
This is a method based on the TDsamplesDesign where model used are of
ModelTox class object DLE samples are also used.
Usage
## S4 method for signature 'TDsamplesDesign'
simulate(
object,
nsim = 1L,
seed = NULL,
truth,
args = NULL,
firstSeparate = FALSE,
mcmcOptions = McmcOptions(),
parallel = FALSE,
nCores = min(parallel::detectCores(), 5L),
...
)
Arguments
object |
the |
nsim |
( |
seed |
see |
truth |
( |
args |
( |
firstSeparate |
( |
mcmcOptions |
(McmcOptions) |
parallel |
( |
nCores |
( |
... |
not used |
Value
an object of class PseudoSimulations
Examples
# nolint start
## Simulate dose-escalation procedure based only on DLE responses with DLE samples involved
## The design comprises a model, the escalation rule, starting data,
## a cohort size and a starting dose
## Define your data set first using an empty data set
## with dose levels from 25 to 300 with increments 25
data <- Data(doseGrid = seq(25, 300, 25))
## The design only incorporate DLE responses and DLE samples are involved
## Specified the model of 'ModelTox' class eg 'LogisticIndepBeta' class model
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## Then the escalation rule
tdNextBest <- NextBestTDsamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, probs = 0.3))
}
)
## The cohort size, size of 3 subjects
mySize <- CohortSizeConst(size = 3)
## Deifne the increments for the dose-escalation process
## The maximum increase of 200% for doses up to the maximum of the dose specified in the doseGrid
## The maximum increase of 200% for dose above the maximum of the dose specified in the doseGrid
## This is to specified a maximum of 3-fold restriction in dose-esclation
myIncrements <- IncrementsRelative(
intervals = c(min(data@doseGrid), max(data@doseGrid)),
increments = c(2, 2)
)
## Specified the stopping rule e.g stop when the maximum sample size of 36 patients has been reached
myStopping <- StoppingMinPatients(nPatients = 36)
## Specified the design(for details please refer to the 'TDsamplesDesign' example)
design <- TDsamplesDesign(
model = model,
nextBest = tdNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = data,
startingDose = 25
)
## Specify the truth of the DLE responses
myTruth <- probFunction(model, phi1 = -53.66584, phi2 = 10.50499)
## then plot the truth to see how the truth dose-DLE curve look like
curve(myTruth(x), from = 0, to = 300, ylim = c(0, 1))
## Then specified the simulations and generate the trial
## options for MCMC
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
## The simulations
## For illustration purpose only 1 simulation is produced (nsim=1).
mySim <- simulate(
object = design,
args = NULL,
truth = myTruth,
nsim = 1,
seed = 819,
mcmcOptions = options,
parallel = FALSE
)
# nolint end
Size of an Object
Description
A method that computes the size of a given object. This can be for instance a size of a MCMC sample, or the size of a cohort. See the help of a specific method for more details.
Usage
size(object, ...)
## S4 method for signature 'McmcOptions'
size(object, ...)
## S4 method for signature 'CohortSizeRange'
size(object, dose, data)
## S4 method for signature 'CohortSizeDLT'
size(object, dose, data)
## S4 method for signature 'CohortSizeMax'
size(object, dose, data)
## S4 method for signature 'CohortSizeMin'
size(object, dose, data)
## S4 method for signature 'CohortSizeConst'
size(object, dose, ...)
## S4 method for signature 'CohortSizeParts'
size(object, dose, data)
## S4 method for signature 'CohortSizeOrdinal'
size(object, dose, data, ...)
## S4 method for signature 'Samples'
size(object, ...)
Arguments
object |
( |
... |
not used. |
dose |
( |
data |
the data input, an object of class |
Value
A size of a given object.
Functions
-
size(McmcOptions): compute the number of MCMC samples based onMcmcOptionsobject. -
size(CohortSizeRange): Determines the size of the next cohort based on the range into which the next dose falls into. -
size(CohortSizeDLT): Determines the size of the next cohort based on the number of DLTs so far. -
size(CohortSizeMax): Determines the size of the next cohort based on maximum of multiple cohort size rules. -
size(CohortSizeMin): Determines the size of the next cohort based on minimum of multiple cohort size rules. -
size(CohortSizeConst): Constant cohort size. -
size(CohortSizeParts): Determines the size of the next cohort based on the parts. -
size(CohortSizeOrdinal): Determines the size of the next cohort in a ordinal CRM trial. -
size(Samples): get the number of MCMC samples fromSamplesobject.
Examples
# Set up the MCMC option in order to have a burn-in of 10000 iterations and
# then take every other iteration up to a collection of 10000 samples.
my_options <- McmcOptions(burnin = 10000, step = 2, samples = 10000)
size(my_options)
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Rule for the cohort size:
# - having cohort of size 1 for doses <10
# - and having cohort of size 3 for doses >=10
mySize <- CohortSizeRange(intervals = c(0, 10), cohort_size = c(1, 3))
# Determine the cohort size for the next cohort
size(mySize, dose = doseRecommendation$value, data = data)
# nolint end
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(
burnin = 100,
step = 2,
samples = 2000
)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Rule for the cohort size:
# - having cohort of size 1 if no DLTs were yet observed
# - and having cohort of size 3 if at least 1 DLT was already observed
mySize <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
# Determine the cohort size for the next cohort
size(mySize, dose = doseRecommendation$value, data = data)
# nolint end
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(
burnin = 100,
step = 2,
samples = 2000
)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Rule for having cohort of size 1 for doses <30
# and having cohort of size 3 for doses >=30
mySize1 <- CohortSizeRange(
intervals = c(0, 10),
cohort_size = c(1, 3)
)
# Rule for having cohort of size 1 until no DLT were observed
# and having cohort of size 3 as soon as 1 DLT is observed
mySize2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
# Combining the two rules for cohort size by taking the maximum of the sample sizes
# of the single rules
mySize <- maxSize(mySize1, mySize2)
# Determine the cohort size for the next cohort
size(mySize, dose = doseRecommendation$value, data = data)
# nolint end
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(
burnin = 100,
step = 2,
samples = 2000
)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Rule for having cohort of size 1 for doses <30
# and having cohort of size 3 for doses >=30
mySize1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
# Rule for having cohort of size 1 until no DLT were observed
# and having cohort of size 3 as soon as 1 DLT is observed
mySize2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
# Combining the two rules for cohort size by taking the minimum of the sample sizes
# of the single rules
mySize <- minSize(mySize1, mySize2)
# Determine the cohort size for the next cohort
size(mySize, dose = doseRecommendation$value, data = data)
# nolint end
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Rule for having cohorts with constant cohort size of 3
mySize <- CohortSizeConst(size = 3)
# Determine the cohort size for the next cohort
size(mySize, dose = doseRecommendation$value)
# nolint end
# nolint start
# create an object of class 'DataParts'
data <- DataParts(
x = c(0.1, 0.5, 1.5),
y = c(0, 0, 0),
doseGrid = c(
0.1,
0.5,
1.5,
3,
6,
seq(from = 10, to = 80, by = 2)
),
part = c(1L, 1L, 1L),
nextPart = 1L,
part1Ladder = c(0.1, 0.5, 1.5, 3, 6, 10)
)
# Initialize the CRM model used to model the data
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
options <- McmcOptions(
burnin = 100,
step = 2,
samples = 2000
)
set.seed(94)
samples <- mcmc(data, model, options)
myIncrements <- IncrementsRelativeParts(
dlt_start = 0,
clean_start = 1
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Rule for the cohort size:
mySize <- CohortSizeParts(cohort_sizes = c(1, 3))
# Determine the cohort size for the next cohort
size(mySize, dose = doseRecommendation$value, data = data)
# nolint end
CohortSizeOrdinal(
grade = 1L,
rule = CohortSizeRange(intervals = c(0L, 30L), cohort_size = c(1L, 3L))
)
# Set up the MCMC option in order to have a burn-in of 100 iterations and
# then take every other iteration up to a collection of 200 samples.
my_options <- McmcOptions(burnin = 100, step = 2, samples = 200)
my_samples <- Samples(
data = list(alpha = rnorm(200), beta = rnorm(200)),
options = my_options
)
size(my_samples)
Stop the trial?
Description
This function returns whether to stop the trial.
Stopping rule based precision of the MTD estimation.
The trial is stopped, when the MTD can be estimated with sufficient precision.
The criteria is based on the robust coefficient of variation (CV) calculated
from the posterior distribution.
The robust CV is defined mad(MTD) / median(MTD), where mad is the median
absolute deviation.
Stopping based based on the lowest non placebo dose. The trial is stopped when the lowest non placebo dose meets the Hard Safety Rule, i.e. it is deemed to be overly toxic. Stopping is based on the observed data at the lowest dose level using a Bin-Beta model based on DLT probability.
Usage
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingMissingDose,numeric,ANY,ANY,Data'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingList,ANY,ANY,ANY,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingAll,ANY,ANY,ANY,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingAny,ANY,ANY,ANY,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingCohortsNearDose,numeric,ANY,ANY,Data'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingPatientsNearDose,numeric,ANY,ANY,Data'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingMinCohorts,ANY,ANY,ANY,Data'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingMinPatients,ANY,ANY,ANY,Data'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature
## 'StoppingTargetProb,numeric,Samples,GeneralModel,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature
## 'StoppingMTDdistribution,numeric,Samples,GeneralModel,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingMTDCV,numeric,Samples,GeneralModel,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingLowestDoseHSRBeta,numeric,Samples,ANY,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature
## 'StoppingTargetBiomarker,numeric,Samples,DualEndpoint,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingSpecificDose,numeric,ANY,ANY,Data'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingHighestDose,numeric,ANY,ANY,Data'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature
## 'StoppingOrdinal,numeric,ANY,LogisticLogNormalOrdinal,DataOrdinal'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingOrdinal,numeric,ANY,ANY,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingExternal,numeric,ANY,ANY,ANY'
stopTrial(stopping, dose, samples, model, data, external, ...)
## S4 method for signature 'StoppingTDCIRatio,ANY,Samples,ModelTox,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature 'StoppingTDCIRatio,ANY,missing,ModelTox,ANY'
stopTrial(stopping, dose, samples, model, data, ...)
## S4 method for signature
## 'StoppingMaxGainCIRatio,ANY,Samples,ModelTox,DataDual'
stopTrial(
stopping,
dose,
samples,
model,
data,
TDderive,
Effmodel,
Effsamples,
Gstarderive,
...
)
## S4 method for signature
## 'StoppingMaxGainCIRatio,ANY,missing,ModelTox,DataDual'
stopTrial(stopping, dose, model, data, Effmodel, ...)
Arguments
stopping |
( |
dose |
the recommended next best dose. |
samples |
( |
model |
( |
data |
( |
... |
additional arguments without method dispatch. |
external |
( |
TDderive |
( |
Effmodel |
( |
Effsamples |
( |
Gstarderive |
( |
Value
logical value: TRUE if the trial can be stopped, FALSE
otherwise. It should have an attribute message which gives the reason
for the decision.
Functions
-
stopTrial( stopping = StoppingMissingDose, dose = numeric, samples = ANY, model = ANY, data = Data ): Stop based on value returned by next best dose. -
stopTrial( stopping = StoppingList, dose = ANY, samples = ANY, model = ANY, data = ANY ): Stop based on multiple stopping rules. -
stopTrial( stopping = StoppingAll, dose = ANY, samples = ANY, model = ANY, data = ANY ): Stop based on fulfillment of all multiple stopping rules. -
stopTrial( stopping = StoppingAny, dose = ANY, samples = ANY, model = ANY, data = ANY ): Stop based on fulfillment of any stopping rule. -
stopTrial( stopping = StoppingCohortsNearDose, dose = numeric, samples = ANY, model = ANY, data = Data ): Stop based on number of cohorts near to next best dose. -
stopTrial( stopping = StoppingPatientsNearDose, dose = numeric, samples = ANY, model = ANY, data = Data ): Stop based on number of patients near to next best dose. -
stopTrial( stopping = StoppingMinCohorts, dose = ANY, samples = ANY, model = ANY, data = Data ): Stop based on minimum number of cohorts. -
stopTrial( stopping = StoppingMinPatients, dose = ANY, samples = ANY, model = ANY, data = Data ): Stop based on minimum number of patients. -
stopTrial( stopping = StoppingTargetProb, dose = numeric, samples = Samples, model = GeneralModel, data = ANY ): Stop based on probability of target tox interval -
stopTrial( stopping = StoppingMTDdistribution, dose = numeric, samples = Samples, model = GeneralModel, data = ANY ): Stop based on MTD distribution. -
stopTrial( stopping = StoppingTargetBiomarker, dose = numeric, samples = Samples, model = DualEndpoint, data = ANY ): Stop based on probability of targeting biomarker -
stopTrial( stopping = StoppingSpecificDose, dose = numeric, samples = ANY, model = ANY, data = Data ): if Stopping rule is met for specific dose of the planned dose grid and not just for the default next best dose. -
stopTrial( stopping = StoppingHighestDose, dose = numeric, samples = ANY, model = ANY, data = Data ): Stop when the highest dose is reached. -
stopTrial( stopping = StoppingOrdinal, dose = numeric, samples = ANY, model = LogisticLogNormalOrdinal, data = DataOrdinal ): Stop based on value returned by next best dose. -
stopTrial( stopping = StoppingOrdinal, dose = numeric, samples = ANY, model = ANY, data = ANY ): Stop based on value returned by next best dose. -
stopTrial( stopping = StoppingExternal, dose = numeric, samples = ANY, model = ANY, data = ANY ): Stop based on an external flag. -
stopTrial( stopping = StoppingTDCIRatio, dose = ANY, samples = Samples, model = ModelTox, data = ANY ): Stop based onStoppingTDCIRatioclass when reaching the target ratio of the upper to the lower 95% credibility interval of the estimate (TDtargetEndOfTrial). This is a stopping rule which incorporates only DLE responses and DLE samples are given. -
stopTrial( stopping = StoppingTDCIRatio, dose = ANY, samples = missing, model = ModelTox, data = ANY ): Stop based onStoppingTDCIRatioclass when reaching the target ratio of the upper to the lower 95% credibility interval of the estimate (TDtargetEndOfTrial). This is a stopping rule which incorporates only DLE responses and no DLE samples are involved. -
stopTrial( stopping = StoppingMaxGainCIRatio, dose = ANY, samples = Samples, model = ModelTox, data = DataDual ): Stop based on reaching the target ratio of the upper to the lower 95% credibility interval of the estimate (the minimum of Gstar and TDtargetEndOfTrial). This is a stopping rule which incorporates DLE and efficacy responses and DLE and efficacy samples are also used. -
stopTrial( stopping = StoppingMaxGainCIRatio, dose = ANY, samples = missing, model = ModelTox, data = DataDual ): Stop based on reaching the target ratio of the upper to the lower 95% credibility interval of the estimate (the minimum of Gstar and TDtargetEndOfTrial). This is a stopping rule which incorporates DLE and efficacy responses without DLE and efficacy samples involved.
Examples
## Example of combining stopping rules with '&' and/or '|' operators
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
myStopping3 <- StoppingMinPatients(nPatients = 20)
myStopping <- (myStopping1 & myStopping2) | myStopping3
# Example of usage for `StoppingMissingDose` StopTrial class.
# Create the data.
my_data <- Data(
x = c(0.01, 0.1, 0.5, 3, 6, 10, 10, 10),
y = c(0, 1, 1, 0, 0, 0, 0, 1),
cohort = c(1, 1, 2, 3, 4, 5, 5, 5),
ID = 1:8,
doseGrid = c(
0.01,
0.1,
0.5,
1.5,
3,
6,
seq(from = 10, to = 80, by = 2)
),
placebo = TRUE
)
# 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 = 2000
)
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 'NextBestNCRM'.
my_next_best <- NextBestNCRM(
target = c(0.1, 0.25),
overdose = c(0.2, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose.
dose_recommendation <- nextBest(
my_next_best,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
# Define the stopping rule such that the study would be stopped if there is
# no safe active dose returned from dose_recommendation.
my_stopping <- StoppingMissingDose()
my_stopping <- StoppingAny(
stop_list = c(
StoppingMinPatients(nPatients = 16),
StoppingMissingDose()
)
)
# Evaluate if to stop the trial.
stopTrial(
stopping = my_stopping,
dose = dose_recommendation$value,
data = my_data,
model = my_model
)
# nolint start
# Create some data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rules
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
myStopping3 <- StoppingMinPatients(nPatients = 20)
# Create a list of stopping rules (of class 'StoppingList') which will then be
# summarized (in this specific example) with the 'any' function, meaning that the study
# would be stopped if 'any' of the single stopping rules is TRUE.
mystopping <- StoppingList(
stop_list = c(myStopping1, myStopping2, myStopping3),
summary = any
)
# Evaluate if to stop the Trial
stopTrial(
stopping = myStopping,
dose = doseRecommendation$value,
samples = samples,
model = model,
data = data
)
# nolint end
# nolint start
# Create some data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rules
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
myStopping3 <- StoppingMinPatients(nPatients = 20)
# Combine the stopping rules, obtaining (in this specific example) a list of stopping
# rules of class 'StoppingAll'
myStopping <- (myStopping1 | myStopping2) & myStopping3
# Evaluate if to stop the Trial
stopTrial(
stopping = myStopping,
dose = doseRecommendation$value,
samples = samples,
model = model,
data = data
)
# nolint end
# nolint start
# Create some data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rules
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
myStopping3 <- StoppingMinPatients(nPatients = 20)
# Combine the stopping rules, obtaining (in this specific example) a list of stopping
# rules of class 'StoppingAny'
myStopping <- (myStopping1 | myStopping2) | myStopping3
# Evaluate if to stop the Trial
stopTrial(
stopping = myStopping,
dose = doseRecommendation$value,
samples = samples,
model = model,
data = data
)
# nolint end
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rule such that the study would be stopped if at least 3
# cohorts were already dosed within 1 +/- 0.2 of the next best dose
myStopping <- StoppingCohortsNearDose(nCohorts = 3, percentage = 0.2)
# Evaluate if to stop the trial
stopTrial(stopping = myStopping, dose = doseRecommendation$value, data = data)
# nolint end
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rule such that the study would be stopped if at least 9
# patients were already dosed within 1 +/- 0.2 of the next best dose
myStopping <- StoppingPatientsNearDose(nPatients = 9, percentage = 0.2)
# Evaluate if to stop the trial
stopTrial(stopping = myStopping, dose = doseRecommendation$value, data = data)
# nolint end
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rule such that the study would be stopped if at least 6
# cohorts were already dosed
myStopping <- StoppingMinCohorts(nCohorts = 6)
# Evaluate if to stop the trial
stopTrial(stopping = myStopping, dose = doseRecommendation$value, data = data)
# nolint end
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rule such that the study would be stopped if at least 20
# patients were already dosed
myStopping <- StoppingMinPatients(nPatients = 20)
# Evaluate if to stop the trial
stopTrial(stopping = myStopping, dose = doseRecommendation$value, data = data)
# nolint end
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rule such that the study would be stopped if there is at least
# 0.5 posterior probability that [0.2 =< Prob(DLT | next-best-dose) <= 0.35]
myStopping <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
# Evaluate if to stop the trial
stopTrial(
stopping = myStopping,
dose = doseRecommendation$value,
samples = samples,
model = model,
data = data
)
# nolint end
# nolint start
# Create the data
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),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rule such that the study would be stopped if there is at least
# 0.9 probability that MTD > 0.5*next_best_dose. Here MTD is defined as the dose for
# which prob(DLE)=0.33
myStopping <- StoppingMTDdistribution(target = 0.33, thresh = 0.5, prob = 0.9)
# Evaluate if to stop the trial
stopTrial(
stopping = myStopping,
dose = doseRecommendation$value,
samples = samples,
model = model,
data = data
)
# nolint end
# 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),
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 = 2000,
rng_kind = "Mersenne-Twister",
rng_seed = 94
)
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 'NextBestNCRM'.
my_next_best <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose.
dose_recommendation <- nextBest(
my_next_best,
doselimit = next_max_dose,
samples = my_samples,
model = my_model,
data = my_data
)
# Define the stopping rule such that the study would be stopped if the
# the MTD can be estimated with sufficient precision, i.e. if robust coefficient
# of variation is below 40%.
my_stopping <- StoppingMTDCV(target = 0.3, thresh_cv = 40)
# Evaluate if to stop the trial.
stopTrial(
stopping = my_stopping,
dose = dose_recommendation$value,
samples = my_samples,
model = my_model,
data = my_data
)
# Create the data.
data <- Data(
x = c(0.1, 0.1, 0.1),
y = c(0, 0, 1),
cohort = c(1, 1, 1),
doseGrid = c(
0.1,
0.5,
1.5,
3,
6,
seq(from = 10, to = 80, by = 2)
),
ID = 1:3
)
# Initialize the CRM model used to model the data.
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.
options <- McmcOptions(
burnin = 100,
step = 2,
samples = 2000
)
set.seed(94)
samples <- mcmc(data, model, 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 = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'.
my_next_best <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose.
dose_recommendation <- nextBest(
my_next_best,
doselimit = next_max_dose,
samples = samples,
model = model,
data = data
)
# Define the stopping rule such that the study would be stopped if first dose
# is toxic based on a Beta posterior distribution with Beta(1,1) prior.
my_stopping <- StoppingLowestDoseHSRBeta(
target = 0.3,
prob = 0.9
)
# Evaluate if the trial will be stopped.
stopTrial(
stopping = my_stopping,
dose = dose_recommendation$value,
samples = samples,
model = model,
data = data
)
# nolint start
# Create the data
data <- DataDual(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10, 20, 20, 20, 40, 40, 40, 50, 50, 50),
y = c(0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1),
w = c(
0.31,
0.42,
0.59,
0.45,
0.6,
0.7,
0.55,
0.6,
0.52,
0.54,
0.56,
0.43,
0.41,
0.39,
0.34,
0.38,
0.21
),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Initialize the Dual-Endpoint model (in this case RW1)
model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# Set-up some MCMC parameters and generate samples from the posterior
options <- McmcOptions(burnin = 100, step = 2, samples = 500)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# In this case target a dose achieving at least 0.9 of maximum biomarker level (efficacy)
# and with a probability below 0.25 that prob(DLT)>0.35 (safety)
myNextBest <- NextBestDualEndpoint(
target = c(0.9, 1),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rule such that the study would be stopped if if there is at
# least 0.5 posterior probability that the biomarker (efficacy) is within the
# biomarker target range of [0.9, 1.0] (relative to the maximum for the biomarker).
myStopping <- StoppingTargetBiomarker(target = c(0.9, 1), prob = 0.5)
# Evaluate if to stop the trial
stopTrial(
stopping = myStopping,
dose = doseRecommendation$value,
samples = samples,
model = model,
data = data
)
# nolint end
# Create some 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 = 50
)
# 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 which will be used to select the next best dose
# based on the class 'NextBestNCRM'.
my_nb_ncrm <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose.
my_dose_recommendation <- nextBest(
nextBest = my_nb_ncrm,
doselimit = 100,
samples = my_samples,
model = my_model,
data = my_data
)
# Define the stopping rules.
highest_dose_safe <- StoppingSpecificDose(
rule = StoppingTargetProb(target = c(0, 0.3), prob = 0.8),
dose = 80
)
max_patients <- StoppingMinPatients(nPatients = 20)
patients_near_dose <- StoppingPatientsNearDose(nPatients = 3, percentage = 0)
# Create a list of stopping rules (of class 'StoppingList') which will then be
# summarized (in this specific example) with the 'any' function, meaning that
# the study would be stopped if 'any' of the single stopping rules is TRUE.
my_stopping <- highest_dose_safe | max_patients | patients_near_dose
# Evaluate if to stop the Trial
stopTrial(
stopping = my_stopping,
dose = doseRecommendation$value,
samples = samples,
model = model,
data = data
)
# nolint start
# Create the data
data <- Data(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10, 20, 20, 20, 40, 40, 40, 80, 80, 80),
y = c(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
cohort = c(0, 1, 2, 3, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8),
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
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
options <- McmcOptions(burnin = 100, step = 2, samples = 2000)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the stopping rule such that the study would be stopped if there is at least
# 0.5 posterior probability that [0.2 =< Prob(DLT | next-best-dose) <= 0.35]
stopTarget <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5)
## now use the StoppingHighestDose rule:
stopHigh <-
StoppingHighestDose() &
StoppingPatientsNearDose(nPatients = 3, percentage = 0) &
StoppingTargetProb(target = c(0, 0.2), prob = 0.5)
## and combine everything:
myStopping <- stopTarget | stopHigh
# Then evaluate if to stop the trial
stopTrial(
stopping = myStopping,
dose = doseRecommendation$value,
samples = samples,
model = model,
data = data
)
# nolint end
data <- .DefaultDataOrdinal()
model <- .DefaultLogisticLogNormalOrdinal()
options <- .DefaultMcmcOptions()
samples <- mcmc(data, model, options)
myIncrements <- .DefaultIncrementsOrdinal()
nextMaxDose <- maxDose(myIncrements, data = data)
myNextBest <- .DefaultNextBestOrdinal()
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
myStopping <- .DefaultStoppingOrdinal()
stopTrial(
stopping = myStopping,
dose = doseRecommendation$value,
samples = samples,
model = model,
data = data
)
data <- .DefaultDataOrdinal()
model <- .DefaultLogisticLogNormalOrdinal()
options <- .DefaultMcmcOptions()
samples <- mcmc(data, model, options)
myIncrements <- .DefaultIncrementsOrdinal()
nextMaxDose <- maxDose(myIncrements, data = data)
myNextBest <- .DefaultNextBestOrdinal()
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
myStopping <- .DefaultStoppingOrdinal()
stopTrial(
stopping = myStopping,
dose = doseRecommendation$value,
samples = samples,
model = model,
data = data
)
my_rule <- StoppingExternal(report_label = "Based on combo stop")
stopTrial(
my_rule,
5,
.DefaultSamples(),
.DefaultModelLogNormal(),
.DefaultData(),
external = TRUE
)
# nolint start
##define the stopping rules based on the 'StoppingTDCIRatio' class
##Using only DLE responses with samples
## we need a data object with doses >= 1:
data <- Data(
x = c(25, 50, 50, 75, 150, 200, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
doseGrid = seq(from = 25, to = 300, by = 25)
)
##model can be specified of 'Model' or 'ModelTox' class
##For example, the 'logisticIndepBeta' class model
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
##define MCMC options
##for illustration purpose we use 10 burn-in and generate 50 samples
options <- McmcOptions(burnin = 10, step = 2, samples = 50)
##samples of 'Samples' class
samples <- mcmc(data, model, options)
##define the 'StoppingTDCIRatio' class
myStopping <- StoppingTDCIRatio(target_ratio = 5, prob_target = 0.3)
##Find the next Recommend dose using the nextBest method (plesae refer to nextbest examples)
tdNextBest <- NextBestTDsamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, probs = 0.3))
}
)
RecommendDose <- nextBest(
tdNextBest,
doselimit = max(data@doseGrid),
samples = samples,
model = model,
data = data
)
##use 'stopTrial' to determine if the rule has been fulfilled
##use 0.3 as the target proability of DLE at the end of the trial
stopTrial(
stopping = myStopping,
dose = RecommendDose$next_dose_drt,
samples = samples,
model = model,
data = data
)
# nolint end
# nolint start
##define the stopping rules based on the 'StoppingTDCIRatio' class
##Using only DLE responses
## we need a data object with doses >= 1:
data <- Data(
x = c(25, 50, 50, 75, 150, 200, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
doseGrid = seq(from = 25, to = 300, by = 25)
)
##model must be of 'ModelTox' class
##For example, the 'logisticIndepBeta' class model
model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
##define the 'StoppingTDCIRatio' class
myStopping <- StoppingTDCIRatio(target_ratio = 5, prob_target = 0.3)
##Find the next Recommend dose using the nextBest method (plesae refer to nextbest examples)
tdNextBest <- NextBestTD(prob_target_drt = 0.35, prob_target_eot = 0.3)
RecommendDose <- nextBest(
tdNextBest,
doselimit = max(data@doseGrid),
model = model,
data = data
)
##use 'stopTrial' to determine if the rule has been fulfilled
##use 0.3 as the target proability of DLE at the end of the trial
stopTrial(
stopping = myStopping,
dose = RecommendDose$next_dose_drt,
model = model,
data = data
)
# nolint end
# nolint start
##define the stopping rules based on the 'StoppingMaxGainCIRatio' class
##Using both DLE and efficacy responses
## we need a data object with doses >= 1:
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
##DLEmodel must be of 'ModelTox' class
##For example, the 'logisticIndepBeta' class model
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
##Effmodel must be of 'ModelEff' class
##For example, the 'Effloglog' class model
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data
)
##for illustration purpose we use 10 burn-in and generate 50 samples
options <- McmcOptions(burnin = 10, step = 2, samples = 50)
##DLE and efficacy samples must be of 'Samples' class
DLEsamples <- mcmc(data, DLEmodel, options)
Effsamples <- mcmc(data, Effmodel, options)
##define the 'StoppingMaxGainCIRatio' class
myStopping <- StoppingMaxGainCIRatio(target_ratio = 5, prob_target = 0.3)
##Find the next Recommend dose using the nextBest method (plesae refer to nextbest examples)
mynextbest <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
RecommendDose <- nextBest(
mynextbest,
doselimit = max(data@doseGrid),
samples = DLEsamples,
model = DLEmodel,
data = data,
model_eff = Effmodel,
samples_eff = Effsamples
)
##use 'stopTrial' to determine if the rule has been fulfilled
##use 0.3 as the target proability of DLE at the end of the trial
stopTrial(
stopping = myStopping,
dose = RecommendDose$next_dose,
samples = DLEsamples,
model = DLEmodel,
data = data,
TDderive = function(TDsamples) {
quantile(TDsamples, prob = 0.3)
},
Effmodel = Effmodel,
Effsamples = Effsamples,
Gstarderive = function(Gstarsamples) {
quantile(Gstarsamples, prob = 0.5)
}
)
# nolint end
# nolint start
##define the stopping rules based on the 'StoppingMaxGainCIRatio' class
##Using both DLE and efficacy responses
## we need a data object with doses >= 1:
data <- DataDual(
x = c(25, 50, 25, 50, 75, 300, 250, 150),
y = c(0, 0, 0, 0, 0, 1, 1, 0),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
doseGrid = seq(25, 300, 25),
placebo = FALSE
)
##DLEmodel must be of 'ModelTox' class
##For example, the 'logisticIndepBeta' class model
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
##Effmodel must be of 'ModelEff' class
##For example, the 'Effloglog' class model
Effmodel <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = data
)
##define the 'StoppingMaxGainCIRatio' class
myStopping <- StoppingMaxGainCIRatio(target_ratio = 5, prob_target = 0.3)
##Find the next Recommend dose using the nextBest method (plesae refer to nextbest examples)
mynextbest <- NextBestMaxGain(prob_target_drt = 0.35, prob_target_eot = 0.3)
RecommendDose <- nextBest(
mynextbest,
doselimit = max(data@doseGrid),
model = DLEmodel,
model_eff = Effmodel,
data = data
)
##use 'stopTrial' to determine if the rule has been fulfilled
##use 0.3 as the target proability of DLE at the end of the trial
stopTrial(
stopping = myStopping,
dose = RecommendDose$next_dose,
model = DLEmodel,
data = data,
Effmodel = Effmodel
)
# nolint end
Summarize Dual-Endpoint Design Simulations
Description
Summarize the dual-endpoint design simulations, relative to given true dose-toxicity and dose-biomarker curves.
Usage
## S4 method for signature 'DualSimulations'
summary(object, trueTox, trueBiomarker, target = c(0.2, 0.35), ...)
Arguments
object |
( |
trueTox |
( |
trueBiomarker |
( |
target |
( |
... |
additional arguments can be supplied here for |
Value
An object of class DualSimulationsSummary.
Examples
# Define the dose-grid.
emptydata <- DataDual(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Initialize the CRM model.
my_model <- DualEndpointRW(
mean = c(0, 1),
cov = matrix(c(1, 0, 0, 1), nrow = 2),
sigma2betaW = 0.01,
sigma2W = c(a = 0.1, b = 0.1),
rho = c(a = 1, b = 1),
rw1 = TRUE
)
# Choose the rule for selecting the next dose.
my_next_best <- NextBestDualEndpoint(
target = c(0.9, 1),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for stopping.
my_stopping1 <- StoppingTargetBiomarker(
target = c(0.9, 1),
prob = 0.5
)
# For illustration stop with 6 subjects.
my_stopping <- my_stopping1 | StoppingMinPatients(6) | StoppingMissingDose()
# Choose the rule for dose increments.
my_increments <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design.
design <- DualDesign(
model = my_model,
data = emptydata,
nextBest = my_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = CohortSizeConst(3),
startingDose = 3
)
# Define scenarios for the TRUE toxicity and efficacy profiles.
beta_mod <- function(dose, e0, eMax, delta1, delta2, scal) {
maxDens <- (delta1^delta1) *
(delta2^delta2) /
((delta1 + delta2)^(delta1 + delta2))
dose <- dose / scal
e0 + eMax / maxDens * (dose^delta1) * (1 - dose)^delta2
}
true_biomarker <- function(dose) {
beta_mod(
dose,
e0 = 0.2,
eMax = 0.6,
delta1 = 5,
delta2 = 5 * 0.5 / 0.5,
scal = 100
)
}
true_tox <- function(dose) {
pnorm((dose - 60) / 10)
}
# Draw the TRUE profiles.
par(mfrow = c(1, 2))
curve(true_tox(x), from = 0, to = 80)
curve(true_biomarker(x), from = 0, to = 80)
# Run the simulation on the desired design.
# For illustration purposes 1 trial is simulated with 5 burn-ins to generate 20 samples.
my_sims <- simulate(
object = design,
trueTox = true_tox,
trueBiomarker = true_biomarker,
sigma2W = 0.01,
rho = 0,
nsim = 1,
parallel = FALSE,
seed = 3,
startingDose = 6,
mcmcOptions = McmcOptions(
burnin = 5,
step = 1,
samples = 20
)
)
# Summarize the results of the simulations.
summary(
my_sims,
trueTox = true_tox,
trueBiomarker = true_biomarker
)
Summarize the GeneralSimulations, Relative to a Given Truth
Description
Summarize simulations relative to a given true dose-toxicity curve.
Usage
## S4 method for signature 'GeneralSimulations'
summary(object, truth, target = c(0.2, 0.35), ...)
Arguments
object |
( |
truth |
( |
target |
( |
... |
additional arguments can be supplied here for |
Value
An object of class GeneralSimulationsSummary.
Summarize PseudoDualFlexiSimulations
Description
Summary for PseudoDualFlexiSimulations given a pseudo DLE model and
the flexible efficacy model.
Usage
## S4 method for signature 'PseudoDualFlexiSimulations'
summary(
object,
trueDLE,
trueEff,
targetEndOfTrial = 0.3,
targetDuringTrial = 0.35,
...
)
Arguments
object |
( |
trueDLE |
( |
trueEff |
( |
targetEndOfTrial |
( |
targetDuringTrial |
( |
... |
additional arguments can be supplied here for |
Value
An object of class PseudoDualSimulationsSummary.
Examples
# nolint start
## If DLE and efficacy responses are considered in the simulations and the 'EffFlexi' class is used
## we need a data object with doses >= 1:
data <- DataDual(doseGrid = seq(25, 300, 25))
## First for the DLE model
## The DLE model must be of 'ModelTox' (e.g 'LogisticIndepBeta') class
DLEmodel <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = data
)
## for the efficacy model
Effmodel <- EffFlexi(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
sigma2W = c(a = 0.1, b = 0.1),
sigma2betaW = c(a = 20, b = 50),
rw1 = FALSE,
data = data
)
## specified the next best
mynextbest <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
## The increments (see Increments class examples)
## 200% allowable increase for dose below 300 and 200% increase for dose above 300
myIncrements <- IncrementsRelative(
intervals = c(25, 300),
increments = c(2, 2)
)
## cohort size of 3
mySize <- CohortSizeConst(size = 3)
## Stop only when 10 subjects are treated:
## very low sample size is just for illustration here
myStopping <- StoppingMinPatients(nPatients = 10)
## Specified the design
design <- DualResponsesSamplesDesign(
nextBest = mynextbest,
cohort_size = mySize,
startingDose = 25,
model = DLEmodel,
eff_model = Effmodel,
data = data,
stopping = myStopping,
increments = myIncrements
)
## specified the true DLE curve and the true expected efficacy values at all dose levels
myTruthDLE <- probFunction(DLEmodel, phi1 = -53.66584, phi2 = 10.50499)
myTruthEff <- c(
-0.5478867,
0.1645417,
0.5248031,
0.7604467,
0.9333009,
1.0687031,
1.1793942,
1.2726408,
1.3529598,
1.4233411,
1.4858613,
1.5420182
)
## specify the options for MCMC
# For illustration purpose, we use 10 burn-in and generate 100 samples
options <- McmcOptions(burnin = 10, step = 1, samples = 100)
## The simulation
## For illustration purpose only 1 simulation is produced (nsim=1).
mySim <- simulate(
object = design,
args = NULL,
trueDLE = myTruthDLE,
trueEff = myTruthEff,
trueSigma2 = 0.025,
trueSigma2betaW = 1,
nsim = 1,
seed = 819,
parallel = FALSE,
mcmcOptions = options
)
## summarize the simulation results
summary(mySim, trueDLE = myTruthDLE, trueEff = myTruthEff)
# nolint end
Summarize PseudoDualSimulations
Description
Summary for Pseudo Dual responses simulations, relative to a given pseudo DLE and efficacy model (except the EffFlexi class model).
Usage
## S4 method for signature 'PseudoDualSimulations'
summary(
object,
trueDLE,
trueEff,
targetEndOfTrial = 0.3,
targetDuringTrial = 0.35,
...
)
Arguments
object |
( |
trueDLE |
( |
trueEff |
( |
targetEndOfTrial |
( |
targetDuringTrial |
( |
... |
additional arguments can be supplied here for |
Value
An object of class PseudoDualSimulationsSummary.
Examples
# Obtain the plot for the simulation results if DLE and efficacy responses
# are considered in the simulations.
# Specified simulations when no samples are used.
emptydata <- DataDual(doseGrid = seq(25, 300, 25))
# The DLE model must be of 'ModelTox' (e.g 'LogisticIndepBeta') class.
dle_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = emptydata
)
# The efficacy model of 'ModelEff' (e.g 'Effloglog') class.
eff_model <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = emptydata
)
# The escalation rule using the 'NextBestMaxGain' class.
my_next_best <- NextBestMaxGain(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
# Allow increase of 200%.
my_increments <- IncrementsRelative(intervals = 0, increments = 2)
# Cohort size of 3.
my_size <- CohortSizeConst(size = 3)
# Stop when 36 subjects are treated or next dose is NA.
my_stopping <- StoppingMinPatients(nPatients = 36) | StoppingMissingDose()
# Specify the design. (For details please refer to the 'DualResponsesDesign' example.)
my_design <- DualResponsesDesign(
nextBest = my_next_best,
model = dle_model,
eff_model = eff_model,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 25
)
# Specify the true DLE and efficacy curves.
my_truth_dle <- probFunction(dle_model, phi1 = -53.66584, phi2 = 10.50499)
my_truth_eff <- efficacyFunction(eff_model, theta1 = -4.818429, theta2 = 3.653058)
# Specify the simulations and generate the 2 trials.
my_sim <- simulate(
object = my_design,
args = NULL,
trueDLE = my_truth_dle,
trueEff = my_truth_eff,
trueNu = 1 / 0.025,
nsim = 2,
seed = 819,
parallel = FALSE
)
# Produce a summary of the simulations.
summary(
my_sim,
trueDLE = my_truth_dle,
trueEff = my_truth_eff
)
# Example where DLE and efficacy samples are involved.
# Please refer to design-method 'simulate DualResponsesSamplesDesign' examples for details.
# Specify the next best rule.
my_next_best <- NextBestMaxGainSamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, prob = 0.3))
},
mg_derive = function(mg_samples) {
as.numeric(quantile(mg_samples, prob = 0.5))
}
)
# Specify the design.
my_design <- DualResponsesSamplesDesign(
nextBest = my_next_best,
cohort_size = my_size,
startingDose = 25,
model = dle_model,
eff_model = eff_model,
data = emptydata,
stopping = my_stopping,
increments = my_increments
)
# For illustration purpose 50 burn-ins to generate 200 samples are used.
my_options <- McmcOptions(burnin = 50, step = 2, samples = 200)
# fmt: skip
# For illustration purpose 2 simulation are created.
my_sim <- simulate(
object = my_design,
args = NULL,
trueDLE = my_truth_dle,
trueEff = my_truth_eff,
trueNu = 1 / 0.025,
nsim = 2,
mcmcOptions = my_options,
seed = 819,
parallel = FALSE
)
# Produce a summary of the simulations.
summary(
my_sim,
trueDLE = my_truth_dle,
trueEff = my_truth_eff
)
Summarize PseudoSimulations
Description
Summarize the simulations, relative to a given truth.
Usage
## S4 method for signature 'PseudoSimulations'
summary(object, truth, targetEndOfTrial = 0.3, targetDuringTrial = 0.35, ...)
Arguments
object |
( |
truth |
( |
targetEndOfTrial |
( |
targetDuringTrial |
( |
... |
additional arguments can be supplied here for |
Value
An object of class PseudoSimulationsSummary.
Examples
emptydata <- Data(doseGrid = seq(25, 300, 25))
# The design incorporate DLE responses and DLE samples.
# Specify the model of 'ModelTox' class eg 'LogisticIndepBeta' class model.
my_model <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = emptydata
)
# The escalation rule.
td_next_best <- NextBestTD(
prob_target_drt = 0.35,
prob_target_eot = 0.3
)
# Cohort size is 3 subjects.
my_size <- CohortSizeConst(size = 3)
# Allow increase of 200%.
my_increments <- IncrementsRelative(intervals = 0, increments = 2)
# Stopp when the maximum sample size of 36 patients has been reached or the next
# dose is NA.
my_stopping <- StoppingMinPatients(nPatients = 36) | StoppingMissingDose()
# Specify the design. (For details please refer to the 'TDDesign' example.)
my_design <- TDDesign(
model = my_model,
nextBest = td_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 25
)
# Specify the truth of the DLE responses.
my_truth <- probFunction(my_model, phi1 = -53.66584, phi2 = 10.50499)
# For illustration purpose 50 burn-ins to generate 200 samples are used.
my_options <- McmcOptions(burnin = 50, step = 2, samples = 200)
# Refer to design-method 'simulate TDDesign' examples for details.
# For illustration purpose only 1 simulation is produced.
my_sim <- simulate(
object = my_design,
args = NULL,
truth = my_truth,
nsim = 1,
seed = 819,
parallel = FALSE,
mcmcOptions = my_options
)
# Produce a summary of the simulations.
summary(
my_sim,
truth = my_truth
)
# Example where DLE samples are involved.
# Specify the next best rule.
td_next_best <- NextBestTDsamples(
prob_target_drt = 0.35,
prob_target_eot = 0.3,
derive = function(samples) {
as.numeric(quantile(samples, probs = 0.3))
}
)
# The design.
my_design <- TDsamplesDesign(
model = my_model,
nextBest = td_next_best,
stopping = my_stopping,
increments = my_increments,
cohort_size = my_size,
data = emptydata,
startingDose = 25
)
# For illustration purpose 50 burn-ins to generate 200 samples are used.
my_options <- McmcOptions(burnin = 50, step = 2, samples = 200)
# For illustration purpose 2 trials are simulated.
my_sim <- simulate(
object = my_design,
args = NULL,
truth = my_truth,
nsim = 2,
seed = 819,
mcmcOptions = my_options,
parallel = FALSE
)
# Produce a summary of the simulations.
summary(
my_sim,
truth = my_truth
)
Summarize Model-Based Design Simulations
Description
Summarize the model-based design simulations, relative to a given truth.
Usage
## S4 method for signature 'Simulations'
summary(object, truth, target = c(0.2, 0.35), ...)
Arguments
object |
( |
truth |
( |
target |
( |
... |
additional arguments can be supplied here for |
Value
An object of class SimulationsSummary.
Examples
# nolint start
# Define the dose-grid
emptydata <- Data(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
# Initialize the CRM model
model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
# Choose the rule for selecting the next dose
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Choose the rule for the cohort-size
mySize1 <- CohortSizeRange(
intervals = c(0, 30),
cohort_size = c(1, 3)
)
mySize2 <- CohortSizeDLT(
intervals = c(0, 1),
cohort_size = c(1, 3)
)
mySize <- maxSize(mySize1, mySize2)
# Choose the rule for stopping
myStopping1 <- StoppingMinCohorts(nCohorts = 3)
myStopping2 <- StoppingTargetProb(
target = c(0.2, 0.35),
prob = 0.5
)
myStopping3 <- StoppingMinPatients(nPatients = 20)
myStopping <- (myStopping1 & myStopping2) | myStopping3
# Choose the rule for dose increments
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
# Initialize the design
design <- Design(
model = model,
nextBest = myNextBest,
stopping = myStopping,
increments = myIncrements,
cohort_size = mySize,
data = emptydata,
startingDose = 3
)
## define the true function
myTruth <- probFunction(model, alpha0 = 7, alpha1 = 8)
# Run the simulation on the desired design
# We only generate 1 trial outcomes here for illustration, for the actual study
# this should be increased of course
options <- McmcOptions(
burnin = 100,
step = 2,
samples = 1000
)
time <- system.time(
mySims <- simulate(
design,
args = NULL,
truth = myTruth,
nsim = 1,
seed = 819,
mcmcOptions = options,
parallel = FALSE,
derive = list(
max_mtd = max,
mean_mtd = mean,
median_mtd = median
),
)
)[3]
# Summarize the Results of the Simulations
summary(mySims, truth = myTruth)
# nolint end
Tidying CrmPackClass objects
Description
In the spirit of the broom package, provide a method to convert a
CrmPackClass object to a (list of) tibbles.
Following the principles of the broom package, convert a CrmPackClass
object to a (list of) tibbles. This is a basic, default representation.
A method that tidies a GeneralData object.
A method that tidies a DataGrouped object.
A method that tidies a DataDA object.
A method that tidies a DataDual object.
A method that tidies a DataParts object.
A method that tidies a DataMixture object.
A method that tidies a DataOrdinal object.
A method that tidies a LogisticIndepBeta object.
A method that tidies a Effloglog object.
Usage
tidy(x, ...)
## S4 method for signature 'CrmPackClass'
tidy(x, ...)
## S4 method for signature 'GeneralData'
tidy(x, ...)
## S4 method for signature 'DataGrouped'
tidy(x, ...)
## S4 method for signature 'DataDA'
tidy(x, ...)
## S4 method for signature 'DataDual'
tidy(x, ...)
## S4 method for signature 'DataParts'
tidy(x, ...)
## S4 method for signature 'DataMixture'
tidy(x, ...)
## S4 method for signature 'DataOrdinal'
tidy(x, ...)
## S4 method for signature 'Simulations'
tidy(x, ...)
## S4 method for signature 'LogisticIndepBeta'
tidy(x, ...)
## S4 method for signature 'Effloglog'
tidy(x, ...)
## S4 method for signature 'IncrementsMaxToxProb'
tidy(x, ...)
## S4 method for signature 'IncrementsRelative'
tidy(x, ...)
## S4 method for signature 'CohortSizeDLT'
tidy(x, ...)
## S4 method for signature 'CohortSizeMin'
tidy(x, ...)
## S4 method for signature 'CohortSizeMax'
tidy(x, ...)
## S4 method for signature 'CohortSizeRange'
tidy(x, ...)
## S4 method for signature 'CohortSizeParts'
tidy(x, ...)
## S4 method for signature 'IncrementsMin'
tidy(x, ...)
## S4 method for signature 'IncrementsRelative'
tidy(x, ...)
## S4 method for signature 'IncrementsRelativeDLT'
tidy(x, ...)
## S4 method for signature 'IncrementsRelativeParts'
tidy(x, ...)
## S4 method for signature 'NextBestNCRM'
tidy(x, ...)
## S4 method for signature 'NextBestNCRMLoss'
tidy(x, ...)
## S4 method for signature 'DualDesign'
tidy(x, ...)
## S4 method for signature 'Samples'
tidy(x, ...)
Arguments
x |
( |
... |
potentially used by class-specific methods. |
Value
A (list of) tibble(s) representing the object in tidy form.
The tibble::tibble object.
The tibble::tibble object.
The tibble::tibble object.
The tibble::tibble object.
The tibble::tibble object.
The tibble::tibble object.
The tibble::tibble object.
The list of tibble::tibble objects.
The list of tibble::tibble objects.
Usage Notes
The prior observations are indicated by a Cohort value of 0 in the returned
tibble.
Examples
CohortSizeConst(3) %>% tidy()
.DefaultData() %>% tidy()
.DefaultDataOrdinal() %>% tidy()
.DefaultDataGrouped() %>% tidy()
.DefaultDataDA() %>% tidy()
.DefaultData() %>% tidy()
.DefaultDataOrdinal() %>% tidy()
.DefaultDataGrouped() %>% tidy()
.DefaultDataDA() %>% tidy()
.DefaultData() %>% tidy()
.DefaultDataOrdinal() %>% tidy()
.DefaultDataGrouped() %>% tidy()
.DefaultDataDA() %>% tidy()
.DefaultData() %>% tidy()
.DefaultDataOrdinal() %>% tidy()
.DefaultDataGrouped() %>% tidy()
.DefaultDataDA() %>% tidy()
.DefaultData() %>% tidy()
.DefaultDataOrdinal() %>% tidy()
.DefaultDataGrouped() %>% tidy()
.DefaultDataDA() %>% tidy()
.DefaultData() %>% tidy()
.DefaultDataOrdinal() %>% tidy()
.DefaultDataGrouped() %>% tidy()
.DefaultDataDA() %>% tidy()
.DefaultData() %>% tidy()
.DefaultDataOrdinal() %>% tidy()
.DefaultDataGrouped() %>% tidy()
.DefaultDataDA() %>% tidy()
.DefaultSimulations() %>% tidy()
.DefaultLogisticIndepBeta() %>% tidy()
.DefaultEffloglog() %>% tidy()
IncrementsMaxToxProb(prob = c("DLAE" = 0.2, "CRS" = 0.05)) %>% tidy()
CohortSizeRange(intervals = c(0, 20), cohort_size = c(1, 3)) %>% tidy()
.DefaultCohortSizeDLT() %>% tidy()
.DefaultCohortSizeMin() %>% tidy()
.DefaultCohortSizeMax() %>% tidy()
.DefaultCohortSizeRange() %>% tidy()
CohortSizeParts(cohort_sizes = c(1, 3)) %>% tidy()
.DefaultIncrementsMin() %>% tidy()
CohortSizeRange(intervals = c(0, 20), cohort_size = c(1, 3)) %>% tidy()
x <- .DefaultIncrementsRelativeDLT()
x %>% tidy()
.DefaultIncrementsRelativeParts() %>% tidy()
NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
) %>%
tidy()
.DefaultNextBestNCRMLoss() %>% tidy()
.DefaultDualDesign() %>% tidy()
options <- McmcOptions(
burnin = 100,
step = 1,
samples = 2000
)
emptydata <- Data(doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100))
model <- LogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56
)
samples <- mcmc(emptydata, model, options)
samples %>% tidy()
Updating Data Objects
Description
A method that updates existing Data object with new data.
Usage
## S4 method for signature 'Data'
update(
object,
x,
y,
ID = length(object@ID) + seq_along(y),
new_cohort = TRUE,
check = TRUE,
...
)
Arguments
object |
( |
x |
( |
y |
( |
ID |
( |
new_cohort |
( |
check |
( |
... |
not used. |
Details
The current implementation of this update method allows for
updating the Data class object by adding a single dose level x only.
However, there might be some use cases where the new cohort to be added
contains a placebo and active dose. Hence, such update would need to be
performed iteratively by calling the update method twice. For example,
in the first call a user can add a placebo, and then in the second call,
an active dose. Since having a cohort with placebo only is not allowed,
the update method would normally throw the error when attempting to add
a placebo in the first call. To allow for such updates, the check
parameter should be then set to FALSE for that first call.
Value
The new, updated Data object.
Examples
# Create some data of class '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),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Update the data with a new cohort.
my_data1 <- update(my_data, x = 20, y = c(0L, 1L, 1L))
my_data1
Updating DataDA Objects
Description
A method that updates existing DataDA object with new data.
Usage
## S4 method for signature 'DataDA'
update(object, u, t0, trialtime, y, ..., check = TRUE)
Arguments
object |
( |
u |
( |
t0 |
( |
trialtime |
( |
y |
( |
... |
further arguments passed to |
check |
( |
Value
The new, updated DataDA object.
Note
This function is capable of not only adding new patients but also
updates existing ones with respect to y, t0, u slots.
Examples
# Create an object of class 'DataDA'.
my_data <- DataDA(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 1, 1, 0, 0, 1, 0),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2)),
u = c(42, 30, 15, 5, 20, 25, 30, 60),
t0 = c(0, 15, 30, 40, 55, 70, 75, 85),
Tmax = 60
)
# Update the data.
my_data1 <- update(
object = my_data,
y = c(my_data@y, 0), # The 'y' will be updated according to 'u'.
u = c(my_data@u, 20),
t0 = c(my_data@t0, 95),
x = 20,
trialtime = 120 # This is the global timeline for a trial.
)
my_data1
Updating DataDual Objects
Description
A method that updates existing DataDual object with new data.
Usage
## S4 method for signature 'DataDual'
update(object, w, ..., check = TRUE)
Arguments
object |
( |
w |
( |
... |
further arguments passed to |
check |
( |
Value
The new, updated DataDual object.
Examples
# Create some data of class 'DataDual'.
my_data <- DataDual(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 0, 0, 0, 0, 1, 0),
w = rnorm(8),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
# Update the data with a new cohort.
my_data1 <- update(my_data, x = 20, y = c(0, 1, 1), w = c(0.4, 1.2, 2.2))
my_data1
Updating DataOrdinal Objects
Description
A method that updates existing DataOrdinal object with new data.
Usage
## S4 method for signature 'DataOrdinal'
update(
object,
x,
y,
ID = length(object@ID) + seq_along(y),
new_cohort = TRUE,
check = TRUE,
...
)
Arguments
object |
( |
x |
( |
y |
( |
ID |
( |
new_cohort |
( |
check |
( |
... |
not used. |
Details
The current implementation of this update method allows for
updating the DataOrdinal class object by adding a single dose level x only.
However, there might be some use cases where the new cohort to be added
contains a placebo and active dose. Hence, such update would need to be
performed iteratively by calling the update method twice. For example,
in the first call a user can add a placebo, and then in the second call,
an active dose. Since having a cohort with placebo only is not allowed,
the update method would normally throw the error when attempting to add
a placebo in the first call. To allow for such updates, the check
parameter should be then set to FALSE for that first call.
Value
The new, updated DataOrdinal object.
Examples
data <- DataOrdinal(
x = c(10, 20, 30, 40, 50, 50, 50, 60, 60, 60),
y = as.integer(c(0, 0, 0, 0, 0, 1, 0, 0, 1, 2)),
ID = 1L:10L,
cohort = as.integer(c(1:4, 5, 5, 5, 6, 6, 6)),
doseGrid = c(seq(from = 10, to = 100, by = 10)),
yCategories = c("No tox" = 0L, "Sub-tox AE" = 1L, "DLT" = 2L),
placebo = FALSE
)
update(data, x = 70, y = c(1L, 2L, 1L))
Updating DataParts Objects
Description
A method that updates existing DataParts object with new data.
Usage
## S4 method for signature 'DataParts'
update(object, x, y, ..., check = TRUE)
Arguments
object |
( |
x |
( |
y |
( |
... |
further arguments passed to |
check |
( |
Value
The new, updated DataParts object.
Examples
# Create an object of class 'DataParts'.
my_data <- DataParts(
x = c(0.1, 0.5, 1.5),
y = c(0, 0, 0),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2)),
part = c(1L, 1L, 1L),
nextPart = 1L,
part1Ladder = c(0.1, 0.5, 1.5, 3, 6, 10)
)
# Update the data with a new cohort.
# Note that since we reached the last level from 'part1Ladder'
# then the 'nextPart' is switched from '1' to '2'.
my_data1 <- update(my_data, x = 10, y = 0L)
my_data1
Update method for the ModelPseudo model class. This is a method to update
the model class slots (estimates, parameters, variables and etc.), when the
new data (e.g. new observations of responses) are available. This method is
mostly used to obtain new modal estimates for pseudo model parameters.
Description
Update method for the ModelPseudo model class. This is a method to update
the model class slots (estimates, parameters, variables and etc.), when the
new data (e.g. new observations of responses) are available. This method is
mostly used to obtain new modal estimates for pseudo model parameters.
Usage
## S4 method for signature 'ModelPseudo'
update(object, data, ...)
Arguments
object |
( |
data |
( |
... |
not used. |
Value
the new ModelPseudo class object.
Examples
# Update the 'LogisticIndepBeta' model with new data.
empty_data <- Data(doseGrid = seq(25, 300, 25))
my_model_lib <- LogisticIndepBeta(
binDLE = c(1.05, 1.8),
DLEweights = c(3, 3),
DLEdose = c(25, 300),
data = empty_data
)
# Then, we have some new observations data.
data <- Data(
x = c(25, 50, 50, 75, 100, 100, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
ID = 1:8,
cohort = c(1L, 2L, 2L, 3L, 4L, 4L, 5L, 6L),
doseGrid = empty_data@doseGrid
)
# Update the model to get new estimates.
new_model_lib <- update(object = my_model_lib, data = data)
# Update the 'Effloglog' model with new data.
empty_data_dual <- DataDual(doseGrid = seq(25, 300, 25), placebo = FALSE)
my_model_eff <- Effloglog(
eff = c(1.223, 2.513),
eff_dose = c(25, 300),
nu = c(a = 1, b = 0.025),
data = empty_data_dual,
const = 0
)
# Data with new observations data.
my_data_dual <- DataDual(
x = c(25, 50, 50, 75, 100, 100, 225, 300),
y = c(0, 0, 0, 0, 1, 1, 1, 1),
w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
ID = 1:8,
cohort = c(1L, 2L, 2L, 3L, 4L, 4L, 5L, 6L),
doseGrid = empty_data_dual@doseGrid
)
# Update the model to get new estimates.
new_model_eff <- update(object = my_model_eff, data = my_data_dual)
Internal Helper Functions for Validation of CohortSize Objects
Description
These functions are only used internally to validate the format of an input
CohortSize or inherited classes and therefore not exported.
Usage
v_cohort_size_range(object)
v_cohort_size_dlt(object)
v_cohort_size_const(object)
v_cohort_size_parts(object)
v_cohort_size_max(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_cohort_size_range(): validates that theCohortSizeRangeobject contains validintervalsandcohort_sizeslots. -
v_cohort_size_dlt(): validates that theCohortSizeDLTobject contains validintervalsandcohort_sizeslots. -
v_cohort_size_const(): validates that theCohortSizeConstobject contains validsizeslot. -
v_cohort_size_parts(): validates that theCohortSizePartsobject contains validsizesslot. -
v_cohort_size_max(): validates that theCohortSizeMaxobject contains validcohort_sizesslot.
Internal Helper Functions for Validation of GeneralData Objects
Description
These functions are only used internally to validate the format of an input
GeneralData or inherited classes and therefore not exported.
Usage
v_general_data(object)
h_doses_unique_per_cohort(dose, cohort)
v_data(object)
v_data_dual(object)
v_data_parts(object)
v_data_mixture(object)
v_data_da(object)
v_data_ordinal(object)
v_data_grouped(object)
Arguments
object |
( |
dose |
( |
cohort |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
TRUE if dose is unique per cohort, otherwise FALSE.
Functions
-
v_general_data(): validates that theGeneralDataobject contains uniqueID, non-negativecohortindices andIDandcohortvectors are of the same lengthnObs. -
h_doses_unique_per_cohort(): helper function which verifies whether thedosevalues are unique in each and every differentcohort. -
v_data(): validates that theDataobject contains valid elements with respect to their types, dependency and length. -
v_data_dual(): validates that theDataDualobject contains valid biomarker vector with respect to its type and the length. -
v_data_parts(): validates that theDataPartsobject contains valid elements with respect to their types, dependency and length. -
v_data_mixture(): validates that theDataMixtureobject contains valid elements with respect to their types, dependency and length. -
v_data_da(): validates that theDataDAobject contains valid elements with respect to their types, dependency and length. -
v_data_ordinal(): validates that theDataOrdinalobject contains valid elements with respect to their types, dependency and length. -
v_data_grouped(): validates that theDataGroupedobject contains valid group information.
Internal Helper Functions for Validation of RuleDesign Objects
Description
These functions are only used internally to validate the format of an input
RuleDesign or inherited classes and therefore not exported.
These functions are only used internally to validate the format of an input
RuleDesignOrdinal or inherited classes and therefore not exported.
Usage
v_rule_design(object)
v_rule_design_ordinal(object)
v_design_grouped(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_rule_design(): validates that theRuleDesignobject contains validstartingDose. -
v_rule_design_ordinal(): validates that theRuleDesignOrdinalobject contains validstarting_dose. -
v_design_grouped(): validates that theDesignGroupedobject contains valid flags.
Internal Helper Functions for Validation of GeneralSimulations Objects
Description
These functions are only used internally to validate the format of an input
GeneralSimulations or inherited classes and therefore not exported.
Usage
v_general_simulations(object)
v_simulations(object)
v_dual_simulations(object)
v_da_simulations(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_general_simulations(): validates that theGeneralSimulationsobject contains validdataobject and validdosesimulations. -
v_simulations(): validates that theSimulationsobject contains valid objectfit,stop_reasons,stop_report, andadditional_statscompared to the general classGeneralSimulations. -
v_dual_simulations(): validates that theDualSimulationsobject and capture the dose-biomarkerfits, and thesigma2Wandrhoestimates. -
v_da_simulations(): validates that theDASimulationsobject contains validtrial_durationthe vector of trial duration values for all simulations.
Internal Helper Functions for Validation of Increments Objects
Description
These functions are only used internally to validate the format of an input
Increments or inherited classes and therefore not exported.
Usage
v_increments_relative(object)
v_increments_relative_parts(object)
v_increments_relative_dlt(object)
v_increments_dose_levels(object)
v_increments_hsr_beta(object)
v_increments_min(object)
v_increments_maxtoxprob(object)
v_increments_ordinal(object)
v_cohort_size_ordinal(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_increments_relative(): validates that theIncrementsRelativeobject contains validintervalsandincrementsparameters. -
v_increments_relative_parts(): validates that theIncrementsRelativePartsobject contains validdlt_startandclean_startparameters. -
v_increments_relative_dlt(): validates that theIncrementsRelativeDLTobject contains validintervalsandincrementsparameters. -
v_increments_dose_levels(): validates that theIncrementsDoseLevelsobject contains validlevelsandbasis_leveloption. -
v_increments_hsr_beta(): validates that theIncrementsHSRBetaobject contains valid probability target, threshold and shape parameters. -
v_increments_min(): validates that theIncrementsMinobject contains a list withIncrementsobjects. -
v_increments_maxtoxprob(): validates theIncrementsMaxToxProb -
v_increments_ordinal(): validates that theIncrementsOrdinalobject contains validgradeand standardIncrementsrule. -
v_cohort_size_ordinal(): validates that theCohortSizeOrdinalobject contains validgradeand standardCohortSizerule.
Internal Helper Functions for Validation of McmcOptions Objects
Description
These functions are only used internally to validate the format of an input
McmcOptions or inherited classes and therefore not exported.
Usage
v_mcmc_options(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_mcmc_options(): validates that theMcmcOptionsobject contains valid integer scalarsiterations,burninandstepas well as proper parameters for Random Number Generator.
Internal Helper Functions for Validation of GeneralModel and ModelPseudo Objects
Description
These functions are only used internally to validate the format of an input
GeneralModel and ModelPseudo or inherited classes and therefore are
not exported.
Usage
v_general_model(object)
v_model_logistic_kadane(object)
v_model_logistic_kadane_beta_gamma(object)
v_model_logistic_normal_mix(object)
v_model_logistic_normal_fixed_mix(object)
v_model_logistic_log_normal_mix(object)
v_model_dual_endpoint(object)
v_model_dual_endpoint_rw(object)
v_model_dual_endpoint_beta(object)
v_model_dual_endpoint_emax(object)
v_model_logistic_indep_beta(object)
v_model_eff_log_log(object)
v_model_eff_flexi(object)
v_model_da_logistic_log_normal(object)
v_model_tite_logistic_log_normal(object)
v_model_one_par_exp_normal_prior(object)
v_model_one_par_exp_prior(object)
v_logisticlognormalordinal(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_general_model(): validates that the names of the arguments ininitfunction are included indatanamesordatanames_priorslots. -
v_model_logistic_kadane(): validates that the logistic Kadane model parameters are valid. -
v_model_logistic_kadane_beta_gamma(): validates that the logistic Kadane model parameters with a beta and gamma prior are valid. -
v_model_logistic_normal_mix(): validates thatweightparis valid. -
v_model_logistic_normal_fixed_mix(): validates thatcomponentis a list with validModelParamsNormalobjects as well asweightsare correct. -
v_model_logistic_log_normal_mix(): validates thatshare_weightrepresents probability. -
v_model_dual_endpoint(): validates thatDualEndpointclass slots are valid. -
v_model_dual_endpoint_rw(): validates thatDualEndpointRWclass slots are valid. -
v_model_dual_endpoint_beta(): validates thatDualEndpointBetaclass slots are valid. -
v_model_dual_endpoint_emax(): validates thatDualEndpointEmaxclass slots are valid. -
v_model_logistic_indep_beta(): validates thatLogisticIndepBetaclass slots are valid. -
v_model_eff_log_log(): validates thatEffloglogclass slots are valid. -
v_model_eff_flexi(): validates thatEffFlexiclass slots are valid. -
v_model_da_logistic_log_normal(): validates thatDALogisticLogNormalclass slots are valid. -
v_model_tite_logistic_log_normal(): validates thatTITELogisticLogNormalclass slots are valid. -
v_model_one_par_exp_normal_prior(): validates thatOneParLogNormalPriorclass slots are valid. -
v_model_one_par_exp_prior(): validates thatOneParExpPriorclass slots are valid. -
v_logisticlognormalordinal(): confirms that cov is diagonal
Internal Helper Functions for Validation of Model Parameters Objects
Description
These functions are only used internally to validate the format of an object with model parameters or inherited classes and therefore not exported.
Usage
v_model_params_normal(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_model_params_normal(): a helper function that validates multivariate normal parameters.
Internal Helper Functions for Validation of NextBest Objects
Description
These functions are only used internally to validate the format of an input
NextBest or inherited classes and therefore not exported.
Usage
v_next_best_mtd(object)
v_next_best_ncrm(object)
v_next_best_ncrm_loss(object)
v_next_best_dual_endpoint(object)
v_next_best_min_dist(object)
v_next_best_ewoc(object)
v_next_best_inf_theory(object)
v_next_best_td(object)
v_next_best_td_samples(object)
v_next_best_max_gain_samples(object)
v_next_best_prob_mtd_lte(object)
v_next_best_prob_mtd_min_dist(object)
v_next_best_ordinal(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_next_best_mtd(): validates that theNextBestMTDobject contains validtargetprobability andderivefunction. -
v_next_best_ncrm(): validates that theNextBestNCRMobject contains validtargetprobability,overdoseandmax_overdose_probprobability ranges. -
v_next_best_ncrm_loss(): validates that theNextBestNCRMLossobject contains valid objects. -
v_next_best_dual_endpoint(): validates that theNextBestDualEndpointobject contains valid probability objects. -
v_next_best_min_dist(): validates that theNextBestMinDistobject contains validtargetobject. -
v_next_best_ewoc(): validates that theNextBestEWOCobject contains validtarget,overdoseandmax_overdose_probparameters. -
v_next_best_inf_theory(): validates that theNextBestInfTheoryobject contains validtargetandasymmetryobjects. -
v_next_best_td(): validates that theNextBestTDobject contains validprob_target_drtandprob_target_eotprobabilities. -
v_next_best_td_samples(): validates that theNextBestTDsamplesobject contains validderivefunction. -
v_next_best_max_gain_samples(): validates that theNextBestMaxGainSamplesobject contains validderiveandmg_derivefunctions. -
v_next_best_prob_mtd_lte(): validates that theNextBestProbMTDLTEobject contains validtargetprobability andmethodstring value. -
v_next_best_prob_mtd_min_dist(): validates that theNextBestProbMTDMinDistobject contains validtargetprobability andmethodstring value. -
v_next_best_ordinal(): validates that theNextBestOrdinalobject contains validgradeand standardNextBestrule.
Internal Helper Functions for Validation of PseudoSimulations Objects
Description
These functions are only used internally to validate the format of an input
PseudoSimulations or inherited classes and therefore not exported.
Usage
v_pseudo_simulations(object)
v_pseudo_dual_simulations(object)
v_pseudo_dual_flex_simulations(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_pseudo_simulations(): validates that thePseudoSimulationsobject contains validfit,FinalTDtargetEndOfTrialEstimates,FinalTDtargetDuringTrialAtDoseGrid,FinalTDtargetEndOfTrialAtDoseGrid,FinalTDEOTCIs,FinalTDEOTRatios,FinalCIs,FinalRatios, object and validstopReasonssimulations. -
v_pseudo_dual_simulations(): validates that thePseudoDualSimulationsobject contains validfit_eff,final_gstar_estimates,final_gstar_at_dose_grid,final_gstar_cis,final_gstar_ratios,final_optimal_dose,final_optimal_dose_at_dose_gridobject and validsigma2_estsimulations. -
v_pseudo_dual_flex_simulations(): validates that thePseudoDualFlexiSimulationsobject contains validsigma2_beta_w_estvector of the final posterior mean sigma2betaW estimates.FinalGstarEstimates,FinalGstarAtDoseGrid,
Internal Helper Functions for Validation of SafetyWindow Objects
Description
These functions are only used internally to validate the format of an input
SafetyWindow or inherited classes and therefore not exported.
Usage
v_safety_window_size(object)
v_safety_window_const(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_safety_window_size(): validates that theSafetyWindowSizeobject contains valid slots. -
v_safety_window_const(): validates that theSafetyWindowConstobject contains valid slots.
Internal Helper Functions for Validation of Samples Objects
Description
These functions are only used internally to validate the format
of an input Samples or inherited classes and therefore not exported.
Usage
v_samples(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages, or TRUE
in case validation passes.
Functions
-
v_samples(): validates that theSamplesobject contains validdataslot.
Internal Helper Functions for Validation of StartingDose Objects
Description
Validates that the StartingDose object contains valid starting_dose.
Usage
v_starting_dose(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Internal Helper Functions for Validation of Stopping Objects
Description
These functions are only used internally to validate the format of an input
Stopping or inherited classes and therefore not exported.
Usage
v_stopping_cohorts_near_dose(object)
v_stopping_patients_near_dose(object)
v_stopping_min_cohorts(object)
v_stopping_min_patients(object)
v_stopping_target_prob(object)
v_stopping_mtd_distribution(object)
v_stopping_mtd_cv(object)
v_stopping_target_biomarker(object)
v_stopping_list(object)
v_stopping_all(object)
v_stopping_tdci_ratio(object)
Arguments
object |
( |
Value
A character vector with the validation failure messages,
or TRUE in case validation passes.
Functions
-
v_stopping_cohorts_near_dose(): validates that theStoppingCohortsNearDoseobject contains validnCohortsandpercentageparameters. -
v_stopping_patients_near_dose(): validates that theStoppingPatientsNearDoseobject contains validnPatientsandpercentageparameters. -
v_stopping_min_cohorts(): validates that theStoppingMinCohortsobject contains validnCohortsparameter. -
v_stopping_min_patients(): validates that theStoppingMinPatientsobject contains validnPatientsparameter. -
v_stopping_target_prob(): validates that theStoppingTargetProbobject contains validtargetandprobparameters. -
v_stopping_mtd_distribution(): validates that theStoppingMTDdistributionobject contains validtarget,threshandprobparameters. -
v_stopping_mtd_cv(): validates that theStoppingMTDCVobject contains valid probability target and percentage threshold. -
v_stopping_target_biomarker(): validates that theStoppingTargetBiomarkerobject contains validtarget,is_relativeandprobslots. -
v_stopping_list(): validates that theStoppingListobject contains validstop_list,summaryslots. -
v_stopping_all(): validates that theStoppingAllobject contains validstop_listslot. -
v_stopping_tdci_ratio(): validates that theStoppingTDCIRatioobject contains validtarget_ratioandprob_targetslots.
Determine the Safety Window Length of the Next Cohort
Description
This function determines the safety window length of the next cohort.
Usage
windowLength(safetyWindow, size, ...)
## S4 method for signature 'SafetyWindowSize'
windowLength(safetyWindow, size, data, ...)
## S4 method for signature 'SafetyWindowConst'
windowLength(safetyWindow, size, ...)
Arguments
safetyWindow |
( |
size |
( |
... |
additional arguments without method dispatch. |
data |
( |
Value
The windowLength as a list of safety window parameters
(gap, follow, follow_min).
Functions
-
windowLength(SafetyWindowSize): Determine safety window length based on the cohort size. -
windowLength(SafetyWindowConst): Constant safety window length.
Examples
# nolint start
# Create the data
data <- DataDA(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 1, 1, 0, 0, 1, 0),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2)),
u = c(42, 30, 15, 5, 20, 25, 30, 60),
t0 = c(0, 15, 30, 40, 55, 70, 75, 85),
Tmax = 60
)
# Initialize the CRM model used to model the data
npiece_ <- 10
lambda_prior <- function(k) {
npiece_ / (data@Tmax * (npiece_ - k + 0.5))
}
model <- DALogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56,
npiece = npiece_,
l = as.numeric(t(apply(
as.matrix(c(1:npiece_), 1, npiece_),
2,
lambda_prior
))),
c_par = 2
)
# Set-up some MCMC parameters and generate samples from the posterior
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the rule which will be used to select the next cohort size
# based on the class 'CohortSizeConst'
mySize <- CohortSizeConst(size = 3)
# Determine the cohort size for the next cohort
sizeRecommendation <- size(mySize, dose = doseRecommendation$value, data = data)
# Rule for the safety window length:
# -having patientGap as (0,7,3,3,...) for cohort size <4
# -and having patientGap as (0,9,5,5,...) for cohort size >=4
myWindowLength <- SafetyWindowSize(
gap = list(c(7, 3), c(9, 5)),
size = c(1, 4),
follow = 7,
follow_min = 14
)
# Determine the safety window parameters for the next cohort
windowLength(myWindowLength, size = sizeRecommendation)
# nolint end
# nolint start
# Create the data
data <- DataDA(
x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
y = c(0, 0, 1, 1, 0, 0, 1, 0),
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2)),
u = c(42, 30, 15, 5, 20, 25, 30, 60),
t0 = c(0, 15, 30, 40, 55, 70, 75, 85),
Tmax = 60
)
# Initialize the CRM model used to model the data
npiece_ <- 10
lambda_prior <- function(k) {
npiece_ / (data@Tmax * (npiece_ - k + 0.5))
}
model <- DALogisticLogNormal(
mean = c(-0.85, 1),
cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
ref_dose = 56,
npiece = npiece_,
l = as.numeric(t(apply(
as.matrix(c(1:npiece_), 1, npiece_),
2,
lambda_prior
))),
c_par = 2
)
# Set-up some MCMC parameters and generate samples from the posterior
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
set.seed(94)
samples <- mcmc(data, model, options)
# Define the rule for dose increments and calculate the maximum dose allowed
myIncrements <- IncrementsRelative(
intervals = c(0, 20),
increments = c(1, 0.33)
)
nextMaxDose <- maxDose(myIncrements, data = data)
# Define the rule which will be used to select the next best dose
# based on the class 'NextBestNCRM'
myNextBest <- NextBestNCRM(
target = c(0.2, 0.35),
overdose = c(0.35, 1),
max_overdose_prob = 0.25
)
# Calculate the next best dose
doseRecommendation <- nextBest(
myNextBest,
doselimit = nextMaxDose,
samples = samples,
model = model,
data = data
)
# Define the rule which will be used to select the next cohort size
# based on the class 'CohortSizeConst'
mySize <- CohortSizeConst(size = 3)
# Determine the cohort size for the next cohort
sizeRecommendation <- size(mySize, dose = doseRecommendation$value, data = data)
# Rule for having safety window length with constant safety window parameters
myWindowLength <- SafetyWindowConst(gap = c(7, 3), follow = 7, follow_min = 14)
# Determine the safety window parameters for the next cohort
windowLength(myWindowLength, size = sizeRecommendation)
# nolint end