Title: | Object-Oriented Implementation of CRM Designs |
---|---|
Description: | Implements a wide range of model-based dose escalation 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. The focus is on Bayesian inference, making it very easy to setup a new design with its own 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>. |
Authors: | 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 [aut] , Oliver Boix [aut], Robert Adams [aut], Clara Beck [aut], John Kirkpatrick [aut], F. Hoffmann-La Roche AG [cph, fnd], Merck Healthcare KGaA [cph, fnd], Bayer AG [cph, fnd] |
Maintainer: | Daniel Sabanes Bove <[email protected]> |
License: | GPL (>= 2) |
Version: | 2.0.0.9001 |
Built: | 2024-12-15 05:07:22 UTC |
Source: | https://github.com/Roche/crmPack |
Object-oriented implementation of CRM designs
Sabanes Bove 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 (URL: http://doi.org/10.18637/jss.v089.i10).
CohortSize
CohortSize
is a class for cohort sizes.
.DefaultCohortSize() .DefaultCohortSize()
.DefaultCohortSize() .DefaultCohortSize()
Typically, end users will not use the DefaultCohortSize()
function.
Typically, end users will not use the DefaultCohortSize()
function.
CohortSizeRange
, CohortSizeDLT
, CohortSizeConst
,
CohortSizeParts
, CohortSizeMin
, CohortSizeMin
.
The method combining two atomic stopping rules
## S4 method for signature 'Stopping,Stopping' e1 & e2
## S4 method for signature 'Stopping,Stopping' e1 & e2
e1 |
First |
e2 |
Second |
The StoppingAll
object
## 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
## 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
The method combining an atomic and a stopping list
## S4 method for signature 'Stopping,StoppingAll' e1 & e2
## S4 method for signature 'Stopping,StoppingAll' e1 & e2
e1 |
|
e2 |
|
The modified StoppingAll
object
## 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 )
## 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 )
The method combining a stopping list and an atomic
## S4 method for signature 'StoppingAll,Stopping' e1 & e2
## S4 method for signature 'StoppingAll,Stopping' e1 & e2
e1 |
|
e2 |
|
The modified StoppingAll
object
## 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
## 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
To reproduce the resultant approximate model in the future exactly, include
seed = xxxx
in the call to approximate
.
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, ... )
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, ... )
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 |
a list
containing the approximation model and, if requested, a
ggplot2
object containing a graphical representation of the fitted model
approximate(Samples)
: Here the ... argument can transport additional arguments for
Quantiles2LogisticNormal
, e.g. in order to control the
approximation quality, etc.
# 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
# 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
checkmate
We provide additional assertion functions that can be used together with
the checkmate
functions. These are described in individual help pages
linked below.
Depending on the function prefix.
assert_
functions return the object invisibly if successful, and otherwise
throw an error message.
check_
functions return TRUE
if successful, otherwise a string with the
error message.
test_
functions just return TRUE
or FALSE
.
assert_probabilities()
, assert_probability()
,
assert_probability_range()
, assert_length()
.
biomarker(xLevel, model, samples, ...) ## S4 method for signature 'integer,DualEndpoint,Samples' biomarker(xLevel, model, samples, ...)
biomarker(xLevel, model, samples, ...) ## S4 method for signature 'integer,DualEndpoint,Samples' biomarker(xLevel, model, samples, ...)
xLevel |
( |
model |
( |
samples |
( |
... |
not used. |
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.
The biomarker levels.
biomarker(xLevel = integer, model = DualEndpoint, samples = Samples)
:
# 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 )
# 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 )
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.
check_equal(..., tol = sqrt(.Machine$double.eps)) assert_equal( ..., tol = sqrt(.Machine$double.eps), .var.name = vname(x), add = NULL )
check_equal(..., tol = sqrt(.Machine$double.eps)) assert_equal( ..., tol = sqrt(.Machine$double.eps), .var.name = vname(x), add = NULL )
... |
( |
tol |
( |
.var.name |
[ |
add |
[ |
TRUE
if all element-by-element differences are less than tolerance
in magnitude, FALSE
otherwise.
list(...)
, invisibly.
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.
assertions
for more details.
assertions
for more details.
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_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_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) )
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) )
x |
[any] |
len |
[ |
min.len |
[ |
max.len |
[ |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
TRUE
if successful, otherwise a string with the error message.
assertions
for more details.
check_format("%5.2f")
check_format("%5.2f")
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.
check_length(x, len) assert_length(x, len, .var.name = checkmate::vname(x), add = NULL) test_length(x, len)
check_length(x, len) assert_length(x, len, .var.name = checkmate::vname(x), add = NULL) test_length(x, len)
x |
( |
len |
( |
.var.name |
[ |
add |
[ |
TRUE
if successful, otherwise a string with the error message.
assertions
for more details.
check_length(1:5, 1) check_length(1:5, 6) check_length(1:5, 5) check_length(10, 1) check_length(10, 9)
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 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.
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) )
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) )
x |
( |
bounds_closed |
( |
len |
[ |
unique |
[ |
sorted |
[ |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
TRUE
if successful, otherwise a string with the error message.
If there are any missing or non-finite values in x
, this function
returns FALSE
, regardless of the values of other elements in x
.
assertions
for more details.
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))
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 a given value represents a probability, that is a number within (0, 1) interval, that can optionally be closed at any side.
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))
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))
x |
( |
bounds_closed |
( |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
TRUE
if successful, otherwise a string with the error message.
assertions
for more details.
check_probability(0.5) check_probability(0, bounds_closed = FALSE) check_probability(0, bounds_closed = c(FALSE, TRUE))
check_probability(0.5) check_probability(0, bounds_closed = FALSE) check_probability(0, bounds_closed = c(FALSE, TRUE))
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.
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) )
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) )
x |
( |
bounds_closed |
( |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
TRUE
if successful, otherwise a string with the error message.
assertions
for more details.
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))
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))
An argument x
is a numerical range if and only if (all conditions must be met):
Is an object of type: integer
or double
.
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 unique
flag
is set to TRUE
.
Lower bound of the interval is greater than or equal to lower
and
upper bound of the interval is less than or equal to upper
.
It contains only finite (given that finite
is TRUE
) and non-missing values.
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) )
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) )
x |
[any] |
lower |
[ |
upper |
[ |
finite |
[ |
unique |
[ |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
TRUE
if successful, otherwise a string with the error message.
assertions
for more details.
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)
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)
CohortSizeConst
CohortSizeConst
is the class for fixed and constant size of cohort.
CohortSizeConst(size) .DefaultCohortSizeConst()
CohortSizeConst(size) .DefaultCohortSizeConst()
size |
( |
size
(integer
)
cohort size.
Typically, end users will not use the .DefaultCohortSizeConst()
function.
# Cohort of size 3, constant along the study. my_size <- CohortSizeConst(size = 3)
# Cohort of size 3, constant along the study. my_size <- CohortSizeConst(size = 3)
CohortSizeDLT
CohortSizeDLT
is the class for cohort size based on number of DLTs.
CohortSizeDLT(intervals, cohort_size) .DefaultCohortSizeDLT()
CohortSizeDLT(intervals, cohort_size) .DefaultCohortSizeDLT()
intervals |
( |
cohort_size |
( |
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 of intervals
.
Typically, end users will not use the .DefaultCohortSizeDLT()
function.
# 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))
# 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
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.
.DefaultCohortSizeMax() CohortSizeMax(cohort_sizes)
.DefaultCohortSizeMax() CohortSizeMax(cohort_sizes)
cohort_sizes |
( |
cohort_sizes
(list
)
a list of cohort size rules, i.e. objects
of class CohortSize
.
Typically, end users will not use the .DefaultCohortSizeMax()
function.
# 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))
# 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
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.
CohortSizeMin(cohort_sizes) .DefaultCohortSizeMin()
CohortSizeMin(cohort_sizes) .DefaultCohortSizeMin()
cohort_sizes |
( |
cohort_sizes
(list
)
a list of cohort size rules, i.e. objects
of class CohortSize
.
Typically, end users will not use the .DefaultCohortSizeMin()
function.
# 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))
# 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
CohortSizeOrdinal
is the class for cohort size for an ordinal CRM trial.
CohortSizeOrdinal(grade, rule) .DefaultCohortSizeOrdinal()
CohortSizeOrdinal(grade, rule) .DefaultCohortSizeOrdinal()
grade |
( |
rule |
( |
grade
(integer
)
the grade at which the rule should be applied
rule
(CohortSize
)
the CohortSize
rule to apply.
Typically, end users will not use the .DefaultCohortSizeOrdinal()
function.
CohortSizeOrdinal( grade = 1L, rule = CohortSizeRange(intervals = c(0, 30), cohort_size = c(1L, 3L)) )
CohortSizeOrdinal( grade = 1L, rule = CohortSizeRange(intervals = c(0, 30), cohort_size = c(1L, 3L)) )
CohortSizeParts
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.
CohortSizeParts(cohort_sizes) .DefaultCohortSizeParts()
CohortSizeParts(cohort_sizes) .DefaultCohortSizeParts()
cohort_sizes |
( |
cohort_sizes
(integer
)
a vector of length two with two sizes, one for
part 1, and one for part 2 respectively.
Typically, end users will not use the .DefaultCohortSizeParts()
function.
# Part 1 cohort size = 1, Part 2 cohort size = 3. my_size <- CohortSizeParts(cohort_sizes = c(1, 3))
# Part 1 cohort size = 1, Part 2 cohort size = 3. my_size <- CohortSizeParts(cohort_sizes = c(1, 3))
CohortSizeRange
CohortSizeRange
is the class for cohort size based on dose range.
CohortSizeRange(intervals, cohort_size) .DefaultCohortSizeRange()
CohortSizeRange(intervals, cohort_size) .DefaultCohortSizeRange()
intervals |
( |
cohort_size |
( |
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 of intervals
.
Typically, end users will not use the .DefaultCohortSizeRange()
function.
# 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))
# 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
CrmPackClass
is a virtual class, from which all other crmPack
classes
inherit.
Calling this helper function should open the example.pdf document, residing in the doc subfolder of the package installation directory.
crmPackExample()
crmPackExample()
nothing
Daniel Sabanes Bove [email protected]
This convenience function opens your browser with the help pages for crmPack.
crmPackHelp()
crmPackHelp()
nothing
Daniel Sabanes Bove [email protected]
DADesign
This class has special requirements for the model
and data
slots in comparison to the parent class Design
:
DADesign(model, data, safetyWindow, ...) .DefaultDADesign()
DADesign(model, data, safetyWindow, ...) .DefaultDADesign()
model |
( |
data |
( |
safetyWindow |
( |
... |
Arguments passed on to
|
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)
model
(GeneralModel
)
the model to use, see in particular DALogisticLogNormal
and
TITELogisticLogNormal
which 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.
Typically, end users will not use the .DefaultDADesign()
function.
SafetyWindowConst
for creating a constant safety window.
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 )
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
DALogisticLogNormal
is the class for the logistic model with bivariate
(log) normal prior and data augmentation. This class inherits from the
LogisticLogNormal
class.
DALogisticLogNormal(npiece = 3, l, c_par = 2, cond_pem = TRUE, ...) .DefaultDALogisticLogNormal()
DALogisticLogNormal(npiece = 3, l, c_par = 2, cond_pem = TRUE, ...) .DefaultDALogisticLogNormal()
npiece |
( |
l |
( |
c_par |
( |
cond_pem |
( |
... |
Arguments passed on to
|
npiece
(number
)
the number of pieces in the PEM
.
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 = 2
is recommended.
cond_pem
(flag
)
is a conditional piecewise-exponential model used?
(default). Otherwise an unconditional model is used.
We still need to include here formula for the lambda prior.
Typically, end users will not use the .DefaultDALogisticLogNormal()
function.
ModelLogNormal
, LogisticNormal
, LogisticLogNormal
.
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 )
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 )
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.
dapply(df, f, FUN, ...)
dapply(df, f, FUN, ...)
df |
( |
f |
( |
FUN |
( |
... |
parameters passed to |
The data.frame
object with results from FUN
.
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 } )
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 } )
DASimulations
Initialization function for DASimulations
DASimulations(trialduration, ...)
DASimulations(trialduration, ...)
trialduration |
see |
... |
additional parameters from |
the DASimulations
object
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.
.DefaultDASimulations()
.DefaultDASimulations()
trialduration
the vector of trial duration values for all simulations.
Typically, end users will not use the .DASimulations()
function. This
function has a noticeable execution time.
Data
Data
is a class for the data input.
It inherits from GeneralData
.
Data( x = numeric(), y = integer(), ID = integer(), cohort = integer(), doseGrid = numeric(), placebo = FALSE, ... ) .DefaultData()
Data( x = numeric(), y = integer(), ID = integer(), cohort = integer(), doseGrid = numeric(), placebo = FALSE, ... ) .DefaultData()
x |
( |
y |
( |
ID |
( |
cohort |
( |
doseGrid |
( |
placebo |
( |
... |
not used. |
The cohort
can be missing if and only if placebo
is equal to
FALSE
.
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.t doseGrid
.
placebo
(logical
)
if TRUE
the first dose level
in the doseGrid
is considered as PLACEBO.
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.
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
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
DataDA
is a class for the time-to-DLT augmented data.
It inherits from Data
and it contains additional DLT free survival times.
DataDA( u = numeric(), t0 = numeric(length(u)), Tmax = 0 + .Machine$double.xmin, ... ) .DefaultDataDA()
DataDA( u = numeric(), t0 = numeric(length(u)), Tmax = 0 + .Machine$double.xmin, ... ) .DefaultDataDA()
u |
( |
t0 |
( |
Tmax |
( |
... |
parameters passed to |
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.
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.
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
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
DataDual
is a class for the dual endpoint data.
It inherits from Data
and it contains additional biomarker information.
DataDual(w = numeric(), ...) .DefaultDataDual()
DataDual(w = numeric(), ...) .DefaultDataDual()
w |
( |
... |
parameters passed to |
w
(numeric
)
the continuous vector of biomarker values.
Typically, end users will not use the .DefaultDataDual()
function.
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
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
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.
DataGrouped(group = character(), ...) .DefaultDataGrouped()
DataGrouped(group = character(), ...) .DefaultDataGrouped()
group |
( |
... |
parameters passed to |
group
(factor
)
whether mono
or combo
was used.
Typically, end users will not use the .DefaultDataGrouped()
function.
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
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
DataMixture
is a class for the data with mixture sharing.
It inherits from Data
and it contains additional information
on the mixture sharing.
DataMixture(xshare = numeric(), yshare = integer(), ...) .DefaultDataMixture()
DataMixture(xshare = numeric(), yshare = integer(), ...) .DefaultDataMixture()
xshare |
( |
yshare |
( |
... |
parameters passed to |
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.
Typically, end users will not use the .DefaultDataMixture()
function.
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
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
DataOrdinal
is a class for ordinal toxicity data.
It inherits from GeneralData
and it describes toxicity responses on an
ordinal rather than binary scale.
DataOrdinal( x = numeric(), y = integer(), ID = integer(), cohort = integer(), doseGrid = numeric(), placebo = FALSE, yCategories = c(`No DLT` = 0L, DLT = 1L), ... ) .DefaultDataOrdinal()
DataOrdinal( x = numeric(), y = integer(), ID = integer(), cohort = integer(), doseGrid = numeric(), placebo = FALSE, yCategories = c(`No DLT` = 0L, DLT = 1L), ... ) .DefaultDataOrdinal()
x |
( |
y |
( |
ID |
( |
cohort |
( |
doseGrid |
( |
placebo |
( |
yCategories |
(named |
... |
not used. |
The cohort
can be missing if and only if placebo
is equal to
FALSE
.
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.
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 )
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
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.
DataParts(part = integer(), nextPart = 1L, part1Ladder = numeric(), ...) .DefaultDataParts()
DataParts(part = integer(), nextPart = 1L, part1Ladder = numeric(), ...) .DefaultDataParts()
part |
( |
nextPart |
( |
part1Ladder |
( |
... |
parameters passed to |
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 the doseGrid
.
Typically, end users will not use the .DefaultDataParts()
function.
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
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
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.
Design(model, stopping, increments, pl_cohort_size = CohortSizeConst(0L), ...) .DefaultDesign()
Design(model, stopping, increments, pl_cohort_size = CohortSizeConst(0L), ...) .DefaultDesign()
model |
( |
stopping |
( |
increments |
( |
pl_cohort_size |
( |
... |
Arguments passed on to
|
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).
Typically, end users will not use the .DefaultDesign()
function.
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 )
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
DesignGrouped
combines two Design
objects: one for the mono and one
for the combo arm of a joint dose escalation design.
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, ... )
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, ... )
model |
( |
mono |
( |
combo |
( |
first_cohort_mono_only |
( |
same_dose_for_all |
( |
same_dose_for_start |
( |
stop_mono_with_combo |
( |
... |
not used. |
Note that the model slots inside the mono
and combo
parameters
are ignored (because we don't fit separate regression models for the mono and
combo arms). Instead, the model
parameter is used to fit a joint regression
model for the mono and combo arms together.
same_dose_for_start = TRUE
is useful as an option when we want to use same_dose_for_all = FALSE
combined with first_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.
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 from same_dose_for_all
which will always force
them to be the same. If same_dose_for_all = TRUE
, this is therefore ignored. See Details.
Typically, end-users will not use the .DefaultDesignGrouped()
function.
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 )
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
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.
DesignOrdinal( model, stopping, increments, pl_cohort_size = CohortSizeOrdinal(1L, CohortSizeConst(0L)), ... ) .DefaultDesignOrdinal()
DesignOrdinal( model, stopping, increments, pl_cohort_size = CohortSizeOrdinal(1L, CohortSizeConst(0L)), ... ) .DefaultDesignOrdinal()
model |
( |
stopping |
( |
increments |
( |
pl_cohort_size |
( |
... |
Arguments passed on to
|
model
(LogisticLogNormalOrdinal
)
the model to be used.
stopping
(StoppingOrdinal
)
stopping rule(s) for the trial.
increments
(IncrementsOrdinal
)
how to control increments between dose levels.
pl_cohort_size
(CohortSizeOrdinal
)
rules for the cohort sizes for placebo,
if any planned (defaults to constant 0 placebo patients).
Typically, end users will not use the .DefaultDesignOrdinal()
function.
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 )
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 )
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).
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)
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)
x |
( |
model |
( |
samples |
( |
... |
model specific parameters when |
grade |
( |
group |
( |
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
.
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
.
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 LogisticLogNormalOrdinal
model, dose
returns 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 for LogisticLogNormalGrouped
which needs group
argument 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 (except x
) should be present in the model
object.
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 (except x
) should be present in the model
object.
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 method x
must
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
).
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.
doseFunction()
, prob()
, efficacy()
.
# 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)
# 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)
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.
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)
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)
object |
( |
... |
further arguments passed to class-specific methods. |
ignore_placebo |
( |
A numeric
vector containing the minimum and maximum of all the
doses in a grid or c(-Inf, Inf)
.
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)
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)
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.
doseFunction(model, ...) ## S4 method for signature 'GeneralModel' doseFunction(model, ...) ## S4 method for signature 'ModelPseudo' doseFunction(model, ...) ## S4 method for signature 'LogisticLogNormalOrdinal' doseFunction(model, grade, ...)
doseFunction(model, ...) ## S4 method for signature 'GeneralModel' doseFunction(model, ...) ## S4 method for signature 'ModelPseudo' doseFunction(model, ...) ## S4 method for signature 'LogisticLogNormalOrdinal' doseFunction(model, grade, ...)
model |
( |
... |
model specific parameters. |
grade |
( |
A dose()
method that computes doses.
doseFunction(GeneralModel)
:
doseFunction(ModelPseudo)
:
doseFunction(LogisticLogNormalOrdinal)
:
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)
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)
DualDesign
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
.
DualDesign(model, data, ...) .DefaultDualDesign()
DualDesign(model, data, ...) .DefaultDualDesign()
model |
( |
data |
( |
... |
Arguments passed on to
|
model
(DualEndpoint
)
the model to be used.
data
(DataDual
)
specifies dose grid, any previous data, etc.
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.
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 )
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
DualEndpoint
is the general class for the dual endpoint model.
DualEndpoint(mean, cov, ref_dose = 1, use_log_dose = FALSE, sigma2W, rho) .DefaultDualEndpoint()
DualEndpoint(mean, cov, ref_dose = 1, use_log_dose = FALSE, sigma2W, rho) .DefaultDualEndpoint()
mean |
( |
cov |
( |
ref_dose |
( |
use_log_dose |
( |
sigma2W |
( |
rho |
( |
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
or
in case when the option use_log_dose
is TRUE
.
Here, is the probability of observing a DLT for a given
dose
and
is the reference dose.
The prior
For the biomarker response at a dose
, we assume
where is a function of the dose
, which is further
specified in sub-classes. The biomarker variance
can be fixed
or assigned an Inverse-Gamma prior distribution; see the details below under
slot
sigma2W
.
Finally, the two endpoints (the binary DLT variable) and
(the biomarker) can be correlated, by assuming a correlation of level
between the underlying continuous latent toxicity variable
and the biomarker
. 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.
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 named
a
and b
.
rho
(numeric
)
either a fixed value for the correlation
(between -1
and 1
), or a named vector with two elements named a
and b
for the Beta prior on the transformation kappa = (rho + 1) / 2
, which is
in (0, 1)
. For example, a = 1, b = 1
leads to a uniform prior on rho
.
use_fixed
(logical
)
indicates whether a fixed value for sigma2W
or rho
(for each parameter separately) is used or not. This slot is
needed for internal purposes and must not be touched by the user.
Typically, end users will not use the .DefaultDualEndpoint()
function.
DualEndpointRW
, DualEndpointBeta
, DualEndpointEmax
.
DualEndpointBeta
DualEndpointBeta
is the class for the dual endpoint model with beta
function for dose-biomarker relationship.
DualEndpointBeta(E0, Emax, delta1, mode, ref_dose_beta = 1, ...) .DefaultDualEndpointBeta()
DualEndpointBeta(E0, Emax, delta1, mode, ref_dose_beta = 1, ...) .DefaultDualEndpointBeta()
E0 |
( |
Emax |
( |
delta1 |
( |
mode |
( |
ref_dose_beta |
( |
... |
parameters passed to |
This class extends the DualEndpoint
class so that the dose-biomarker
relationship is modelled by a parametric, rescaled beta density
function:
where is the maximum dose (end of the dose range to be considered),
and
are the two beta function parameters, and
,
are the minimum and maximum levels, respectively.
For ease of interpretation, we use the parametrization based on
and the mode, where
so that multiplying this by 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.
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 dose (note
that this is different from the
ref_dose
in the inherited DualEndpoint
model).
Typically, end users will not use the .DefaultDualEndpointBeta()
function.
DualEndpoint
, DualEndpointRW
, DualEndpointEmax
.
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 )
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
DualEndpointEmax
is the class for the dual endpoint model with Emax
function for dose-biomarker relationship.
DualEndpointEmax(E0, Emax, ED50, ref_dose_emax = 1, ...) .DefaultDualEndpointEmax()
DualEndpointEmax(E0, Emax, ED50, ref_dose_emax = 1, ...) .DefaultDualEndpointEmax()
E0 |
( |
Emax |
( |
ED50 |
( |
ref_dose_emax |
( |
... |
parameters passed to |
This class extends the DualEndpoint
class so that the dose-biomarker
relationship is modelled by a parametric
Emax
function:
where is a reference dose,
and
are the minimum
and maximum levels for the biomarker, and
is the dose achieving
half of the maximum effect
.
All parameters can currently be assigned uniform distributions or be fixed.
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 dose (note
that this is different from the
ref_dose
in the inherited DualEndpoint
model).
Typically, end users will not use the .DefaultDualEndpointEmax()
function.
DualEndpoint
, DualEndpointRW
, DualEndpointBeta
.
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 )
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
DualEndpointRW
is the class for the dual endpoint model with random walk
prior for biomarker.
DualEndpointRW(sigma2betaW, rw1 = TRUE, ...) .DefaultDualEndpointRW()
DualEndpointRW(sigma2betaW, rw1 = TRUE, ...) .DefaultDualEndpointRW()
sigma2betaW |
( |
rw1 |
( |
... |
parameters passed to |
This class extends the DualEndpoint
class so that the dose-biomarker
relationship is modelled by a non-parametric random walk of first
or second order. That means, for the first order random walk we assume
where is the biomarker mean at the
-th dose
gridpoint
.
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
mean and
variance.
The variance parameter is important because it steers the
smoothness of the function
, i.e.: if it is large, then
will be very wiggly; if it is small, then
will be smooth.
This parameter can either be a fixed value or assigned an inverse gamma prior
distribution.
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 named a
and b
.
rw1
(flag
)
for specifying the random walk prior on the biomarker
level. When TRUE
, random walk of first order is used. Otherwise, the
random walk of second order is used.
Non-equidistant dose grids can be used now, because the difference
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.
DualEndpoint
, DualEndpointBeta
, DualEndpointEmax
.
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 )
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
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.
DualResponsesDesign(eff_model, data, ...) .DefaultDualResponsesDesign()
DualResponsesDesign(eff_model, data, ...) .DefaultDualResponsesDesign()
eff_model |
( |
data |
( |
... |
Arguments passed on to
|
data
(DataDual
)
the data set.
eff_model
(ModelEff
)
the pseudo efficacy model to be used.
Typically, end users will not use the .DefaultDualResponsesDesign()
function.
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 )
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
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.
DualResponsesSamplesDesign(eff_model, data, ...) .DefaultDualResponsesSamplesDesign()
DualResponsesSamplesDesign(eff_model, data, ...) .DefaultDualResponsesSamplesDesign()
eff_model |
( |
data |
( |
... |
Arguments passed on to
|
data
(DataDual
)
the data set.
eff_model
(ModelEff
)
the pseudo efficacy model to be used.
Typically, end users will not use the .DefaultDualResponsesSamplesDesign()
function.
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 )
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
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.
DualSimulations(rho_est, sigma2w_est, fit_biomarker, ...) .DefaultDualSimulations()
DualSimulations(rho_est, sigma2w_est, fit_biomarker, ...) .DefaultDualSimulations()
rho_est |
( |
sigma2w_est |
( |
fit_biomarker |
( |
... |
additional parameters from |
rho_est
(numeric
)
vector of final posterior median rho estimates
sigma2w_est
(numeric
)
vector of final posterior median sigma2W estimates
fit_biomarker
(list
)
with the final dose-biomarker curve fits
Typically, end users will not use the .DefaultDualSimulations()
function.
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 )
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
This class captures the summary of dual-endpoint simulations output.
In comparison to its parent class SimulationsSummary
, it has additional slots.
.DefaultDualSimulationsSummary()
.DefaultDualSimulationsSummary()
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
Typically, end users will not use the .DefaultDualSimulationsSummary()
function.
EffFlexi
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
where is a vector of the efficacy responses,
is a column
vector of the mean efficacy responses for all dose levels, and
is
the design matrix with entries
that are equal to 1 if subject
is allocated to dose
, and
otherwise. The
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
and for RW2 as
where is the vector of mean efficacy responses at dose j, and
the
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.
EffFlexi(eff, eff_dose, sigma2W, sigma2betaW, rw1 = TRUE, data) .DefaultEffFlexi()
EffFlexi(eff, eff_dose, sigma2W, sigma2betaW, rw1 = TRUE, data) .DefaultEffFlexi()
eff |
( |
eff_dose |
( |
sigma2W |
( |
sigma2betaW |
( |
rw1 |
( |
data |
( |
This model will output the updated value or the updated values of the
parameters of the inverse gamma distributions for and
. The
EffFlexi
inherits all slots from ModelEff
class.
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 in eff_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 in eff
.
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 for
sigma2W
and sigma2betaW
(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
is TRUE
, 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.
Typically, end users will not use the .DefaultEffFlexi()
function.
# 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 )
# 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 )
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).
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)
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)
dose |
( |
model |
( |
samples |
( |
... |
model specific parameters when |
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
.
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
.
efficacy(dose = numeric, model = Effloglog, samples = Samples)
: compute the expected efficacy at a specified dose level,
based on the samples of Effloglog
model parameters.
efficacy(dose = numeric, model = Effloglog, samples = missing)
: compute the expected efficacy at a specified dose level,
based on the Effloglog
model parameters.
All model parameters (except dose
) should be present in the model
object.
efficacy(dose = numeric, model = EffFlexi, samples = Samples)
: compute the expected efficacy at a specified dose level,
based on the samples of EffFlexi
model parameters. If a given dose in
the dose
vector is from outside of the dose grid range, the NA_real
is
returned for this dose and the warning is thrown.
# 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)
# 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)
A function that returns an efficacy()
function that computes expected
efficacy for a given dose level, based on the model specific parameters.
efficacyFunction(model, ...) ## S4 method for signature 'ModelEff' efficacyFunction(model, ...)
efficacyFunction(model, ...) ## S4 method for signature 'ModelEff' efficacyFunction(model, ...)
model |
( |
... |
model specific parameters. |
A efficacy()
function that computes expected efficacy.
efficacyFunction(ModelEff)
:
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)
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)
Effloglog
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
where is the efficacy response for subject
,
is
the dose level treated for subject
and
is the random
error term of efficacy model at subject
. The error term
is a random variable that follows normal distribution with
mean
and variance
, which is assumed to be the
same for all subjects.
There are three parameters in this model, the intercept
, the
slope
and the precision
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.
Effloglog(eff, eff_dose, nu, data, const = 0) .DefaultEffloglog()
Effloglog(eff, eff_dose, nu, data, const = 0) .DefaultEffloglog()
eff |
( |
eff_dose |
( |
nu |
( |
data |
( |
const |
( |
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 and the slope
of this model follows bivariate normal distribution with mean
and covariance matrix
.
The mean
is a
column vector that contains the prior
modal estimates of the intercept and the slope.
Scalar
is the precision of the pseudo efficacy responses and
is the prior or posterior (given that observed, no DLT data is
available) precision matrix.
It is specified as
, where
is a
design matrix that is based on pseudo dose levels only, and
is a
design matrix that is based on dose levels corresponding to the no DLT
efficacy responses observed only (if any).
Hence, the
(or
) will be of size
, if
there are
pseudo efficacy responses specified (or
if there are
no DLT efficacy responses observed in the
data
).
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 in eff_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 in eff
.
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 whether nu
specified 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 the covariance matrix of the
estimators of the intercept
and the slope
parameters in this model.
This is used in output to display the resulting prior and posterior
covariance matrix of
and
obtained, 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 () and the slope (
).
This slot is used in output to display as the mean of the prior or posterior
bivariate normal distribution for
and
.
Q
(matrix
)
is the prior or posterior (given that observed, no DLT
data is available) precision matrix. It is specified as
, where
is a design matrix that is
based on pseudo dose levels only, and
is 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 form
, such that
dose levels greater than
can be considered as described in
Yeung et al. (2015).
Typically, end users will not use the .DefaultEffloglog()
function.
# 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 )
# 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 )
A family of wrappers of selected futile.logger
functions that control
the logging mechanism in crmPack
. The crmPack
uses 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
.
enable_logging() disable_logging() is_logging_enabled() log_trace(msg, ..., capture = FALSE)
enable_logging() disable_logging() is_logging_enabled() log_trace(msg, ..., capture = FALSE)
msg |
The message to log |
... |
Optional arguments to populate the format string |
capture |
Capture print output of variables instead of interpolate |
enable_logging()
: A simple wrapper of
futile.logger::flog.threshold()
that enables crmPack
verbose logging by
setting logging threshold to futile.logger::TRACE
for crmPack
logger.
disable_logging()
: A simple wrapper of
futile.logger::flog.threshold()
that disables crmPack
verbose logging
by setting logging threshold to futile.logger::FATAL
for crmPack
logger.
is_logging_enabled()
: A simple wrapper of
futile.logger::flog.logger()
that checks whether current threshold level
for crmPack
logger is verbose, which is futile.logger::TRACE
.
It returns TRUE
if the current logging level is verbose, FALSE
otherwise.
log_trace()
: A simple wrapper of
futile.logger::flog.trace()
that prints a log message in the crmPack
logger.
This generic function takes a design and generates a dataframe showing the beginning of several hypothetical trial courses under the design. This means, from the generated dataframe one can read off:
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.
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)
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)
object |
the design ( |
... |
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 |
object of class |
The data frame
examine(Design)
: Examine a model-based CRM
examine(RuleDesign)
: Examine a rule-based design
examine(DADesign)
: Examine a model-based CRM
# 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
# 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
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.
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, ... )
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, ... )
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:
|
the data frame with required information (see method details)
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
# 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)
# 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
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, ... )
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, ... )
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:
|
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
##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)
##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)
PEM
curve. If hazard=TRUE,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,
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, ... )
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, ... )
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 |
fitPEM(object = Samples, model = DALogisticLogNormal, data = DataDA)
: This method works for the DALogisticLogNormal
model class.
# 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
# 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
FractionalCRM
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 Guosheng Yin et al.
FractionalCRM(...) .DefaultFractionalCRM()
FractionalCRM(...) .DefaultFractionalCRM()
... |
Arguments passed on to
|
Typically, end users will not use the .DefaultTITELogisticLogNormal()
function.
my_model <- FractionalCRM( skel_probs = c(0.1, 0.2, 0.3, 0.4), dose_grid = c(10, 30, 50, 100), sigma2 = 2 )
my_model <- FractionalCRM( skel_probs = c(0.1, 0.2, 0.3, 0.4), dose_grid = c(10, 30, 50, 100), sigma2 = 2 )
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, ...)
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, ...)
dose |
( |
model_dle |
( |
samples_dle |
( |
model_eff |
( |
samples_eff |
( |
... |
not used. |
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.
The gain values.
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.
# 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 )
# 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 )
GeneralData
GeneralData
is a class for general data input.
.DefaultDataGeneral()
.DefaultDataGeneral()
ID
(integer
)
unique patient IDs.
cohort
(integer
)
the cohort (non-negative sorted) indices.
nObs
(integer
)
number of observations, a single value.
Typically, end users will not use the .DefaultDataGeneral()
function.
GeneralModel
GeneralModel
is a general model class, from which all other specific
model-like classes inherit.
.DefaultGeneralModel()
.DefaultGeneralModel()
datamodel
(function
)
a function representing the JAGS
data model
specification.
priormodel
(function
)
a function representing the JAGS
prior
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) argument from_prior
of type logical
and length one. This
from_prior
flag can be used to differentiate the output of the modelspecs
,
as its value is taken directly from the from_prior
argument of the mcmc
method that invokes modelspecs
function. That is, when from_prior
is
TRUE
, then only priormodel
JAGS model is used (datamodel
is not used)
by the mcmc
, and hence modelspecs
function should return all the parameters
that are required by the priormodel
only. If the value of from_prior
is
FALSE
, then both JAGS models datamodel
and priormodel
are used in the
MCMC sampler, and hence modelspecs
function should return all the parameters
required by both datamodel
and priormodel
.
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
by datamodel
JAGS function. No other names should be specified here.
datanames_prior
(character
)
the names of all data slots that are
used by priormodel
JAGS function. No other names should be specified here.
sample
(character
)
names of all parameters from which you would
like to save the MCMC samples.
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.
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
.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
.
GeneralSimulations(data, doses, seed) .DefaultGeneralSimulations()
GeneralSimulations(data, doses, seed) .DefaultGeneralSimulations()
data |
( |
doses |
( |
seed |
( |
data
(list
)
produced Data
objects.
doses
(numeric
)
final dose recommendations.
seed
(integer
)
random generator state before starting the simulation.
Typically, end users will not use the .DefaultGeneralSimulations()
function.
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)
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
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.
.DefaultGeneralSimulationsSummary() .DefaultPseudoSimulationsSummary()
.DefaultGeneralSimulationsSummary() .DefaultPseudoSimulationsSummary()
target
(numeric
)
target toxicity interval
target_dose_interval
(numeric
)
corresponding target dose interval
nsim
(integer
)
number of simulations
prop_dlts
(ANY
)
A numeric array (multi-dimensional) or list representing proportions of DLTs in the trials
mean_tox_risk
(numeric
)
mean toxicity risks for the patients
dose_selected
(numeric
)
doses selected as MTD
tox_at_doses_selected
(numeric
)
true toxicity at doses selected
prop_at_target
(numeric
)
Proportion of trials selecting target MTD
dose_most_selected
(numeric
)
dose most often selected as MTD
obs_tox_rate_at_dose_most_selected
(numeric
)
observed toxicity rate at dose most often selected
n_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 interval
dose_grid
(numeric
)
the dose grid that has been used
placebo
(logical
)
set to TRUE (default is FALSE) for a design with placebo
Typically, end users will not use the .DefaultGeneralSimulationsSummary()
function.
Typically, end users will not use the .DefaultPseudoSimulationsSummary()
function.
Here you have to specify with pos
which
parameter you would like to extract from the Samples
object
## S4 method for signature 'Samples,character' get(x, pos = -1L, envir = NULL, mode = NULL, inherits = NULL)
## S4 method for signature 'Samples,character' get(x, pos = -1L, envir = NULL, mode = NULL, inherits = NULL)
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 |
the data frame suitable for use with ggmcmc
# 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
# 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
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.
getEff(object, ...) ## S4 method for signature 'DataDual' getEff(object, no_dlt = FALSE)
getEff(object, ...) ## S4 method for signature 'DataDual' getEff(object, no_dlt = FALSE)
object |
( |
... |
further arguments passed to class-specific methods. |
no_dlt |
( |
list
with efficacy responses categorized by the DLT value.
# 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)
# 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)
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.
h_all_equivalent(target, current, tolerance = 1e-10)
h_all_equivalent(target, current, tolerance = 1e-10)
target |
( |
current |
( |
tolerance |
( |
TRUE
when target
and current
do not differ
up to desired tolerance and without looking at names or other attributes,
FALSE
otherwise.
Helper Function to Blind Plot Data
h_blind_plot_data(df, blind, has_placebo, pbo_dose)
h_blind_plot_data(df, blind, has_placebo, pbo_dose)
df |
( |
blind |
( |
has_placebo |
( |
pbo_dose |
( |
The blinded data
show()
and output with cat to consoleHelper 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
h_calc_report_label_percentage(stop_report)
h_calc_report_label_percentage(stop_report)
stop_report |
object from summary method |
named list with label and percentage of rule activation
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.
h_check_fun_formals(fun, mandatory = NULL, allowed = NULL)
h_check_fun_formals(fun, mandatory = NULL, allowed = NULL)
fun |
( |
mandatory |
( |
allowed |
( |
A simple helper function that takes a DataOrdinal
object and an
integer grade and converts them to the equivalent Data
object.
h_convert_ordinal_data(data_ord, grade)
h_convert_ordinal_data(data_ord, grade)
data_ord |
( |
grade |
( |
A Data
object.
A simple helper function that takes a LogisticLogNormalOrdinal
and an
integer grade and converts them to the equivalent LogisticLogNormal
model.
h_convert_ordinal_model(x, grade)
h_convert_ordinal_model(x, grade)
x |
( |
grade |
( |
A LogisticLogNormal
model.
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.
h_convert_ordinal_samples(obj, grade)
h_convert_ordinal_samples(obj, grade)
obj |
( |
grade |
( |
A Samples
object.
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
.
h_default_if_empty(x, default)
h_default_if_empty(x, default)
x |
( |
default |
( |
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")
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")
A simple wrapper of findInterval()
function that invokes
findInterval()
, takes its output and replaces all the
elements with value to a custom number as specified in
replacement
argument.
h_find_interval(..., replacement = -Inf)
h_find_interval(..., replacement = -Inf)
... |
Arguments passed on to
|
replacement |
( |
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)
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)
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.
h_format_number(x, digits = 5, prefix = "", suffix = "")
h_format_number(x, digits = 5, prefix = "", suffix = "")
x |
( |
digits |
( |
prefix |
( |
suffix |
( |
Either formatted x
as string
or unchanged x
if the
formatting condition is not met.
This function was primarily designed as a helper for
h_jags_write_model()
function.
h_format_number(50000) h_format_number(50000, prefix = "P", suffix = "S")
h_format_number(50000) h_format_number(50000, prefix = "P", suffix = "S")
A simple helper function that tests whether elements of a given vector or matrix are within specified interval.
h_in_range(x, range = c(0, 1), bounds_closed = TRUE)
h_in_range(x, range = c(0, 1), bounds_closed = TRUE)
x |
( |
range |
( |
bounds_closed |
( |
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
.
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))
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))
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.
h_info_theory_dist(prob, target, asymmetry)
h_info_theory_dist(prob, target, asymmetry)
prob |
( |
target |
( |
asymmetry |
( |
h_info_theory_dist(c(0.5, 0.2), 0.4, 1.2)
h_info_theory_dist(c(0.5, 0.2), 0.4, 1.2)
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.
h_is_positive_definite(x, size = 2, tol = 1e-08)
h_is_positive_definite(x, size = 2, tol = 1e-08)
x |
( |
size |
( |
tol |
( |
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
.
TRUE
if a given matrix is a positive-definite, FALSE
otherwise.
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.
h_jags_add_dummy(object, where, dummy = 0)
h_jags_add_dummy(object, where, dummy = 0)
object |
( |
where |
( |
dummy |
( |
A GeneralData
object with slots updated with dummy number.
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.
# 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"))
# 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"))
JAGS
mcarray
ObjectA 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.
h_jags_extract_samples(x)
h_jags_extract_samples(x)
x |
an |
JAGS
A simple helper function that prepares an object for data
argument of
rjags::jags.model()
, which is invoked by mcmc()
method.
h_jags_get_data(model, data, from_prior)
h_jags_get_data(model, data, from_prior)
model |
( |
data |
( |
from_prior |
( |
# 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
# 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
JAGS
Model ParametersA 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.
h_jags_get_model_inits(model, data)
h_jags_get_model_inits(model, data)
model |
( |
data |
( |
A list
of starting values for parameters required to be initialized
in the MCMC JAGS
sampler.
# 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)
# 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)
JAGS
ModelsThis 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.
h_jags_join_models(model1, model2)
h_jags_join_models(model1, model2)
model1 |
( |
model2 |
( |
joined models.
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.
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.
h_jags_write_model(model, file = NULL, digits = 5)
h_jags_write_model(model, file = NULL, digits = 5)
model |
( |
file |
( |
digits |
( |
The name of the file where the model was saved.
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.
# Some model function my_model <- function() { alpha0 <- mean(1:10) alpha1 <- 600000 } h_jags_write_model(my_model, digits = 5)
# Some model function my_model <- function() { alpha0 <- mean(1:10) alpha1 <- 600000 } h_jags_write_model(my_model, digits = 5)
DualEndpoint
model with regard to parameters
of the function that models dose-biomarker relationship defined in the
DualEndpointBeta
class.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 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 .
See the help page for
DualEndpointBeta
class for more details.
h_model_dual_endpoint_beta( param, param_name, param_suffix = c("_low", "_high"), priormodel = NULL, de )
h_model_dual_endpoint_beta( param, param_name, param_suffix = c("_low", "_high"), priormodel = NULL, de )
param |
( |
param_name |
( |
param_suffix |
( |
priormodel |
( |
de |
( |
A DualEndpoint
model with updated use_fixed
, priormodel
,
modelspecs
, init
, sample
slots.
DualEndpoint
class model components with regard to DLT and biomarker
correlation.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
.
h_model_dual_endpoint_rho(use_fixed, rho, comp)
h_model_dual_endpoint_rho(use_fixed, rho, comp)
use_fixed |
( |
rho |
( |
comp |
( |
A list
with updated model components.
DualEndpoint
model with regard to prior variance
factor of the random walk.A simple helper function that takes DualEndpoint
object and updates
priormodel
, modelspecs
, init
, sample
slots according to the random walk
variance.
h_model_dual_endpoint_sigma2betaW(use_fixed, sigma2betaW, de)
h_model_dual_endpoint_sigma2betaW(use_fixed, sigma2betaW, de)
use_fixed |
( |
sigma2betaW |
( |
de |
( |
A DualEndpoint
model with updated priormodel
, modelspecs
,
init
, sample
slots.
DualEndpoint
class model components with regard to biomarker
regression variance.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
.
h_model_dual_endpoint_sigma2W(use_fixed, sigma2W, comp)
h_model_dual_endpoint_sigma2W(use_fixed, sigma2W, comp)
use_fixed |
( |
sigma2W |
( |
comp |
( |
list
with updated model components.
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
it then excluded from the eligible doses.
h_next_best_eligible_doses(dose_grid, doselimit, placebo, levels = FALSE)
h_next_best_eligible_doses(dose_grid, doselimit, placebo, levels = FALSE)
dose_grid |
( |
doselimit |
( |
placebo |
( |
levels |
( |
A numeric vector with eligible doses or eligible dose levels if levels
flag is TRUE
.
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)
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)
nextBest-NextBestMaxGain
Method.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.
h_next_best_mg_ci(dose_target, dose_mg, prob_target, placebo, model, model_eff)
h_next_best_mg_ci(dose_target, dose_mg, prob_target, placebo, model, model_eff)
dose_target |
( |
dose_mg |
( |
prob_target |
( |
placebo |
( |
model |
( |
model_eff |
( |
Yeung, W.Y., Whitehead, J., Reigner, B., Beyer, U., Diack, Ch., Jaki, T. (2015),
Bayesian adaptive dose-escalation procedures for binary and continuous responses utilizing a gain function,
Pharmaceutical Statistics,
doi:10.1002/pst.1706
nextBest-NextBestMaxGain
Method.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: ,
dose_mg
, dose_target_drt
or dose_target_eot
.
h_next_best_mg_doses_at_grid( dose_target_drt, dose_target_eot, dose_mg, dose_grid, doselimit, placebo )
h_next_best_mg_doses_at_grid( dose_target_drt, dose_target_eot, dose_mg, dose_grid, doselimit, placebo )
dose_target_drt |
( |
dose_target_eot |
( |
dose_mg |
( |
dose_grid |
( |
doselimit |
( |
placebo |
( |
nextBest-NextBestMaxGain
Method.Helper function which creates the plot for nextBest-NextBestMaxGain()
method.
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 )
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 )
prob_target_drt |
( |
dose_target_drt |
( |
prob_target_eot |
( |
dose_target_eot |
( |
dose_mg |
( |
max_gain |
( |
next_dose |
( |
doselimit |
( |
data |
( |
model |
( |
model_eff |
( |
nextBest-NextBestMaxGainSamples
Method.Helper function which creates the plot for nextBest-NextBestMaxGainSamples()
method.
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 )
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 )
prob_target_drt |
( |
dose_target_drt |
( |
prob_target_eot |
( |
dose_target_eot |
( |
dose_mg |
( |
dose_mg_samples |
( |
next_dose |
( |
doselimit |
( |
dose_grid_range |
( |
nextBest-NextBestNCRMLoss
Method.Helper function which creates the plot for nextBest-NextBestNCRMLoss()
method.
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 )
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 )
prob_mat |
( |
posterior_loss |
( |
max_overdose_prob |
( |
dose_grid |
( |
max_eligible_dose_level |
( |
doselimit |
( |
next_dose |
( |
is_unacceptable_specified |
( |
nextBest-NextBestTD
Method.Helper function which creates the plot for nextBest-NextBestTD()
method.
h_next_best_td_plot( prob_target_drt, dose_target_drt, prob_target_eot, dose_target_eot, data, prob_dlt, doselimit, next_dose )
h_next_best_td_plot( prob_target_drt, dose_target_drt, prob_target_eot, dose_target_eot, data, prob_dlt, doselimit, next_dose )
prob_target_drt |
( |
dose_target_drt |
( |
prob_target_eot |
( |
dose_target_eot |
( |
data |
( |
prob_dlt |
( |
doselimit |
( |
next_dose |
( |
nextBest-NextBestTDsamples
Method.Helper function which creates the plot for nextBest-NextBestTDsamples()
method.
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 )
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 )
dose_target_drt_samples |
( |
dose_target_eot_samples |
( |
dose_target_drt |
( |
dose_target_eot |
( |
dose_grid_range |
( |
nextBest |
( |
doselimit |
( |
next_dose |
( |
NULL
for NA
A simple helper function that replaces NA
object by NULL
object.
h_null_if_na(x)
h_null_if_na(x)
x |
( |
NULL
if x
is NA
, otherwise, x
.
h_null_if_na(NA)
h_null_if_na(NA)
Used by dose_grid_range-Data
and dose_grid_range-DataOrdinal
h_obtain_dose_grid_range(object, ignore_placebo)
h_obtain_dose_grid_range(object, ignore_placebo)
object |
( |
ignore_placebo |
( |
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.
h_plot_data_cohort_lines(cohort, placebo, vertical = TRUE)
h_plot_data_cohort_lines(cohort, placebo, vertical = TRUE)
cohort |
( |
placebo |
( |
vertical |
( |
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.
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.
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, ... )
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, ... )
x |
( |
blind |
( |
legend |
( |
tox_labels |
( |
tox_shapes |
( |
... |
not used. |
y |
( |
The ggplot2
object.
The ggplot2
object.
The ggplot2
object.
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.
# 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)
# 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)
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
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, ...)
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, ...)
data |
( |
... |
further arguments passed to |
blind |
( |
legend |
( |
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.
h_plot_data_df(Data)
: method for Data
.
h_plot_data_df(DataOrdinal)
: Class specific method for DataOrdinal
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.
h_rapply(x, fun, classes, ...)
h_rapply(x, fun, classes, ...)
x |
( |
fun |
( |
classes |
( |
... |
further arguments passed to function |
"list-like" object of similar structure as x
.
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.
# 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" )
# 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" )
This helper function extracts requested slots from the S4 class object.
It is a simple wrapper of methods::slot()
function.
h_slots(object, names, simplify = FALSE)
h_slots(object, names, simplify = FALSE)
object |
( |
names |
( |
simplify |
( |
list
with the slots extracted from object
according to names
,
or single slot if simplification is required and possible.
show()
and output with cat to consoleHelper 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
h_summarize_add_stats(stats_list)
h_summarize_add_stats(stats_list)
stats_list |
object from simulation with nested parameter values (sublist for each parameter) |
list of parameter names and averaged values for console output
A simple helper function that tests whether an object is a named numerical vector.
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, ... )
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, ... )
x |
( |
subset.of |
[ |
must.include |
[ |
permutation.of |
[ |
identical.to |
[ |
disjunct.from |
[ |
lower |
[ |
finite |
[ |
any.missing |
[ |
len |
[ |
... |
further parameters passed to |
TRUE
if x
is a named vector of type numeric, otherwise FALSE
.
This function is based on checkmate::test_numeric()
and
checkmate::test_names()
functions.
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"))
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 recursively unpack stopping rules and return lists with logical value and label given
h_unpack_stopit(stopit_tree)
h_unpack_stopit(stopit_tree)
stopit_tree |
object from simulate method |
named list
A simple helper function that combines two outputs from calls to result()
function which is placed in a slot of Validate()
reference class.
h_validate_combine_results(v1, v2)
h_validate_combine_results(v1, v2)
v1 |
( |
v2 |
( |
h_validate_combine_results(TRUE, "some_message")
h_validate_combine_results(TRUE, "some_message")
Helper Function performing validation Common to Data and DataOrdinal
h_validate_common_data_slots(object)
h_validate_common_data_slots(object)
object |
( |
a Validate
object containing the result of the validation
Increments
Increments
is a virtual class for controlling increments, from which all
other specific increments classes inherit.
.DefaultIncrements()
.DefaultIncrements()
Typically, end users will not use the .DefaultIncrements()
function.
IncrementsRelative
, IncrementsRelativeDLT
,
IncrementsDoseLevels
, IncrementsHSRBeta
, IncrementsMin
.
IncrementsDoseLevels
IncrementsDoseLevels
is the class for increments control based on the
number of dose levels.
IncrementsDoseLevels(levels = 1L, basis_level = "last") .DefaultIncrementsDoseLevels()
IncrementsDoseLevels(levels = 1L, basis_level = "last") .DefaultIncrementsDoseLevels()
levels |
( |
basis_level |
( |
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 (see basis_level
parameter).
basis_level
(string
)
defines the current base dose level. It can
take one out of two possible values: last
or max
.
If last
is specified (default), the current base dose level is set to the
last dose given. If max
is specified, then the current base dose level is
set to the maximum dose level given.
Typically, end users will not use the .DefaultIncrementsDoseLevels()
function.
# 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")
# 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
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.
IncrementsHSRBeta(target = 0.3, prob = 0.95, a = 1, b = 1) .DefaultIncrementsHSRBeta()
IncrementsHSRBeta(target = 0.3, prob = 0.95, a = 1, b = 1) .DefaultIncrementsHSRBeta()
target |
( |
prob |
( |
a |
( |
b |
( |
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 parameter of probability distribution
Beta (a,b).
b
(number
)
shape parameter of probability distribution
Beta (a,b).
Typically, end users will not use the .DefaultIncrementsHSRBeta()
function.
# 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)
# 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
IncrementsMaxToxProb
is the class for increments control based on
probability of toxicity
IncrementsMaxToxProb(prob) .DefaultIncrementsMaxToxProb()
IncrementsMaxToxProb(prob) .DefaultIncrementsMaxToxProb()
prob |
( |
prob
(numeric
)
See Usage Notes below.
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.
Typically, end users will not use the .DefaultIncrementsMaxToxProb()
function.
# 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))
# 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
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.
IncrementsMin(increments_list) .DefaultIncrementsMin()
IncrementsMin(increments_list) .DefaultIncrementsMin()
increments_list |
( |
increments_list
(list
)
list with increment rules.
Typically, end users will not use the .DefaultIncrementsMin()
function.
# 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) )
# 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
IncrementsOrdinal
is the class for applying a standard Increments
rule to
the results of an ordinal CRM trial.
IncrementsOrdinal(grade, rule) .DefaultIncrementsOrdinal()
IncrementsOrdinal(grade, rule) .DefaultIncrementsOrdinal()
grade |
( |
rule |
( |
grade
(integer
)
the toxicity grade to which the rule
should be
applied.
rule
(Increments
)
the standard Increments
rule to be applied
Typically, end users will not use the .DefaultIncrementsOrdinal()
function.
IncrementsOrdinal( grade = 1L, rule = IncrementsRelative( intervals = c(0, 20), increments = c(1, 0.33) ) )
IncrementsOrdinal( grade = 1L, rule = IncrementsRelative( intervals = c(0, 20), increments = c(1, 0.33) ) )
IncrementsRelative
IncrementsRelative
is the class for increments control based on relative
differences in intervals.
IncrementsRelative(intervals, increments) .DefaultIncrementsRelative()
IncrementsRelative(intervals, increments) .DefaultIncrementsRelative()
intervals |
( |
increments |
( |
intervals
(numeric
)
a vector with the left bounds of the relevant
intervals. For example, intervals = c(0, 50, 100)
specifies three intervals:
,
and
. 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 the intervals
.
Typically, end users will not use the .DefaultIncrementsRelative()
function.
# 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) )
# 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
IncrementsRelativeDLT
is the class for increments control based on
relative differences in terms of DLTs.
IncrementsRelativeDLT(intervals, increments) .DefaultIncrementsRelativeDLT()
IncrementsRelativeDLT(intervals, increments) .DefaultIncrementsRelativeDLT()
intervals |
( |
increments |
( |
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 to intervals
. IT must be of the same length
as the length of intervals
.
This considers all DLTs across all cohorts observed so far.
Typically, end users will not use the .DefaultIncrementsRelativeDLT()
function.
IncrementsRelativeDLTCurrent which only considers the DLTs in the current cohort.
# 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) )
# 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
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.
IncrementsRelativeDLTCurrent(intervals = c(0L, 1L), increments = c(2L, 1L)) .DefaultIncrementsRelativeDLTCurrent()
IncrementsRelativeDLTCurrent(intervals = c(0L, 1L), increments = c(2L, 1L)) .DefaultIncrementsRelativeDLTCurrent()
intervals |
( |
increments |
( |
Typically, end users will not use the .DefaultIncrementsRelativeDLTCurrent()
function.
# 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) )
# 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
IncrementsRelativeParts
is the class for increments control based on
relative differences in intervals, with special rules for part 1 and
beginning of part 2.
IncrementsRelativeParts(dlt_start, clean_start, ...) .DefaultIncrementsRelativeParts()
IncrementsRelativeParts(dlt_start, clean_start, ...) .DefaultIncrementsRelativeParts()
dlt_start |
( |
clean_start |
( |
... |
Arguments passed on to
|
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
.
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. If clean_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.
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.
my_increments <- IncrementsRelativeParts(dlt_start = 0, clean_start = 1)
my_increments <- IncrementsRelativeParts(dlt_start = 0, clean_start = 1)
CohortSizeConst
ObjectWe 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
## 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 = function(x) x ) ## 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 = function(x) x ) ## 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 = function(x) { kableExtra::kable_styling(x, bootstrap_options = c("striped", "hover", "condensed")) } ) ## 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)
## 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 = function(x) x ) ## 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 = function(x) x ) ## 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 = function(x) { kableExtra::kable_styling(x, bootstrap_options = c("striped", "hover", "condensed")) } ) ## 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)
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 |
( |
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.
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_size
s. 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 label
s.
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_size
s. 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 label
s.
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.
knit_print
for more details.
LogisticIndepBeta
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
where is the probability of the occurrence of a DLE at dose
.
The two parameters of this model are the intercept
and the slope
. 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.
LogisticIndepBeta(binDLE, DLEdose, DLEweights, data) .DefaultLogisticIndepBeta()
LogisticIndepBeta(binDLE, DLEdose, DLEweights, data) .DefaultLogisticIndepBeta()
binDLE |
( |
DLEdose |
( |
DLEweights |
( |
data |
( |
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 Willamson (1998).
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 in DLEdose
and DLEweights
.
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 in binDLE
and DLEweights
.
DLEweights
(integer
)
total number of subjects treated at each of
the pseudo dose level DLEdose
.
It must be at least of length 2 and the order of its elements must
correspond to values specified in binDLE
and DLEdose
.
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
() and the slope parameters (
) of the model.
This is used in output to display the resulting prior and posterior
covariance matrix of
and
obtained, based on the
pseudo data and (if any) the observed data and responses. This slot is
needed for internal purposes.
Typically, end users will not use the .DefaultLogisticIndepBeta()
function.
# 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 )
# 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
LogisticKadane
is the class for the logistic model in the parametrization
of Kadane et al. (1980).
LogisticKadane(theta, xmin, xmax) .DefaultLogisticKadane()
LogisticKadane(theta, xmin, xmax) .DefaultLogisticKadane()
theta |
( |
xmin |
( |
xmax |
( |
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. . Then it can easily be shown that the logistic
regression model has intercept
and slope
The priors are
and
theta
(proportion
)
the target toxicity probability.
xmin
(number
)
the minimum of the dose range.
xmax
(number
)
the maximum of the dose range.
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.
my_model <- LogisticKadane(theta = 0.33, xmin = 1, xmax = 200)
my_model <- LogisticKadane(theta = 0.33, xmin = 1, xmax = 200)
LogisticKadaneBetaGamma
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.
LogisticKadaneBetaGamma(theta, xmin, xmax, alpha, beta, shape, rate) .DefaultLogisticKadaneBetaGamma()
LogisticKadaneBetaGamma(theta, xmin, xmax, alpha, beta, shape, rate) .DefaultLogisticKadaneBetaGamma()
theta |
( |
xmin |
( |
xmax |
( |
alpha |
( |
beta |
( |
shape |
( |
rate |
( |
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. . Then it can easily be shown that the logistic
regression model has intercept
and slope
The prior for gamma
, is
.
The prior for rho0 = p(xmin)
, is
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
of rho0 = p(xmin)
the probability of a DLT at the minimum dose xmin
.
beta
(number
)
the second shape parameter of the Beta prior distribution
of rho0 = p(xmin)
the probability of a DLT at the minimum dose xmin
.
shape
(number
)
the shape parameter of the Gamma prior distribution
of gamma
the dose with target toxicity probability theta
.
rate
(number
)
the rate parameter of the Gamma prior distribution
of gamma
the dose with target toxicity probability theta
.
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.
ModelLogNormal
, LogisticKadane
.
my_model <- LogisticKadaneBetaGamma( theta = 0.3, xmin = 0, xmax = 7, alpha = 1, beta = 19, shape = 0.5625, rate = 0.125 )
my_model <- LogisticKadaneBetaGamma( theta = 0.3, xmin = 0, xmax = 7, alpha = 1, beta = 19, shape = 0.5625, rate = 0.125 )
LogisticLogNormal
LogisticLogNormal
is the class for the usual logistic regression model
with a bivariate normal prior on the intercept and log slope.
LogisticLogNormal(mean, cov, ref_dose = 1) .DefaultLogisticLogNormal()
LogisticLogNormal(mean, cov, ref_dose = 1) .DefaultLogisticLogNormal()
mean |
( |
cov |
( |
ref_dose |
( |
The covariate is the natural logarithm of the dose divided by
the reference dose
, i.e.:
where is the probability of observing a DLT for a given dose
.
The prior
Typically, end users will not use the .DefaultLogisticLogNormal()
function.
ModelLogNormal
, LogisticNormal
, LogisticLogNormalSub
,
ProbitLogNormal
, ProbitLogNormalRel
, LogisticLogNormalMixture
,
DALogisticLogNormal
.
my_model <- LogisticLogNormal( mean = c(-0.85, 1), cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2), ref_dose = 50 ) my_model
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
LogisticLogNormalGrouped
is the class for a logistic regression model
for both the mono and the combo arms of the simultaneous dose escalation
design.
LogisticLogNormalGrouped(mean, cov, ref_dose = 1) .DefaultLogisticLogNormalGrouped()
LogisticLogNormalGrouped(mean, cov, ref_dose = 1) .DefaultLogisticLogNormalGrouped()
mean |
( |
cov |
( |
ref_dose |
( |
The continuous covariate is the natural logarithm of the dose divided by
the reference dose
as in
LogisticLogNormal
. In addition,
is a binary indicator covariate which is 1 for the combo arm and 0 for the mono arm.
The model is then defined as:
where is the probability of observing a DLT for a given dose
,
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
Typically, end users will not use the .DefaultLogisticLogNormalGrouped()
function.
ModelLogNormal
, LogisticLogNormal
.
my_model <- LogisticLogNormalGrouped( mean = c(-0.85, 0, 1, 0), cov = diag(1, 4), ref_dose = 50 ) my_model
my_model <- LogisticLogNormalGrouped( mean = c(-0.85, 0, 1, 0), cov = diag(1, 4), ref_dose = 50 ) my_model
LogisticLogNormalMixture
LogisticLogNormalMixture
is the class for standard logistic model with
online mixture of two bivariate log normal priors.
LogisticLogNormalMixture(mean, cov, ref_dose, share_weight) .DefaultLogisticLogNormalMixture()
LogisticLogNormalMixture(mean, cov, ref_dose, share_weight) .DefaultLogisticLogNormalMixture()
mean |
( |
cov |
( |
ref_dose |
( |
share_weight |
( |
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 is given by
where is the probability for the model
being the same
as the model
, 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, , is the probability of a separate model
. Both components have the same log normal prior distribution,
which can be specified by the user, and which is inherited from the
LogisticLogNormal
class.
share_weight
(proportion
)
the prior weight for the share component
.
Typically, end users will not use the .DefaultLogNormalMixture()
function.
ModelLogNormal
, LogisticNormalMixture
,
LogisticNormalFixedMixture
.
# 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)
# 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
LogisticLogNormalOrdinal
is the class for a logistic lognormal CRM model
using an ordinal toxicity scale.
LogisticLogNormalOrdinal(mean, cov, ref_dose) .DefaultLogisticLogNormalOrdinal()
LogisticLogNormalOrdinal(mean, cov, ref_dose) .DefaultLogisticLogNormalOrdinal()
mean |
( |
cov |
( |
ref_dose |
( |
Typically, end users will not use the .DefaultLogisticLogNormalOrdinal()
function.
LogisticLogNormalOrdinal( mean = c(3, 4, 0), cov = diag(c(4, 3, 1)), ref_dose = 1 )
LogisticLogNormalOrdinal( mean = c(3, 4, 0), cov = diag(c(4, 3, 1)), ref_dose = 1 )
LogisticLogNormalSub
LogisticLogNormalSub
is the class for a standard logistic model with
bivariate (log) normal prior with subtractive dose standardization.
LogisticLogNormalSub(mean, cov, ref_dose = 0) .DefaultLogisticLogNormalSub()
LogisticLogNormalSub(mean, cov, ref_dose = 0) .DefaultLogisticLogNormalSub()
mean |
( |
cov |
( |
ref_dose |
( |
The covariate is the dose minus the reference dose
,
i.e.:
where is the probability of observing a DLT for a given dose
.
The prior
params
(ModelParamsNormal
)
bivariate normal prior parameters.
ref_dose
(number
)
the reference dose .
Typically, end-users will not use the .DefaultLogisticLogNormalSub()
function.
LogisticNormal
, LogisticLogNormal
, ProbitLogNormal
,
ProbitLogNormalRel
.
my_model <- LogisticLogNormalSub( mean = c(-0.85, 1), cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2), ref_dose = 50 )
my_model <- LogisticLogNormalSub( mean = c(-0.85, 1), cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2), ref_dose = 50 )
LogisticNormal
LogisticNormal
is the class for the usual logistic regression model with
a bivariate normal prior on the intercept and slope.
LogisticNormal(mean, cov, ref_dose = 1) .DefaultLogisticNormal()
LogisticNormal(mean, cov, ref_dose = 1) .DefaultLogisticNormal()
mean |
( |
cov |
( |
ref_dose |
( |
The covariate is the natural logarithm of the dose divided by
the reference dose
, i.e.:
where is the probability of observing a DLT for a given dose
.
The prior
Typically, end users will not use the .DefaultLogisticNormal()
function.
ModelLogNormal
, LogisticLogNormal
, LogisticLogNormalSub
,
ProbitLogNormal
, ProbitLogNormalRel
, LogisticNormalMixture
.
# 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
# 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
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.
LogisticNormalFixedMixture(components, weights, ref_dose, log_normal = FALSE) .DefaultLogisticNormalFixedMixture()
LogisticNormalFixedMixture(components, weights, ref_dose, log_normal = FALSE) .DefaultLogisticNormalFixedMixture()
components |
( |
weights |
( |
ref_dose |
( |
log_normal |
( |
The covariate is the natural logarithm of the dose divided
by the reference dose
, i.e.:
where is the probability of observing a DLT for a given dose
.
The prior
if a normal prior is used and
if a log normal prior is used.
The weights 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.
components
(list
)
the specifications of the mixture components,
a list with ModelParamsNormal
objects 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?
Typically, end-users will not use the .DefaultLogisticNormalFixedMixture()
function.
ModelParamsNormal
, ModelLogNormal
,
LogisticNormalMixture
, LogisticLogNormalMixture
.
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 )
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
LogisticNormalMixture
is the class for standard logistic regression model
with a mixture of two bivariate normal priors on the intercept and slope parameters.
LogisticNormalMixture(comp1, comp2, weightpar, ref_dose) .DefaultLogisticNormalMixture()
LogisticNormalMixture(comp1, comp2, weightpar, ref_dose) .DefaultLogisticNormalMixture()
comp1 |
( |
comp2 |
( |
weightpar |
( |
ref_dose |
( |
The covariate is the natural logarithm of the dose divided by
the reference dose
, i.e.:
where is the probability of observing a DLT for a given dose
.
The prior
The weight w for the first component is assigned a beta prior B(a, b)
.
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 names a
and
b
and with strictly positive values.
ref_dose
(positive_number
)
the reference dose.
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.
ModelParamsNormal
, ModelLogNormal
,
LogisticNormalFixedMixture
, LogisticLogNormalMixture
.
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 )
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 )
Shorthand for logit function
logit(x)
logit(x)
x |
the function argument |
the logit(x)
This is a modified version of match
that supports tolerance.
match_within_tolerance(x, table)
match_within_tolerance(x, table)
x |
the values to be matched |
table |
the values to be matched against |
A vector of the same length as x
or
empty vector if table
is empty.
This function determines the upper limit of the next dose based on the
increments
and the data
.
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, ...)
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, ...)
increments |
( |
data |
( |
... |
additional arguments without method dispatch. |
model |
( |
samples |
( |
A number
, the maximum possible next dose.
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 in increments
object.
Find out more in IncrementsDoseLevels
.
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
# 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)
# 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)
This function combines cohort size rules by taking the maximum of all sizes.
maxSize(...) ## S4 method for signature 'CohortSize' maxSize(...)
maxSize(...) ## S4 method for signature 'CohortSize' maxSize(...)
... |
Objects of class |
the combination as an object of class
CohortSizeMax
maxSize(CohortSize)
: The method combining cohort size rules by taking maximum
# 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)
# 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)
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.
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, ...)
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, ...)
data |
( |
model |
( |
options |
( |
... |
not used. |
from_prior |
( |
The posterior samples, an object of class Samples
.
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 the
DualEndpointRW
model, 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 the
DualEndpointBeta
model, it is required that the value of ref_dose_beta
slot 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 in DualEndpointBeta
model. 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 the
DualEndpointEmax
model, 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 the
OneParLogNormalPrior
model, 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 the
OneParExpPrior
model, 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 for DataMixture with different from_prior default
mcmc(data = Data, model = LogisticIndepBeta, options = McmcOptions)
: Obtain posterior samples for the model parameters based on the pseudo 'LogisticsIndepBeta'
DLE model. The joint prior and posterior probability density function of
the intercept (phi1) and the slope
(phi2) are given in Whitehead and
Williamson (1998) and TsuTakawa (1975). However, since asymptotically, the joint posterior probability density
will be bivariate normal and we will use the bivariate normal distribution to
generate posterior samples of the intercept and the slope parameters. For the prior samples of
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 the
Efficacy log log model. Given the value of , the precision of the efficacy responses,
the joint prior or the posterior probability of the intercept
(theta1) and
the slope
(theta2) is a bivariate normal distribution. The
(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 of nu will be first generated.
Then the mean of the of the nu samples
will be used the 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 the Efficacy Flexible form.
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 of sigma2 ,
the variance of the efficacy response and samples of sigma2betaW
, 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,
both sigma2 and sigma2betaW can be fixed or having 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 of sigma2 and sigma2betaW will be generated using the updated parameters.
mcmc(
data = DataOrdinal,
model = LogisticLogNormalOrdinal,
options = McmcOptions
)
: Obtain the posterior samples for the model parameters in the
LogisticLogNormalOrdinal
.
The generic mcmc
method returns a Samples
object with elements of the
data
slot named alpha[1]
, alpha[2]
, ..., alpha[k]
and beta
when
passed a LogisticLogNormalOrdinal
object. This makes the "alpha elements"
awkward to access and is inconsistent with other Model
objects. So rename
the alpha elements to alpha1
, alpha2
, ..., alpha<k>
for ease and
consistency.
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
.
# 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)
# 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)
McmcOptions
McmcOptions
is a class for the three canonical MCMC options as well as
Random Number Generator settings.
McmcOptions( burnin = 10000L, step = 2L, samples = 10000L, rng_kind = NA_character_, rng_seed = NA_integer_ ) .DefaultMcmcOptions()
McmcOptions( burnin = 10000L, step = 2L, samples = 10000L, rng_kind = NA_character_, rng_seed = NA_integer_ ) .DefaultMcmcOptions()
burnin |
( |
step |
( |
samples |
( |
rng_kind |
( |
rng_seed |
( |
iterations
(count
)
number of MCMC iterations.
burnin
(count
)
number of burn-in iterations which are not saved.
step
(count
)
only every step
-th iteration is saved after
the burnin
. In other words, a sample from iteration
i = 1,...,iterations
, is saved if and only if
(i - burnin) mod step = 0
.
For example, for iterations = 6
, burnin = 0
and step = 2
, only
samples from iterations 2,4,6
will be saved.
rng_kind
(string
)
a Random Number Generator (RNG) type used by
rjags
. It must be one out of the following four values:
base::Wichmann-Hill
, base::Marsaglia-Multicarry
,
base::Super-Duper
, base::Mersenne-Twister
, or NA_character_
.
If it is NA_character_
(default), then the RNG kind will be chosen by
rjags
.
rng_seed
(number
)
a Random Number Generator (RNG) seed
used by rjags
for a chosen rng_kind
. It must be an integer scalar or
NA_integer_
, which means that the seed will be chosen by rjags
.
Typically, end users will not use the .DefaultMcmcOptions()
function.
# 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)
# 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)
This function constructs a minimally informative prior, which is captured in
a LogisticNormal
(or
LogisticLogNormal
) object.
MinimalInformative( dosegrid, refDose, threshmin = 0.2, threshmax = 0.3, probmin = 0.05, probmax = 0.05, ... )
MinimalInformative( dosegrid, refDose, threshmin = 0.2, threshmax = 0.3, probmin = 0.05, probmax = 0.05, ... )
dosegrid |
the dose grid |
refDose |
the reference dose |
threshmin |
Any toxicity probability above this threshold would
be very unlikely (see |
threshmax |
Any toxicity probability below this threshold would
be very unlikely (see |
probmin |
the prior probability of exceeding |
probmax |
the prior probability of being below |
... |
additional arguments for computations, see
|
Based on the proposal by Neuenschwander et al (2008, Statistics in
Medicine), a minimally informative prior distribution is constructed. The
required key input is the minimum ( in the notation of the
Appendix A.1 of that paper) and the maximum value (
) of the dose
grid supplied to this function. Then
threshmin
is the probability
threshold , such that any probability of DLT larger than
has only 5% probability. Therefore
is the 95%
quantile of the beta distribution and hence
. Likewise,
threshmax
is the probability threshold , such that any
probability of DLT smaller than
has only 5% probability
(
). The probabilities
and
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.
# 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")
# 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")
This function combines cohort size rules by taking the minimum of all sizes.
minSize(...) ## S4 method for signature 'CohortSize' minSize(...)
minSize(...) ## S4 method for signature 'CohortSize' minSize(...)
... |
Objects of class |
the combination as an object of class
CohortSizeMin
minSize(CohortSize)
: The method combining cohort size rules by taking minimum
# 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)
# 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)
ModelEff
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.
.DefaultModelEff()
.DefaultModelEff()
data
(DataDual
)
observed data that is used to obtain model
parameters estimates or samples (see details above).
Typically, end users will not use the .DefaultModelEff()
function.
ModelLogNormal
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.:
. 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.
ModelLogNormal(mean, cov, ref_dose = 1) .DefaultModelLogNormal()
ModelLogNormal(mean, cov, ref_dose = 1) .DefaultModelLogNormal()
mean |
( |
cov |
( |
ref_dose |
( |
params
(ModelParamsNormal
)
bivariate normal prior parameters.
ref_dose
(positive_number
)
the reference dose.
Typically, end users will not use the .DefaultModelLogNormal()
function.
ModelParamsNormal
, LogisticNormal
, LogisticLogNormal
,
LogisticLogNormalSub
, ProbitLogNormal
, ProbitLogNormalRel
.
ModelParamsNormal
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.
ModelParamsNormal(mean, cov) .DefaultModelParamsNormal()
ModelParamsNormal(mean, cov) .DefaultModelParamsNormal()
mean |
( |
cov |
( |
mean
(numeric
)
the mean vector.
cov
(matrix
)
the covariance matrix.
prec
(matrix
)
the precision matrix, which is an inverse matrix of the cov
.
Typically, end users will not use the .ModelPAramsNormal()
function.
ModelLogNormal
, LogisticNormalMixture
.
ModelParamsNormal(mean = c(1, 6), cov = diag(2))
ModelParamsNormal(mean = c(1, 6), cov = diag(2))
ModelPseudo
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).
.DefaultModelPseudo()
.DefaultModelPseudo()
Typically, end users will not use the .DefaultModelPseudo()
function.
ModelTox
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.
.DefaultModelTox()
.DefaultModelTox()
data
(Data
)
observed data that is used to obtain model parameters
estimates or samples (see details above).
Typically, end users will not use the .DefaultModelTox()
function.
A method that returns names of the parameters that are sampled.
## S4 method for signature 'Samples' names(x)
## S4 method for signature 'Samples' names(x)
x |
( |
my_samples <- Samples( data = list(alpha = 1:5, beta = 15:19), options = McmcOptions(burnin = 2, step = 2, samples = 5) ) names(my_samples)
my_samples <- Samples( data = list(alpha = 1:5, beta = 15:19), options = McmcOptions(burnin = 2, step = 2, samples = 5) ) names(my_samples)
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
.
nextBest(nextBest, doselimit, 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, ...)
nextBest(nextBest, doselimit, 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, ...)
nextBest |
( |
doselimit |
( |
samples |
( |
model |
( |
data |
( |
... |
additional arguments without method dispatch. |
in_sim |
( |
model_eff |
( |
samples_eff |
( |
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.
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 element probs
in 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 element probs
contains 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 for LogisticIndepBeta
model 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 for LogisticIndepBeta
model 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 model
ModelTox
and Effloglog
efficacy 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.
# 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 )
# 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 )
NextBest
NextBest
is a virtual class for finding next best dose, from which all
other specific next best dose classes inherit.
.DefaultNextBest()
.DefaultNextBest()
Typically, end users will not use the DefaultNextBest()
function.
NextBestMTD
, NextBestNCRM
, NextBestDualEndpoint
,
NextBestThreePlusThree
, NextBestDualEndpoint
, NextBestMinDist
,
NextBestInfTheory
, NextBestTD
, NextBestTDsamples
,
NextBestMaxGain
, NextBestMaxGainSamples
.
NextBestDualEndpoint
NextBestDualEndpoint
is the class for next best dose that is based on the
dual endpoint model.
NextBestDualEndpoint( target, overdose, max_overdose_prob, target_relative = TRUE, target_thresh = 0.01 ) .DefaultNextBestDualEndpoint()
NextBestDualEndpoint( target, overdose, max_overdose_prob, target_relative = TRUE, target_thresh = 0.01 ) .DefaultNextBestDualEndpoint()
target |
( |
overdose |
( |
max_overdose_prob |
( |
target_relative |
( |
target_thresh |
( |
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.
target
(numeric
)
the biomarker target range that needs to be
reached. For example, the target range and
target_relative = TRUE
means that we target a dose with at least
of maximum biomarker level. As an other example,
would mean that we target a dose between
and
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
)
is target
specified as relative? If
TRUE
, then the target
is interpreted relative to the maximum, so it
must be a probability range. Otherwise, the target
is 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).
Typically, end users will not use the .DefaultNextBestDualEndpoint()
function.
# 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 )
# 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 )
NextBestInfTheory
NextBestInfTheory
is the class for next best dose that is based on
information theory as proposed in https://doi.org/10.1002/sim.8450.
NextBestInfTheory(target, asymmetry) .DefaultNextBestInfTheory()
NextBestInfTheory(target, asymmetry) .DefaultNextBestInfTheory()
target |
( |
asymmetry |
( |
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 interval.
Typically, end users will not use the .DefaultNextBestInfTheory()
function.
NextBestMaxGain
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
).
NextBestMaxGain(prob_target_drt, prob_target_eot) .DefaultNextBestMaxGain()
NextBestMaxGain(prob_target_drt, prob_target_eot) .DefaultNextBestMaxGain()
prob_target_drt |
( |
prob_target_eot |
( |
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.
Typically, end users will not use the .DefaultNextBestMaxGain()
function.
my_next_best <- NextBestMaxGain(0.35, 0.3)
my_next_best <- NextBestMaxGain(0.35, 0.3)
NextBestMaxGainSamples
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.
NextBestMaxGainSamples(prob_target_drt, prob_target_eot, derive, mg_derive) .DefaultNextBestMaxGainSamples()
NextBestMaxGainSamples(prob_target_drt, prob_target_eot, derive, mg_derive) .DefaultNextBestMaxGainSamples()
prob_target_drt |
( |
prob_target_eot |
( |
derive |
( |
mg_derive |
( |
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 the prob_target_drt
or prob_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.
Typically, end users will not use the .DefaultNextBestMaxGainSamples()
function.
# 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)) } )
# 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
NextBestMinDist
is the class for next best dose that is based on minimum
distance to target probability.
NextBestMinDist(target) .DefaultNextBestMinDist()
NextBestMinDist(target) .DefaultNextBestMinDist()
target |
( |
target
(proportion
)
single target toxicity probability, except
0 or 1.
Typically, end users will not use the .DefaultNextBestMinDist()
function.
# 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)
# 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)
NextBestMTD
NextBestMTD
is the class for next best dose based on MTD estimate.
NextBestMTD(target, derive) .DefaultNextBestMTD()
NextBestMTD(target, derive) .DefaultNextBestMTD()
target |
( |
derive |
( |
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.
Typically, end users will not use the .DefaultNextBestMTD()
function.
# 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) } )
# 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) } )
NextBestNCRM
NextBestNCRM
is the class for next best dose that finds the next dose
with high posterior probability to be in the target toxicity interval.
NextBestNCRM(target, overdose, max_overdose_prob) .DefaultNextBestNCRM()
NextBestNCRM(target, overdose, max_overdose_prob) .DefaultNextBestNCRM()
target |
( |
overdose |
( |
max_overdose_prob |
( |
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.
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.
Typically, end users will not use the .DefaultNextBestNCRM()
function.
# 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 )
# 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
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.
NextBestNCRMLoss( target, overdose, unacceptable = c(1, 1), max_overdose_prob, losses ) .DefaultNextBestNCRMLoss()
NextBestNCRMLoss( target, overdose, unacceptable = c(1, 1), max_overdose_prob, losses ) .DefaultNextBestNCRMLoss()
target |
( |
overdose |
( |
unacceptable |
( |
max_overdose_prob |
( |
losses |
( |
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 the overdose
does not include 1. Otherwise, it is c(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 the
unacceptable
is provided, the vector length must be 4, otherwise 3.
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.
# 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) )
# 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
NextBestOrdinal
is the class for applying a standard NextBest
rule to
the results of an ordinal CRM trial.
NextBestOrdinal(grade, rule) .DefaultNextBestOrdinal()
NextBestOrdinal(grade, rule) .DefaultNextBestOrdinal()
grade |
( |
rule |
( |
grade
(integer
)
the toxicity grade to which the rule
should be
applied.
rule
(NextBest
)
the standard NextBest
rule to be applied
Typically, end users will not use the .DefaultNextBestOrdinal()
function.
NextBestOrdinal( grade = 1L, rule = NextBestMTD( 0.25, function(mtd_samples) { quantile(mtd_samples, probs = 0.25) } ) )
NextBestOrdinal( grade = 1L, rule = NextBestMTD( 0.25, function(mtd_samples) { quantile(mtd_samples, probs = 0.25) } ) )
NextBestProbMTDLTE
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.
NextBestProbMTDLTE(target) .DefaultNextBestProbMTDLTE()
NextBestProbMTDLTE(target) .DefaultNextBestProbMTDLTE()
target |
( |
target
(numeric
)
the target toxicity probability.
Typically, end users will not use the .DefaultNextBestProbMTDLTE()
function.
# 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)
# 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
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.
NextBestProbMTDMinDist(target) .DefaultNextBestProbMTDMinDist()
NextBestProbMTDMinDist(target) .DefaultNextBestProbMTDMinDist()
target |
( |
target
(numeric
)
the target toxicity probability.
Typically, end users will not use the .DefaultNextBestProbMTDMinDist()
function.
# 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)
# 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
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.
.DefaultNextBestTD() NextBestTD(prob_target_drt, prob_target_eot)
.DefaultNextBestTD() NextBestTD(prob_target_drt, prob_target_eot)
prob_target_drt |
( |
prob_target_eot |
( |
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.
Typically, end users will not use the .DefaultNextBestTD()
function.
my_next_best <- NextBestTD(0.35, 0.3)
my_next_best <- NextBestTD(0.35, 0.3)
NextBestTDsamples
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.
NextBestTDsamples(prob_target_drt, prob_target_eot, derive) .DefaultNextBestTDsamples()
NextBestTDsamples(prob_target_drt, prob_target_eot, derive) .DefaultNextBestTDsamples()
prob_target_drt |
( |
prob_target_eot |
( |
derive |
( |
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 the prob_target_drt
or prob_target_eot
. It must
therefore accept one and only one argument, which is a numeric vector, and
return a number.
Typically, end users will not use the .DefaultNextBestTDsamples()
function.
# 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)) } )
# 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
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.
NextBestThreePlusThree() .DefaultNextBestThreePlusThree()
NextBestThreePlusThree() .DefaultNextBestThreePlusThree()
Typically, end users will not use the .DefaultNextBestThreePlusThree()
function.
# Next best dose class object using the classical 3+3 design. my_next_best <- NextBestThreePlusThree()
# Next best dose class object using the classical 3+3 design. my_next_best <- NextBestThreePlusThree()
A function that gets the number of doses in grid. User can choose whether the placebo dose (if any) should be counted or not.
ngrid(object, ignore_placebo = TRUE, ...) ## S4 method for signature 'Data' ngrid(object, ignore_placebo = TRUE, ...)
ngrid(object, ignore_placebo = TRUE, ...) ## S4 method for signature 'Data' ngrid(object, ignore_placebo = TRUE, ...)
object |
( |
ignore_placebo |
( |
... |
further arguments passed to class-specific methods. |
integer
the number of doses in grid.
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)
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)
OneParExpPrior
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).
OneParExpPrior(skel_probs, dose_grid, lambda) .DefaultOneParExpPrior()
OneParExpPrior(skel_probs, dose_grid, lambda) .DefaultOneParExpPrior()
skel_probs |
see slot definition. |
dose_grid |
( |
lambda |
see slot definition. |
skel_fun
(function
)
function to calculate the prior DLT probabilities.
skel_fun_inv
(function
)
inverse function of skel_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.
Typically, end users will not use the .DefaultOneparExpPrior()
function.
Typically, end users will not use the .DefaultOneParLogNormalPrior()
function.
my_model <- OneParExpPrior( skel_probs = c(0.1, 0.3, 0.5, 0.7, 0.9), dose_grid = 1:5, lambda = 2 )
my_model <- OneParExpPrior( skel_probs = c(0.1, 0.3, 0.5, 0.7, 0.9), dose_grid = 1:5, lambda = 2 )
OneParLogNormalPrior
OneParLogNormalPrior
is the class for a standard CRM with a normal prior on
the log power parameter for the skeleton prior probabilities.
OneParLogNormalPrior(skel_probs, dose_grid, sigma2) .DefaultOneParLogNormalPrior()
OneParLogNormalPrior(skel_probs, dose_grid, sigma2) .DefaultOneParLogNormalPrior()
skel_probs |
( |
dose_grid |
( |
sigma2 |
( |
an instance of the OneParLogNormalPrior
class
skel_fun
(function
)
function to calculate the prior DLT probabilities.
skel_fun_inv
(function
)
inverse function of skel_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.
my_model <- OneParLogNormalPrior( skel_probs = seq(from = 0.1, to = 0.9, length = 5), dose_grid = 1:5, sigma2 = 2 )
my_model <- OneParLogNormalPrior( skel_probs = seq(from = 0.1, to = 0.9, length = 5), dose_grid = 1:5, sigma2 = 2 )
The method combining two atomic stopping rules
## S4 method for signature 'Stopping,Stopping' e1 | e2
## S4 method for signature 'Stopping,Stopping' e1 | e2
e1 |
First |
e2 |
Second |
The StoppingAny
object
## 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
## 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
The method combining a stopping list and an atomic
## S4 method for signature 'StoppingAny,Stopping' e1 | e2
## S4 method for signature 'StoppingAny,Stopping' e1 | e2
e1 |
|
e2 |
|
The modified StoppingAny
object
## 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
## 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
The method combining an atomic and a stopping list
## S4 method for signature 'Stopping,StoppingAny' e1 | e2
## S4 method for signature 'Stopping,StoppingAny' e1 | e2
e1 |
|
e2 |
|
The modified StoppingAny
object
## 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 )
## 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 )
Plot of the fitted dose-tox based with a given pseudo DLE model and data without samples
## S4 method for signature 'Data,ModelTox' plot( x, y, xlab = "Dose level", ylab = "Probability of DLE", showLegend = TRUE, ... )
## S4 method for signature 'Data,ModelTox' plot( x, y, xlab = "Dose level", ylab = "Probability of DLE", showLegend = TRUE, ... )
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 |
This returns the ggplot
object for the dose-DLE model plot
## 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 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)
DataDA
ClassA method that creates a plot for DataDA
object.
## S4 method for signature 'DataDA,missing' plot(x, y, blind = FALSE, ...)
## S4 method for signature 'DataDA,missing' plot(x, y, blind = FALSE, ...)
x |
( |
y |
( |
blind |
( |
... |
passed to the first inherited method |
The ggplot2
object.
# 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)
# 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)
DataDual
ClassA method that creates a plot for DataDual
object.
## S4 method for signature 'DataDual,missing' plot(x, y, blind = FALSE, ...)
## S4 method for signature 'DataDual,missing' plot(x, y, blind = FALSE, ...)
x |
( |
y |
( |
blind |
( |
... |
passed to the first inherited method |
The ggplot2
object.
# 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)
# 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 of the fitted dose-efficacy based with a given pseudo efficacy model and data without samples
## S4 method for signature 'DataDual,ModelEff' plot( x, y, ..., xlab = "Dose level", ylab = "Expected Efficacy", showLegend = TRUE )
## S4 method for signature 'DataDual,ModelEff' plot( x, y, ..., xlab = "Dose level", ylab = "Expected Efficacy", showLegend = TRUE )
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) |
This returns the ggplot
object for the dose-efficacy model plot
# 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
# 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
This plot method can be applied to DualSimulations
objects in order to summarize them graphically. In addition to the standard
plot types, there is
Plot a boxplot of the final biomarker variance estimates in the simulated trials
Plot a boxplot of the final correlation estimates in the simulated trials
## S4 method for signature 'DualSimulations,missing' plot(x, y, type = c("trajectory", "dosesTried", "sigma2W", "rho"), ...)
## S4 method for signature 'DualSimulations,missing' plot(x, y, type = c("trajectory", "dosesTried", "sigma2W", "rho"), ...)
x |
the |
y |
missing |
type |
the type of plots you want to obtain. |
... |
not used |
A single ggplot
object if a single plot is
asked for, otherwise a gridExtra{gTree}
object.
# 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))
# 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))
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:
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 trueBiomarker
argument to
summary,DualSimulations-method
)
You can specify any subset of these in the type
argument.
## S4 method for signature 'DualSimulationsSummary,missing' plot( x, y, type = c("nObs", "doseSelected", "propDLTs", "nAboveTarget", "meanFit", "meanBiomarkerFit"), ... )
## S4 method for signature 'DualSimulationsSummary,missing' plot( x, y, type = c("nObs", "doseSelected", "propDLTs", "nAboveTarget", "meanFit", "meanBiomarkerFit"), ... )
x |
the |
y |
missing |
type |
the types of plots you want to obtain. |
... |
not used |
A single ggplot
object if a single plot is
asked for, otherwise a gridExtra{gTree}
object.
# 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 ))
# 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 ))
Summarize the simulations with plots
## S4 method for signature 'GeneralSimulations,missing' plot(x, y, type = c("trajectory", "dosesTried"), ...)
## S4 method for signature 'GeneralSimulations,missing' plot(x, y, type = c("trajectory", "dosesTried"), ...)
x |
the |
y |
missing |
type |
the type of plots you want to obtain. |
... |
not used |
This plot method can be applied to GeneralSimulations
objects in order to summarize them graphically. Possible type
s of
plots at the moment are:
Summary of the trajectory of the simulated trials
Average proportions of the doses tested in patients
You can specify one or both of these in the
type
argument.
A single ggplot
object if a single plot is
asked for, otherwise a gridExtra{gTree}
object.
# 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
# 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
This plot method can be applied to
GeneralSimulationsSummary
objects in order to
summarize them graphically. Possible type
s of plots at the moment
are:
## S4 method for signature 'GeneralSimulationsSummary,missing' plot(x, y, type = c("nObs", "doseSelected", "propDLTs", "nAboveTarget"), ...)
## S4 method for signature 'GeneralSimulationsSummary,missing' plot(x, y, type = c("nObs", "doseSelected", "propDLTs", "nAboveTarget"), ...)
x |
the |
y |
missing |
type |
the types of plots you want to obtain. |
... |
not used |
Distribution of the number of patients in the simulated trials
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.
Distribution of the proportion of patients with DLTs in the trials
Distribution of the number of patients treated at doses
which are above the target toxicity interval (as specified by the
truth
and target
arguments to
summary,GeneralSimulations-method
)
You can specify any subset of these in the type
argument.
A single ggplot
object if a single plot is
asked for, otherwise a gridExtra{gTree}
object.
PseudoDualFlexiSimulations
objects in order to summarize them graphically. Possible type
s of
plots at the moment are: Summary of the trajectory of the simulated trials
Average proportions of the doses tested in patients
The variance of the efficacy responses
The variance of the random walk model
You can specify one or both of these in the
type
argument.
This plot method can be applied to PseudoDualFlexiSimulations
objects in order to summarize them graphically. Possible type
s of
plots at the moment are:
Summary of the trajectory of the simulated trials
Average proportions of the doses tested in patients
The variance of the efficacy responses
The variance of the random walk model
You can specify one or both of these in the
type
argument.
## S4 method for signature 'PseudoDualFlexiSimulations,missing' plot(x, y, type = c("trajectory", "dosesTried", "sigma2", "sigma2betaW"), ...)
## S4 method for signature 'PseudoDualFlexiSimulations,missing' plot(x, y, type = c("trajectory", "dosesTried", "sigma2", "sigma2betaW"), ...)
x |
the |
y |
missing |
type |
the type of plots you want to obtain. |
... |
not used |
A single ggplot
object if a single plot is
asked for, otherwise a gridExtra{gTree}
object.
# 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))
# 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))
Summarize the simulations with plots
## S4 method for signature 'PseudoDualSimulations,missing' plot(x, y, type = c("trajectory", "dosesTried", "sigma2"), ...)
## S4 method for signature 'PseudoDualSimulations,missing' plot(x, y, type = c("trajectory", "dosesTried", "sigma2"), ...)
x |
the |
y |
missing |
type |
the type of plots you want to obtain. |
... |
not used |
This plot method can be applied to PseudoDualSimulations
objects in order to summarize them graphically. Possible type
s of
plots at the moment are:
Summary of the trajectory of the simulated trials
Average proportions of the doses tested in patients
The variance of the efficacy responses
You can specify one or both of these in the
type
argument.
A single ggplot
object if a single plot is
asked for, otherwise a gridExtra{gTree}
object.
# 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))
# 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))
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:
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 trueEff
argument to
summary,PseudoDualSimulations-method
)
You can specify any subset of these in the type
argument.
## S4 method for signature 'PseudoDualSimulationsSummary,missing' plot( x, y, type = c("nObs", "doseSelected", "propDLE", "nAboveTargetEndOfTrial", "meanFit", "meanEffFit"), ... )
## S4 method for signature 'PseudoDualSimulationsSummary,missing' plot( x, y, type = c("nObs", "doseSelected", "propDLE", "nAboveTargetEndOfTrial", "meanFit", "meanEffFit"), ... )
x |
the |
y |
missing |
type |
the types of plots you want to obtain. |
... |
not used |
A single ggplot
object if a single plot is
asked for, otherwise a gridExtra{gTree}
object.
# 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))
# 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))
Graphical display of the simulation summary
## S4 method for signature 'PseudoSimulationsSummary,missing' plot( x, y, type = c("nObs", "doseSelected", "propDLE", "nAboveTargetEndOfTrial", "meanFit"), ... )
## S4 method for signature 'PseudoSimulationsSummary,missing' plot( x, y, type = c("nObs", "doseSelected", "propDLE", "nAboveTargetEndOfTrial", "meanFit"), ... )
x |
the |
y |
missing |
type |
the types of plots you want to obtain. |
... |
not used |
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
A single ggplot
object if a single plot is
asked for, otherwise a gridExtra{gTree}
object.
# 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
# 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
## S4 method for signature 'Samples,DALogisticLogNormal' plot(x, y, data, hazard = FALSE, ..., showLegend = TRUE)
## S4 method for signature 'Samples,DALogisticLogNormal' plot(x, y, data, hazard = FALSE, ..., showLegend = TRUE)
x |
the |
y |
the |
data |
the |
hazard |
see |
... |
not used |
showLegend |
should the legend be shown? (default) |
This returns the ggplot
object for the dose-toxicity model fit
When we have the dual endpoint model, also the dose-biomarker fit is shown in the plot
## S4 method for signature 'Samples,DualEndpoint' plot(x, y, data, extrapolate = TRUE, showLegend = FALSE, ...)
## S4 method for signature 'Samples,DualEndpoint' plot(x, y, data, extrapolate = TRUE, showLegend = FALSE, ...)
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
|
This returns the ggplot
object with the dose-toxicity and dose-biomarker model fits
# 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
# 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
## S4 method for signature 'Samples,GeneralModel' plot( x, y, data, ..., xlab = "Dose level", ylab = "Probability of DLT [%]", showLegend = TRUE )
## S4 method for signature 'Samples,GeneralModel' plot( x, y, data, ..., xlab = "Dose level", ylab = "Probability of DLT [%]", showLegend = TRUE )
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) |
This returns the ggplot
object for the dose-toxicity model fit
# 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
# 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
ModelEff
class
with samplesPlot the fitted dose-efficacy curve using a model from ModelEff
class
with samples
## S4 method for signature 'Samples,ModelEff' plot( x, y, data, ..., xlab = "Dose level", ylab = "Expected Efficacy", showLegend = TRUE )
## S4 method for signature 'Samples,ModelEff' plot( x, y, data, ..., xlab = "Dose level", ylab = "Expected Efficacy", showLegend = TRUE )
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) |
This returns the ggplot
object for the dose-efficacy model fit
# 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
# 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
ModelTox
class model with samplesPlot the fitted dose-DLE curve using a ModelTox
class model with samples
## S4 method for signature 'Samples,ModelTox' plot( x, y, data, ..., xlab = "Dose level", ylab = "Probability of DLT [%]", showLegend = TRUE )
## S4 method for signature 'Samples,ModelTox' plot( x, y, data, ..., xlab = "Dose level", ylab = "Probability of DLT [%]", showLegend = TRUE )
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) |
This returns the ggplot
object for the dose-DLE model fit
## 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)
## 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)
Graphical display of the simulation summary
## S4 method for signature 'SimulationsSummary,missing' plot( x, y, type = c("nObs", "doseSelected", "propDLTs", "nAboveTarget", "meanFit"), ... )
## S4 method for signature 'SimulationsSummary,missing' plot( x, y, type = c("nObs", "doseSelected", "propDLTs", "nAboveTarget", "meanFit"), ... )
x |
the |
y |
missing |
type |
the types of plots you want to obtain. |
... |
not used |
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:
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 truth
argument to
summary,Simulations-method
)
You can specify any subset of these in the type
argument.
A single ggplot
object if a single plot is
asked for, otherwise a gridExtra{gTree}
object.
# 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
# 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
gtable
ObjectsThis 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, e.g.
## S3 method for class 'gtable' plot(x, ...) ## S3 method for class 'gtable' print(x, ...)
## S3 method for class 'gtable' plot(x, ...) ## S3 method for class 'gtable' print(x, ...)
x |
( |
... |
additional parameters for |
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
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, ...)
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, ...)
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) |
This returns the ggplot
object with the dose-toxicity and dose-efficacy model fits
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
# 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
# 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
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
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), ...)
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), ...)
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 |
( |
This returns the ggplot
object for the plot
plotGain(
DLEmodel = ModelTox,
DLEsamples = Samples,
Effmodel = ModelEff,
Effsamples = Samples
)
: Standard method
plotGain(
DLEmodel = ModelTox,
DLEsamples = missing,
Effmodel = ModelEff,
Effsamples = missing
)
: Standard method
# 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
# 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
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.
A function that computes the probability of the occurrence of a DLE at a specified dose level, based on the model parameters (samples).
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, ...)
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, ...)
dose |
( |
model |
( |
samples |
( |
... |
model specific parameters when |
group |
( |
grade |
( |
cumulative |
( |
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
.
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
.
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 for LogisticLogNormalGrouped
which needs group
argument 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 of LogisticIndepBeta
model
parameters.
prob(dose = numeric, model = LogisticIndepBeta, samples = missing)
: compute toxicity probabilities of the occurrence of a DLE at
a specified dose level, based on the LogisticIndepBeta
model parameters.
All model parameters (except dose
) should be present in the model
object.
prob(dose = numeric, model = OneParLogNormalPrior, samples = Samples)
:
prob(dose = numeric, model = OneParExpPrior, samples = Samples)
:
prob(dose = numeric, model = LogisticLogNormalOrdinal, samples = Samples)
:
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.
probFunction()
, dose()
, efficacy()
.
# 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)
# 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)
A function that returns a prob()
function that computes the toxicity
probabilities for a given dose level, based on the model specific parameters.
probFunction(model, ...) ## S4 method for signature 'GeneralModel' probFunction(model, ...) ## S4 method for signature 'ModelTox' probFunction(model, ...) ## S4 method for signature 'LogisticLogNormalOrdinal' probFunction(model, grade, ...)
probFunction(model, ...) ## S4 method for signature 'GeneralModel' probFunction(model, ...) ## S4 method for signature 'ModelTox' probFunction(model, ...) ## S4 method for signature 'LogisticLogNormalOrdinal' probFunction(model, grade, ...)
model |
( |
... |
model specific parameters. |
grade |
( |
A prob()
function that computes toxicity probabilities.
probFunction(GeneralModel)
:
probFunction(ModelTox)
:
probFunction(LogisticLogNormalOrdinal)
:
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)
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
probit(x)
probit(x)
x |
the function argument |
the probit(x)
ProbitLogNormal
ProbitLogNormal
is the class for probit regression model with a
bivariate normal prior on the intercept and log slope.
ProbitLogNormal(mean, cov, ref_dose = 1) .DefaultProbitLogNormal()
ProbitLogNormal(mean, cov, ref_dose = 1) .DefaultProbitLogNormal()
mean |
( |
cov |
( |
ref_dose |
( |
The covariate is the natural logarithm of dose divided by a
reference dose
, i.e.:
where is the probability of observing a DLT for a given dose
.
The prior
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 .DefaultProbitLogNormal()
function.
ModelLogNormal
, LogisticNormal
, LogisticLogNormal
,
LogisticLogNormalSub
, ProbitLogNormalRel
.
my_model <- ProbitLogNormal( mean = c(-0.85, 1), cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2), ref_dose = 7.2 )
my_model <- ProbitLogNormal( mean = c(-0.85, 1), cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2), ref_dose = 7.2 )
ProbitLogNormalRel
ProbitLogNormalRel
is the class for probit regression model with a bivariate
normal prior on the intercept and log slope.
ProbitLogNormalRel(mean, cov, ref_dose = 1) .DefaultProbitLogNormalRel()
ProbitLogNormalRel(mean, cov, ref_dose = 1) .DefaultProbitLogNormalRel()
mean |
( |
cov |
( |
ref_dose |
( |
The covariate is the dose divided by a reference dose
,
i.e.:
where is the probability of observing a DLT for a given dose
.
The prior
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.
ModelLogNormal
, LogisticNormal
, LogisticLogNormal
,
LogisticLogNormalSub
, ProbitLogNormal
.
my_model <- ProbitLogNormalRel( mean = c(-0.85, 1), cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2) )
my_model <- ProbitLogNormalRel( mean = c(-0.85, 1), cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2) )
Initialization function for 'PseudoDualFlexiSimulations' class
PseudoDualFlexiSimulations(sigma2betaWest, ...)
PseudoDualFlexiSimulations(sigma2betaWest, ...)
sigma2betaWest |
please refer to |
... |
additional parameters from |
the PseudoDualFlexiSimulations
object
ModelTox
class and the efficacy model from EffFlexi
class
It contains all slots from
GeneralSimulations
, PseudoSimulations
and PseudoDualSimulations
object.
In comparison to the parent class PseudoDualSimulations
,
it contains additional slots to
capture the sigma2betaW estimates.This is a class which captures the trial simulations design using both the
DLE and efficacy responses. The design of model from ModelTox
class and the efficacy model from EffFlexi
class
It contains all slots from
GeneralSimulations
, PseudoSimulations
and PseudoDualSimulations
object.
In comparison to the parent class PseudoDualSimulations
,
it contains additional slots to
capture the sigma2betaW estimates.
.DefaultPseudoDualFlexiSimulations()
.DefaultPseudoDualFlexiSimulations()
sigma2betaWest
the vector of the final posterior mean sigma2betaW estimates
Typically, end users will not use the .DefaultPseudoFlexiSimulations()
function.
PseudoDualSimulations
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.
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()
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()
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 |
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.
Do not use the .DefaultPseudoDualSimulations()
function.
It contains all slots from PseudoSimulationsSummary
object. In addition to
the slots in the parent class PseudoSimulationsSummary
, it contains four
more slots for the efficacy model fit information.
.DefaultPseudoDualSimulationsSummary()
.DefaultPseudoDualSimulationsSummary()
Note that objects should not be created by users, therefore no initialization function is provided for this class.
targetGstar
the target dose level such that its gain value is at maximum
targetGstarAtDoseGrid
the dose level at dose Grid closest and below Gstar
GstarSummary
the six-number table summary (lowest, 25th, 50th (median), 75th percentile, mean and highest value) of the final Gstar values obtained across all simulations
ratioGstarSummary
the six-number summary table of the ratios of the upper to the lower 95% credibility intervals of the final Gstar across all simulations
EffFitAtDoseMostSelected
fitted expected mean efficacy value at dose most often selected
meanEffFit
list with mean, lower (2.5%) and upper (97.5%) quantiles of the fitted expected efficacy value at each dose level.
Typically, end users will not use the .DefaultPseudoDualSimulationsSummary()
function.
PseudoSimulations
This class captures trial simulations from designs using pseudo model.
It has additional slots fit
and stop_reasons
compared to the
general class GeneralSimulations
.
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()
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()
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 |
fit
(list
)
final fit values.
final_td_target_during_trial_estimates
(numeric
)
final estimates of the td_target_during_trial
.
final_td_target_end_of_trial_estimates
(numeric
)
final estimates of the td_target_end_of_trial
.
final_td_target_during_trial_at_dose_grid
(numeric
)
dose levels at dose grid closest below the final td_target_during_trial
estimates.
final_td_target_end_of_trial_at_dose_grid
(numeric
)
dose levels at dose grid closest below the final td_target_end_of_trial
estimates.
final_tdeot_cis
(list
)
95% credibility intervals of the final estimates for td_target_end_of_trial
.
final_tdeot_ratios
(numeric
)
ratio of the upper to the lower 95%
credibility intervals for td_target_end_of_trial
.
final_cis
(list
)
final 95% credibility intervals for td_target_end_of_trial
estimates.
final_ratios
(numeric
)
final ratios of the upper to the lower 95%
credibility interval for td_target_end_of_trial
.
stop_report
(matrix
)
outcomes of stopping rules.
stop_reasons
(list
)
reasons for stopping each simulation run.
Typically, end users will not use the .DefaultPseudoSimulations()
function.
Note that objects should not be created by users, therefore no initialization function is provided for this class.
targetEndOfTrial
the target probability of DLE wanted at the end of a trial
targetDoseEndOfTrial
the dose level corresponds to the target probability of DLE wanted at the end of a trial, TDEOT
targetDoseEndOfTrialAtDoseGrid
the dose level at dose grid corresponds to the target probability of DLE wanted at the end of a trial
targetDuringTrial
the target probability of DLE wanted during a trial
targetDoseDuringTrial
the dose level corresponds to the target probability of DLE wanted during the trial. TDDT
targetDoseDuringTrialAtDoseGrid
the dose level at dose grid corresponds to the target probability of DLE wanted during a trial
TDEOTSummary
the six-number table summary, include the lowest, the 25th precentile (lower quartile), the 50th percentile (median), the mean, the 27th 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 simulations
TDDTSummary
the six-number table summary, include the lowest, the 25th precentile (lower quartile), the 50th percentile (median), the mean, the 27th percentile and the highest values of the final dose levels obtained corresponds to the target probability of DLE want during a trial across all simulations
FinalDoseRecSummary
the six-number table summary, include the lowest, the 25th precentile (lower quartile), the 50th percentile (median), the mean, the 27th 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 simulations
ratioTDEOTSummary
the six-number summary table of the final ratios of the upper to the lower 95% credibility intervals of the final TDEOTs across all simulations
FinalRatioSummary
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 simulations #@slot doseRec the dose level that will be recommend for subsequent study
nsim
number of simulations
propDLE
proportions of DLE in the trials
meanToxRisk
mean toxicity risks for the patients
doseSelected
doses selected as MTD (targetDoseEndOfTrial)
toxAtDosesSelected
true toxicity at doses selected
propAtTargetEndOfTrial
Proportion of trials selecting at the doseGrid closest below the MTD, the targetDoseEndOfTrial
propAtTargetDuringTrial
Proportion of trials selecting at the doseGrid closest below the targetDoseDuringTrial
doseMostSelected
dose most often selected as MTD
obsToxRateAtDoseMostSelected
observed toxicity rate at dose most often selected
nObs
number of patients overall
nAboveTargetEndOfTrial
number of patients treated above targetDoseEndOfTrial
nAboveTargetDuringTrial
number of patients treated above targetDoseDuringTrial
doseGrid
the dose grid that has been used
fitAtDoseMostSelected
fitted toxicity rate at dose most often selected
meanFit
list with the average, lower (2.5%) and upper (97.5%) quantiles of the mean fitted toxicity at each dose level
stop_report
matrix of stopping rule outcomes
This function uses generalized simulated annealing to optimize
a LogisticNormal
model to be as close as possible
to the given prior quantiles.
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) )
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) )
dosegrid |
the dose grid |
refDose |
the reference dose |
lower |
the lower quantiles |
median |
the medians |
upper |
the upper quantiles |
level |
the credible level of the (lower, upper) intervals (default: 0.95) |
logNormal |
use the log-normal prior? (not default) otherwise, the normal prior for the logistic regression coefficients is used |
parstart |
starting values for the parameters. By default, these are determined from the medians supplied. |
parlower |
lower bounds on the parameters (intercept alpha and the slope beta, the corresponding standard deviations and the correlation.) |
parupper |
upper bounds on the parameters |
seed |
seed for random number generation |
verbose |
be verbose? (default) |
control |
additional options for the optimisation routine, see
|
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)
A Reference Class to represent sequentially updated reporting objects.
object
The object from which to report
df
the data frame to which columns are sequentially added
dfNames
the names to which strings are sequentially added
RuleDesign
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.
RuleDesign(nextBest, cohort_size, data, startingDose) .DefaultRuleDesign() ThreePlusThreeDesign(doseGrid)
RuleDesign(nextBest, cohort_size, data, startingDose) .DefaultRuleDesign() ThreePlusThreeDesign(doseGrid)
nextBest |
( |
cohort_size |
( |
data |
( |
startingDose |
( |
doseGrid |
( |
ThreePlusThreeDesign()
: creates a new 3+3 design object from a dose grid.
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 in data
.
Typically, end users will not use the .DefaultRuleDesign()
function.
# 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))
# 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
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.
RuleDesignOrdinal(next_best, cohort_size, data, starting_dose) .DefaultRuleDesignOrdinal()
RuleDesignOrdinal(next_best, cohort_size, data, starting_dose) .DefaultRuleDesignOrdinal()
next_best |
( |
cohort_size |
( |
data |
( |
starting_dose |
( |
next_best
(NextBestOrdinal
)
how to find the next best dose.
cohort_size
(CohortSizeOrdinal
)
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 in data
.
Typically, end users will not use the .DefaultRuleDesignOrdinal()
function.
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 )
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
SafetyWindow
is a class for safety window.
.DefaultSafetyWindow()
.DefaultSafetyWindow()
Typically, end users will not use the .DefaultSafetyWindow()
function.
SafetyWindowSize
, SafetyWindowConst
.
SafetyWindowConst
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).
SafetyWindowConst(gap, follow, follow_min) .DefaultSafetyWindowConst()
SafetyWindowConst(gap, follow, follow_min) .DefaultSafetyWindowConst()
gap |
see slot definition. |
follow |
see slot definition. |
follow_min |
see slot definition. |
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.
Typically, end users will not use the .DefaultSafetyWindowConst()
function.
# 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 )
# 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
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.
SafetyWindowSize(gap, size, follow, follow_min) .DefaultSafetyWindowSize()
SafetyWindowSize(gap, size, follow, follow_min) .DefaultSafetyWindowSize()
gap |
see slot definition. |
size |
see slot definition. |
follow |
see slot definition. |
follow_min |
see slot definition. |
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 the gap
based 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 both gap = list(c(7, 3), c(9, 5))
and
size = 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.
Typically, end users will not use the .DefaultSafetyWindowSize()
function.
# 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 )
# 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
Samples
is the class to store the MCMC samples.
Samples(data, options) .DefaultSamples()
Samples(data, options) .DefaultSamples()
data |
see slot definition. |
options |
see slot definition. |
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.
Typically, end users will not use the .DefaultSamples()
function.
# 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 )
# 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 )
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
.
saveSample(object, iteration, ...) ## S4 method for signature 'McmcOptions' saveSample(object, iteration, ...)
saveSample(object, iteration, ...) ## S4 method for signature 'McmcOptions' saveSample(object, iteration, ...)
object |
( |
iteration |
( |
... |
not used. |
TRUE
if this sample should be saved.
saveSample(McmcOptions)
: determine if a sample should be saved.
# 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)
# 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)
This code is basically copied from stats:::simulate.lm
.
set_seed(seed = NULL)
set_seed(seed = NULL)
seed |
an object specifying if and how the random number generator
should be initialized ("seeded"). Either |
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 the dual-endpoint simulations
## S4 method for signature 'DualSimulationsSummary' show(object)
## S4 method for signature 'DualSimulationsSummary' show(object)
object |
the |
invisibly returns a data frame of the results with one row and appropriate column names
# 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 ))
# 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
## S4 method for signature 'GeneralSimulationsSummary' show(object)
## S4 method for signature 'GeneralSimulationsSummary' show(object)
object |
the |
invisibly returns a data frame of the results with one row and appropriate column names
Show the summary of Pseudo Dual simulations summary
## S4 method for signature 'PseudoDualSimulationsSummary' show(object)
## S4 method for signature 'PseudoDualSimulationsSummary' show(object)
object |
the |
invisibly returns a data frame of the results with one row and appropriate column names
# 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)
# 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 the simulations
## S4 method for signature 'PseudoSimulationsSummary' show(object)
## S4 method for signature 'PseudoSimulationsSummary' show(object)
object |
the |
invisibly returns a data frame of the results with one row and appropriate column names
# 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)
# 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 the simulations
## S4 method for signature 'SimulationsSummary' show(object)
## S4 method for signature 'SimulationsSummary' show(object)
object |
the |
invisibly returns a data frame of the results with one row and appropriate column names
# 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
# 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
DADesign
)Simulate outcomes from a time-to-DLT augmented CRM design (DADesign
)
## 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(), ... )
## 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(), ... )
object |
the |
nsim |
the number of simulations (default: 1) |
seed |
see |
truthTox |
a function which takes as input a dose (vector) and returns the
true probability (vector) for toxicity and the time DLT occurs. Additional
arguments can be supplied in |
truthSurv |
a CDF which takes as input a time (vector) and returns the true cumulative probability (vector) that the DLT would occur conditioning on the patient has DLTs. |
trueTmax |
( |
args |
data frame with arguments for the |
firstSeparate |
enroll the first patient separately from the rest of the cohort? (not default) If yes, the cohort will be closed if a DLT occurs in this patient. |
deescalate |
deescalation when a DLT occurs in cohorts with lower dose level. |
mcmcOptions |
object of class |
DA |
document or rename this parameter to make it more meaningful |
parallel |
should the simulation runs be parallelized across the clusters of the computer? (not default) |
nCores |
how many cores should be used for parallel computing? Defaults to the number of cores on the machine (maximum 5) |
derive |
a named list of functions which derives statistics, based on the vector of posterior MTD samples. Each list element must therefore accept one and only one argument, which is a numeric vector, and return a number. |
... |
not used |
an object of class Simulations
# 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
# 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
## 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(), ... )
## 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(), ... )
object |
the |
nsim |
the number of simulations (default: 1) |
seed |
see |
truth |
a function which takes as input a dose (vector) and returns the
true probability (vector) for toxicity. Additional arguments can be supplied
in |
args |
data frame with arguments for the |
firstSeparate |
enroll the first patient separately from the rest of the cohort? (not default) If yes, the cohort will be closed if a DLT occurs in this patient. |
mcmcOptions |
object of class |
parallel |
should the simulation runs be parallelized across the clusters of the computer? (not default) |
nCores |
how many cores should be used for parallel computing? Defaults to the number of cores on the machine, maximum 5. |
derive |
a named list of functions which derives statistics, based on the vector of posterior MTD samples. Each list element must therefore accept one and only one argument, which is a numeric vector, and return a number. |
... |
not used |
an object of class Simulations
# 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
# 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
DesignGrouped
ClassA simulate method for DesignGrouped
designs.
## 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), ... )
## 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), ... )
object |
( |
nsim |
( |
seed |
( |
truth |
( |
combo_truth |
( |
args |
( |
firstSeparate |
( |
mcmcOptions |
( |
parallel |
( |
nCores |
( |
... |
not used. |
A list of mono
and combo
simulation results as Simulations
objects.
# 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]])
# 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
## 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(), ... )
## 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(), ... )
object |
the |
nsim |
the number of simulations (default: 1) |
seed |
see |
trueTox |
a function which takes as input a dose (vector) and returns the
true probability (vector) for toxicity. Additional arguments can be supplied
in |
trueBiomarker |
a function which takes as input a dose (vector) and
returns the true biomarker level (vector). Additional arguments can be
supplied in |
args |
data frame with arguments for the |
sigma2W |
variance for the biomarker measurements |
rho |
correlation between toxicity and biomarker measurements (default: 0) |
firstSeparate |
enroll the first patient separately from the rest of the cohort? (not default) If yes, the cohort will be closed if a DLT occurs in this patient. |
mcmcOptions |
object of class |
parallel |
should the simulation runs be parallelized across the clusters of the computer? (not default) |
nCores |
how many cores should be used for parallel computing? Defaults to the number of cores on the machine, maximum 5. |
derive |
a named list of functions which derives statistics, based on the vector of posterior MTD samples. Each list element must therefore accept one and only one argument, which is a numeric vector, and return a number. |
... |
not used |
an object of class DualSimulations
# 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
# 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
DualResponsesDesign
where DLEmodel 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
processThis is a methods to simulate dose escalation procedure using both DLE and efficacy responses.
This is a method based on the DualResponsesDesign
where DLEmodel 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
## 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), ... )
## 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), ... )
object |
the |
nsim |
the number of simulations (default :1) |
seed |
see |
trueDLE |
a function which takes as input a dose (vector) and returns the true probability
(vector) of the occurrence of a DLE. Additional arguments can be supplied in |
trueEff |
a function which takes as input a dose (vector) and returns the expected efficacy
responses (vector). Additional arguments can be supplied in |
trueNu |
the precision, the inverse of the variance of the efficacy responses |
args |
data frame with arguments for the |
firstSeparate |
enroll the first patient separately from the rest of the cohort? (not default) If yes, the cohort will be closed if a DLT occurs in this patient. |
parallel |
should the simulation runs be parallelized across the clusters of the computer? (not default) |
nCores |
how many cores should be used for parallel computing? Defaults to the number of cores on the machine, maximum 5. |
... |
not used |
an object of class PseudoDualSimulations
# 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
# 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
DualResponsesSamplesDesign
where DLEmodel
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
processThis is a methods to simulate dose escalation procedure using both DLE and efficacy responses.
This is a method based on the DualResponsesSamplesDesign
where DLEmodel
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
## 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), ... )
## 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), ... )
object |
the |
nsim |
the number of simulations (default :1) |
seed |
see |
trueDLE |
a function which takes as input a dose (vector) and returns the true probability
(vector) of the occurrence of a DLE. Additional arguments can be supplied in |
trueEff |
a function which takes as input a dose (vector) and returns the expected
efficacy responses (vector). Additional arguments can be supplied in |
trueNu |
(not with codeEffFlexi) the precision, the inverse of the variance of the efficacy responses |
trueSigma2 |
(only with codeEffFlexi) the true variance of the efficacy responses which must be a single positive scalar. |
trueSigma2betaW |
(only with codeEffFlexi) the true variance for the random walk model used for smoothing. This must be a single positive scalar. |
args |
data frame with arguments for the |
firstSeparate |
enroll the first patient separately from the rest of the cohort? (not default) If yes, the cohort will be closed if a DLT occurs in this patient. |
mcmcOptions |
object of class |
parallel |
should the simulation runs be parallelized across the clusters of the computer? (not default) |
nCores |
how many cores should be used for parallel computing? Defaults to the number of cores on the machine, maximum 5. |
... |
not used. |
an object of class PseudoDualSimulations
or
PseudoDualFlexiSimulations
# 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
# 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
## S4 method for signature 'RuleDesign' simulate( object, nsim = 1L, seed = NULL, truth, args = NULL, parallel = FALSE, nCores = min(parallel::detectCores(), 5L), ... )
## S4 method for signature 'RuleDesign' simulate( object, nsim = 1L, seed = NULL, truth, args = NULL, parallel = FALSE, nCores = min(parallel::detectCores(), 5L), ... )
object |
the |
nsim |
the number of simulations (default: 1) |
seed |
see |
truth |
a function which takes as input a dose (vector) and returns the
true probability (vector) for toxicity. Additional arguments can be supplied
in |
args |
data frame with arguments for the |
parallel |
should the simulation runs be parallelized across the clusters of the computer? (not default) |
nCores |
how many cores should be used for parallel computing? Defaults to the number of cores on the machine, maximum 5. |
... |
not used |
an object of class GeneralSimulations
# 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
# 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
TDDesign
where model used are of
ModelTox
class object and no samples are involved.This is a methods 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.
## S4 method for signature 'TDDesign' simulate( object, nsim = 1L, seed = NULL, truth, args = NULL, firstSeparate = FALSE, parallel = FALSE, nCores = min(parallel::detectCores(), 5L), ... )
## S4 method for signature 'TDDesign' simulate( object, nsim = 1L, seed = NULL, truth, args = NULL, firstSeparate = FALSE, parallel = FALSE, nCores = min(parallel::detectCores(), 5L), ... )
object |
the |
nsim |
the number of simulations (default :1) |
seed |
see |
truth |
a function which takes as input a dose (vector) and returns the true probability
(vector) of the occurrence of a DLE. Additional arguments can be supplied in |
args |
data frame with arguments for the |
firstSeparate |
enroll the first patient separately from the rest of the cohort? (not default) If yes, the cohort will be closed if a DLT occurs in this patient. |
parallel |
should the simulation runs be parallelized across the clusters of the computer? (not default) |
nCores |
how many cores should be used for parallel computing? Defaults to the number of cores on the machine, maximum 5. |
... |
not used |
an object of class PseudoSimulations
@export @keywords methods
# 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
# 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
TDsamplesDesign
where model used are of
ModelTox
class object DLE samples are also usedThis is a methods 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
## 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), ... )
## 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), ... )
object |
the |
nsim |
the number of simulations (default :1) |
seed |
see |
truth |
a function which takes as input a dose (vector) and returns the true probability
(vector) of the occurrence of a DLE. Additional arguments can be supplied in |
args |
data frame with arguments for the |
firstSeparate |
enroll the first patient separately from the rest of the cohort? (not default) If yes, the cohort will be closed if a DLT occurs in this patient. |
mcmcOptions |
object of class |
parallel |
should the simulation runs be parallelized across the clusters of the computer? (not default) |
nCores |
how many cores should be used for parallel computing? Defaults to the number of cores on the machine, maximum 5. |
... |
not used |
an object of class PseudoSimulations
@export @keywords methods
# 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
# 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
Simulations
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
.
Simulations(fit, stop_reasons, stop_report, additional_stats, ...) .DefaultSimulations()
Simulations(fit, stop_reasons, stop_report, additional_stats, ...) .DefaultSimulations()
fit |
( |
stop_reasons |
( |
stop_report |
see |
additional_stats |
( |
... |
additional parameters from |
fit
(list
)
final fits
stop_reasons
(list
)
stopping reasons for each simulation run
stop_report
matrix of stopping rule outcomes
additional_stats
list of additional statistical summary
Typically, end users will not use the .DefaultSimulations()
function.
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 )
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
In addition to the slots in the parent class GeneralSimulationsSummary
,
it contains two slots with model fit information.
.DefaultSimulationsSummary()
.DefaultSimulationsSummary()
stop_report
(matrix
)
matrix of stopping rule outcomes
fit_at_dose_most_selected
(numeric
)
fitted toxicity rate at dose most often selected
additional_stats
(list
)
list of additional statistical summary
mean_fit
(list
)
list with the average, lower (2.5%) and upper (97.5%)
quantiles of the mean fitted toxicity at each dose level
Typically, end users will not use the .DefaultSimulationsSummary()
function.
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.
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, ...)
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, ...)
object |
( |
... |
not used. |
dose |
( |
data |
the data input, an object of class |
A size of a given object.
size(McmcOptions)
: compute the number of MCMC samples based on McmcOptions
object.
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 from Samples
object.
# 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)
# 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)
Stopping
Stopping
is a class for stopping rules.
report_label
(string
)
a label for the stopping report. The meaning
of this parameter is twofold. If it is equal to NA_character_
(default),
the report_label
will 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.
StoppingList
, StoppingCohortsNearDose
, StoppingPatientsNearDose
,
StoppingMinCohorts
, StoppingMinPatients
, StoppingTargetProb
,
StoppingMTDdistribution
, StoppingTargetBiomarker
, StoppingHighestDose
StoppingMTDCV
, StoppingLowestDoseHSRBeta
, StoppingSpecificDose
.
StoppingAll
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
.
StoppingAll(stop_list, report_label = NA_character_) .DefaultStoppingAll()
StoppingAll(stop_list, report_label = NA_character_) .DefaultStoppingAll()
stop_list |
( |
report_label |
( |
stop_list
(list
)
list of stopping rules.
report_label
label for reporting
Typically, end users will not use the .DefaultStoppingAll()
function.
# 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) )
# 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
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
.
StoppingAny(stop_list, report_label = NA_character_) .DefaultStoppingAny()
StoppingAny(stop_list, report_label = NA_character_) .DefaultStoppingAny()
stop_list |
( |
report_label |
( |
stop_list
(list
)
list of stopping rules.
report_label
label for reporting
Typically, end users will not use the .DefaultStoppingAny()
function.
# 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) )
# 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
StoppingCohortsNearDose
is the class for stopping based on number of
cohorts near to next best dose.
StoppingCohortsNearDose( nCohorts = 2L, percentage = 50, report_label = NA_character_ ) .DefaultStoppingCohortsNearDose()
StoppingCohortsNearDose( nCohorts = 2L, percentage = 50, report_label = NA_character_ ) .DefaultStoppingCohortsNearDose()
nCohorts |
( |
percentage |
( |
report_label |
( |
nCohorts
(number
)
number of required cohorts.
percentage
(number
)
percentage (between and including 0 and 100)
within the next best dose the cohorts must lie.
Typically, end users will not use the .DefaultStoppingCohortsNearDose()
function.
# 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 )
# 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
StoppingExternal
is the class for stopping based on an external flag.
StoppingExternal(report_label = NA_character_) .DefaultStoppingExternal(report_label = NA_character_)
StoppingExternal(report_label = NA_character_) .DefaultStoppingExternal(report_label = NA_character_)
report_label |
( |
Typically, end users will not use the .DefaultStoppingExternal()
function.
my_stopping <- StoppingExternal()
my_stopping <- StoppingExternal()
StoppingHighestDose
StoppingHighestDose
is the class for stopping based on the highest dose.
That is, the stopping occurs when the highest dose is reached.
StoppingHighestDose(report_label = NA_character_) .DefaultStoppingHighestDose()
StoppingHighestDose(report_label = NA_character_) .DefaultStoppingHighestDose()
report_label |
( |
Typically, end users will not use the .DefaultStoppingHighestDose()
function.
# 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.
# 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
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
.
StoppingList(stop_list, summary) .DefaultStoppingList()
StoppingList(stop_list, summary) .DefaultStoppingList()
stop_list |
( |
summary |
( |
stop_list
(list
)
list of stopping rules.
summary
(function
)
a summary function to combine the results of
the stopping rules into a single result.
Typically, end users will not use the .DefaultStoppingList()
function.
# 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 )
# 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
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.
StoppingLowestDoseHSRBeta( target = 0.3, prob = 0.95, a = 1, b = 1, report_label = NA_character_ ) .DefaultStoppingLowestDoseHSRBeta()
StoppingLowestDoseHSRBeta( target = 0.3, prob = 0.95, a = 1, b = 1, report_label = NA_character_ ) .DefaultStoppingLowestDoseHSRBeta()
target |
( |
prob |
( |
a |
( |
b |
( |
report_label |
( |
target
(proportion
)
the target toxicity.
prob
(proportion
)
the threshold probability for the lowest dose
being toxic.
a
(number
)
shape parameter of probability distribution
Beta (a,b).
b
(number
)
shape parameter of probability distribution
Beta (a,b).
This stopping rule is independent from the underlying model.
Typically, end users will not use the .DefaultStoppingLowestDoseHSRBeta()
function.
# 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 )
# 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 )
StoppingMaxGainCIRatio
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.
StoppingMaxGainCIRatio( target_ratio = 5, prob_target = 0.3, report_label = NA_character_ ) .DefaultStoppingMaxGainCIRatio()
StoppingMaxGainCIRatio( target_ratio = 5, prob_target = 0.3, report_label = NA_character_ ) .DefaultStoppingMaxGainCIRatio()
target_ratio |
( |
prob_target |
( |
report_label |
( |
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.
# 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()
# 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
StoppingMinCohorts
is the class for stopping based on minimum number of
cohorts.
StoppingMinCohorts(nCohorts = 2L, report_label = NA_character_) .DefaultStoppingMinCohorts()
StoppingMinCohorts(nCohorts = 2L, report_label = NA_character_) .DefaultStoppingMinCohorts()
nCohorts |
( |
report_label |
( |
nCohorts
(number
)
minimum required number of cohorts.
Typically, end users will not use the .DefaultStoppingMinCohorts()
function.
# As example, here is the rule for stopping the study if at least 6 cohorts # were already dosed. my_stopping <- StoppingMinCohorts(nCohorts = 6)
# As example, here is the rule for stopping the study if at least 6 cohorts # were already dosed. my_stopping <- StoppingMinCohorts(nCohorts = 6)
StoppingMinPatients
StoppingMinPatients
is the class for stopping based on minimum number of
patients
StoppingMinPatients(nPatients = 20L, report_label = NA_character_) .DefaultStoppingMinPatients()
StoppingMinPatients(nPatients = 20L, report_label = NA_character_) .DefaultStoppingMinPatients()
nPatients |
( |
report_label |
( |
nPatients
(number
)
minimum allowed number of patients.
Typically, end users will not use the .DefaultStoppingMinPatients()
function.
# As example, here is the rule for stopping the study if at least 20 patients # were already dosed my_stopping <- StoppingMinPatients(nPatients = 20)
# As example, here is the rule for stopping the study if at least 20 patients # were already dosed my_stopping <- StoppingMinPatients(nPatients = 20)
StoppingMissingDose
StoppingMissingDose
is the class for stopping based on NA returned by
next best dose.
StoppingMissingDose(report_label = NA_character_) .DefaultStoppingMissingDose()
StoppingMissingDose(report_label = NA_character_) .DefaultStoppingMissingDose()
report_label |
( |
Typically, end users will not use the .DefaultStoppingMissingDose()
function.
# The rule for stopping the study if NA or Placebo is returned as # next best dose. my_stopping <- StoppingMissingDose()
# The rule for stopping the study if NA or Placebo is returned as # next best dose. my_stopping <- StoppingMissingDose()
StoppingMTDCV
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.
StoppingMTDCV(target = 0.3, thresh_cv = 40, report_label = NA_character_) .DefaultStoppingMTDCV()
StoppingMTDCV(target = 0.3, thresh_cv = 40, report_label = NA_character_) .DefaultStoppingMTDCV()
target |
( |
thresh_cv |
( |
report_label |
( |
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 to tresh_cv
.
Typically, end users will not use the .DefaultStoppingMTDCV()
function.
# 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)
# 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
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.
StoppingMTDdistribution( target = 0.33, thresh = 0.5, prob = 0.9, report_label = NA_character_ ) .DefaultStoppingMTDdistribution()
StoppingMTDdistribution( target = 0.33, thresh = 0.5, prob = 0.9, report_label = NA_character_ ) .DefaultStoppingMTDdistribution()
target |
( |
thresh |
( |
prob |
( |
report_label |
( |
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.
Typically, end users will not use the .DefaultStoppingMTDDistribution()
function.
# 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 )
# 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 )
StoppingOrdinal
StoppingOrdinal
is the class for stopping based on a Stopping rule applied
to a specific toxicity grade in an ordinal CRM trial
StoppingOrdinal(grade, rule) .DefaultStoppingOrdinal()
StoppingOrdinal(grade, rule) .DefaultStoppingOrdinal()
grade |
( |
rule |
( |
grade
(integer
)
the grade to which the rule should be applied
rule
(Stopping
)
the rule to apply
Typically, end users will not use the .DefaultStoppingOrdinal()
function.
StoppingOrdinal( 1L, StoppingTargetProb(target = c(0.2, 0.35), prob = 0.6) )
StoppingOrdinal( 1L, StoppingTargetProb(target = c(0.2, 0.35), prob = 0.6) )
StoppingPatientsNearDose
StoppingPatientsNearDose
is the class for stopping based on number of
patients near to next best dose.
StoppingPatientsNearDose( nPatients = 10L, percentage = 50, report_label = NA_character_ ) .DefaultStoppingPatientsNearDose()
StoppingPatientsNearDose( nPatients = 10L, percentage = 50, report_label = NA_character_ ) .DefaultStoppingPatientsNearDose()
nPatients |
( |
percentage |
( |
report_label |
( |
nPatients
(number
)
number of required patients.
percentage
(number
)
percentage (between and including 0 and 100)
within the next best dose the patients must lie.
Typically, end users will not use the .DefaultStoppingPatientsNearDose()
function.
# 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 )
# 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
StoppingSpecificDose
is the class for testing a stopping rule at specific
dose of the dose grid and not at the next best dose.
StoppingSpecificDose( rule = StoppingTargetProb(target = c(0, 0.3), prob = 0.8), dose = 80, report_label = NA_character_ ) .DefaultStoppingSpecificDose()
StoppingSpecificDose( rule = StoppingTargetProb(target = c(0, 0.3), prob = 0.8), dose = 80, report_label = NA_character_ ) .DefaultStoppingSpecificDose()
rule |
( |
dose |
( |
report_label |
( |
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.
Typically, end users will not use the .DefaultStoppingSpecificDose()
function.
# 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 )
# 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 )
StoppingTargetBiomarker
StoppingTargetBiomarker
is a class for stopping based on probability of
target biomarker.
StoppingTargetBiomarker( target = c(0.9, 1), prob = 0.3, is_relative = TRUE, report_label = NA_character_ ) .DefaultStoppingTargetBiomarker()
StoppingTargetBiomarker( target = c(0.9, 1), prob = 0.3, is_relative = TRUE, report_label = NA_character_ ) .DefaultStoppingTargetBiomarker()
target |
( |
prob |
( |
is_relative |
( |
report_label |
( |
target
(numeric
)
the biomarker target range that needs to be
reached. For example, target = c(0.8, 1.0)
with is_relative = TRUE
means that we target a dose with at least 80% of maximum biomarker level.
is_relative
(flag
)
is target relative? If it so (default), then
the target
is interpreted relative to the maximum, so it must be a
probability range. Otherwise, the target
is interpreted as absolute
biomarker range.
prob
(proportion
)
required target probability (except 0 or 1) for
reaching sufficient precision.
Typically, end users will not use the .DefaultStoppingTargetBiomarker()
function.
# 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)
# 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
StoppingTargetProb
is the class for stopping based on the probability of
the DLT rate being in the target toxicity interval.
StoppingTargetProb( target = c(0.2, 0.35), prob = 0.4, report_label = NA_character_ ) .DefaultStoppingTargetProb()
StoppingTargetProb( target = c(0.2, 0.35), prob = 0.4, report_label = NA_character_ ) .DefaultStoppingTargetProb()
target |
( |
prob |
( |
report_label |
( |
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.
Typically, end users will not use the .DefaultStoppingTargetProb()
function.
# 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)
# 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)
StoppingTDCIRatio
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
).
StoppingTDCIRatio( target_ratio = 5, prob_target = 0.3, report_label = NA_character_ ) .DefaultStoppingTDCIRatio()
StoppingTDCIRatio( target_ratio = 5, prob_target = 0.3, report_label = NA_character_ ) .DefaultStoppingTDCIRatio()
target_ratio |
( |
prob_target |
( |
report_label |
( |
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.
Typically, end users will not use the .DefaultStoppingTDCIRatio()
function.
# 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 )
# 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 )
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.
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, ...)
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, ...)
stopping |
( |
dose |
the recommended next best dose. |
samples |
( |
model |
( |
data |
( |
... |
additional arguments without method dispatch. |
external |
( |
TDderive |
the function which derives from the input, a vector of the posterior samples called
|
Effmodel |
the efficacy model of |
Effsamples |
the efficacy samples of |
Gstarderive |
the function which derives from the input, a vector of the posterior Gstar (the dose
which gives the maximum gain value) samples
called |
logical value: TRUE
if the trial can be stopped, FALSE
otherwise. It should have an attribute message
which gives the reason
for the decision.
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 on 'StoppingTDCIRatio' class when
reaching the target ratio of the upper to the lower 95% credibility
interval of the estimate (TDtargetEndOfTrial). This is a stopping rule which incorporate only
DLE responses and DLE samples are given
stopTrial(
stopping = StoppingTDCIRatio,
dose = ANY,
samples = missing,
model = ModelTox,
data = ANY
)
: Stop based on 'StoppingTDCIRatio' class
when reaching the target ratio of the upper to the lower 95% credibility
interval of the estimate (TDtargetEndOfTrial). This is a stopping rule which incorporate 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
incorporate 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
incorporate DLE and efficacy responses without DLE and efficacy samples involved.
## 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
## 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 the dual-endpoint design simulations, relative to given true dose-toxicity and dose-biomarker curves
## S4 method for signature 'DualSimulations' summary(object, trueTox, trueBiomarker, target = c(0.2, 0.35), ...)
## S4 method for signature 'DualSimulations' summary(object, trueTox, trueBiomarker, target = c(0.2, 0.35), ...)
object |
the |
trueTox |
a function which takes as input a dose (vector) and returns the true probability (vector) for toxicity. |
trueBiomarker |
a function which takes as input a dose (vector) and returns the true biomarker level (vector). |
target |
the target toxicity interval (default: 20-35%) used for the computations |
... |
Additional arguments can be supplied here for |
an object of class DualSimulationsSummary
# 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 )
# 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 simulations, relative to a given truth
## S4 method for signature 'GeneralSimulations' summary(object, truth, target = c(0.2, 0.35), ...)
## S4 method for signature 'GeneralSimulations' summary(object, truth, target = c(0.2, 0.35), ...)
object |
the |
truth |
a function which takes as input a dose (vector) and returns the true probability (vector) for toxicity |
target |
the target toxicity interval (default: 20-35%) used for the computations |
... |
Additional arguments can be supplied here for |
an object of class GeneralSimulationsSummary
Summary for Pseudo Dual responses simulations given a pseudo DLE model and the Flexible efficacy model.
## S4 method for signature 'PseudoDualFlexiSimulations' summary( object, trueDLE, trueEff, targetEndOfTrial = 0.3, targetDuringTrial = 0.35, ... )
## S4 method for signature 'PseudoDualFlexiSimulations' summary( object, trueDLE, trueEff, targetEndOfTrial = 0.3, targetDuringTrial = 0.35, ... )
object |
the |
trueDLE |
a function which takes as input a dose (vector) and returns the true probability of DLE (vector) |
trueEff |
a vector which takes as input the true mean efficacy values at all dose levels (in order) |
targetEndOfTrial |
the target probability of DLE that are used at the end of a trial. Default at 0.3. |
targetDuringTrial |
the target probability of DLE that are used during the trial. Default at 0.35. |
... |
Additional arguments can be supplied here for |
an object of class PseudoDualSimulationsSummary
# 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
# 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
Summary for Pseudo Dual responses simulations, relative to a given pseudo DLE and efficacy model (except the EffFlexi class model)
## S4 method for signature 'PseudoDualSimulations' summary( object, trueDLE, trueEff, targetEndOfTrial = 0.3, targetDuringTrial = 0.35, ... )
## S4 method for signature 'PseudoDualSimulations' summary( object, trueDLE, trueEff, targetEndOfTrial = 0.3, targetDuringTrial = 0.35, ... )
object |
the |
trueDLE |
a function which takes as input a dose (vector) and returns the true probability (vector) of DLE |
trueEff |
a function which takes as input a dose (vector) and returns the mean efficacy value(s) (vector). |
targetEndOfTrial |
the target probability of DLE that are used at the end of a trial. Default at 0.3. |
targetDuringTrial |
the target probability of DLE that are used during the trial. Default at 0.35. |
... |
Additional arguments can be supplied here for |
an object of class PseudoDualSimulationsSummary
# 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) # 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 )
# 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) # 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 the simulations, relative to a given truth
## S4 method for signature 'PseudoSimulations' summary(object, truth, targetEndOfTrial = 0.3, targetDuringTrial = 0.35, ...)
## S4 method for signature 'PseudoSimulations' summary(object, truth, targetEndOfTrial = 0.3, targetDuringTrial = 0.35, ...)
object |
the |
truth |
a function which takes as input a dose (vector) and returns the true probability (vector) for toxicity |
targetEndOfTrial |
the target probability of DLE wanted to achieve at the end of a trial |
targetDuringTrial |
the target probability of DLE wanted to achieve during a trial |
... |
Additional arguments can be supplied here for |
an object of class PseudoSimulationsSummary
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 )
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 the model-based design simulations, relative to a given truth
## S4 method for signature 'Simulations' summary(object, truth, target = c(0.2, 0.35), ...)
## S4 method for signature 'Simulations' summary(object, truth, target = c(0.2, 0.35), ...)
object |
the |
truth |
a function which takes as input a dose (vector) and returns the true probability (vector) for toxicity |
target |
the target toxicity interval (default: 20-35%) used for the computations |
... |
Additional arguments can be supplied here for |
an object of class SimulationsSummary
# 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
# 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
TDDesign
TDDesign
is the class of design based only on DLT responses using
ModelTox
class model (i.e. LogisticIndepBeta
) without MCMC samples.
TDDesign( model, stopping, increments, pl_cohort_size = CohortSizeConst(0L), ... ) .DefaultTDDesign()
TDDesign( model, stopping, increments, pl_cohort_size = CohortSizeConst(0L), ... ) .DefaultTDDesign()
model |
( |
stopping |
( |
increments |
( |
pl_cohort_size |
( |
... |
Arguments passed on to
|
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).
Typically, end users will not use the .DefaultTDDesign()
function.
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 )
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
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.
TDsamplesDesign( model, stopping, increments, pl_cohort_size = CohortSizeConst(0L), ... ) .DefaultTDsamplesDesign()
TDsamplesDesign( model, stopping, increments, pl_cohort_size = CohortSizeConst(0L), ... ) .DefaultTDsamplesDesign()
model |
( |
stopping |
( |
increments |
( |
pl_cohort_size |
( |
... |
Arguments passed on to
|
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).
Typically, end users will not use the .DefaultTDsamplesDesign()
function.
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 )
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 )
CrmPackClass
objectsIn 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.
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, ...)
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, ...)
x |
( |
... |
potentially used by class-specific methods. |
A (list of) tibble(s) representing the object in tidy form.
The tibble
object.
The tibble
object.
The tibble
object.
The tibble
object.
The tibble
object.
The tibble
object.
The tibble
object.
The prior observations are indicated by a Cohort
value of 0
in the returned
tibble
.
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()
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()
TITELogisticLogNormal
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
.
TITELogisticLogNormal(weight_method = "linear", ...) .DefaultTITELogisticLogNormal()
TITELogisticLogNormal(weight_method = "linear", ...) .DefaultTITELogisticLogNormal()
weight_method |
( |
... |
Arguments passed on to
|
weight_method
(string
)
the weight function method: either linear
or adaptive. This was used in Liu, Yin and Yuan's paper.
Typically, end users will not use the .DefaultTITELogisticLogNormal()
function.
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" )
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" )
Data
ObjectsA method that updates existing Data
object with new data.
## S4 method for signature 'Data' update( object, x, y, ID = length(object@ID) + seq_along(y), new_cohort = TRUE, check = TRUE, ... )
## S4 method for signature 'Data' update( object, x, y, ID = length(object@ID) + seq_along(y), new_cohort = TRUE, check = TRUE, ... )
object |
( |
x |
( |
y |
( |
ID |
( |
new_cohort |
( |
check |
( |
... |
not used. |
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.
The new, updated Data
object.
# 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
# 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
DataDA
ObjectsA method that updates existing DataDA
object with new data.
## S4 method for signature 'DataDA' update(object, u, t0, trialtime, y, ..., check = TRUE)
## S4 method for signature 'DataDA' update(object, u, t0, trialtime, y, ..., check = TRUE)
object |
( |
u |
( |
t0 |
( |
trialtime |
( |
y |
( |
... |
further arguments passed to |
check |
( |
The new, updated DataDA
object.
This function is capable of not only adding new patients but also
updates existing ones with respect to y
, t0
, u
slots.
# 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
# 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
DataDual
ObjectsA method that updates existing DataDual
object with new data.
## S4 method for signature 'DataDual' update(object, w, ..., check = TRUE)
## S4 method for signature 'DataDual' update(object, w, ..., check = TRUE)
object |
( |
w |
( |
... |
further arguments passed to |
check |
( |
The new, updated DataDual
object.
# 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
# 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
DataOrdinal
ObjectsA method that updates existing DataOrdinal
object with new data.
## S4 method for signature 'DataOrdinal' update( object, x, y, ID = length(object@ID) + seq_along(y), new_cohort = TRUE, check = TRUE, ... )
## S4 method for signature 'DataOrdinal' update( object, x, y, ID = length(object@ID) + seq_along(y), new_cohort = TRUE, check = TRUE, ... )
object |
( |
x |
( |
y |
( |
ID |
( |
new_cohort |
( |
check |
( |
... |
not used. |
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.
The new, updated DataOrdinal
object.
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))
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))
DataParts
ObjectsA method that updates existing DataParts
object with new data.
## S4 method for signature 'DataParts' update(object, x, y, ..., check = TRUE)
## S4 method for signature 'DataParts' update(object, x, y, ..., check = TRUE)
object |
( |
x |
( |
y |
( |
... |
further arguments passed to |
check |
( |
The new, updated DataParts
object.
# 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
# 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
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.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.
## S4 method for signature 'ModelPseudo' update(object, data, ...)
## S4 method for signature 'ModelPseudo' update(object, data, ...)
object |
( |
data |
( |
... |
not used. |
the new ModelPseudo
class object.
# 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)
# 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)
CohortSize
ObjectsThese functions are only used internally to validate the format of an input
CohortSize
or inherited classes and therefore not exported.
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)
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)
object |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
v_cohort_size_range()
: validates that the CohortSizeRange
object
contains valid intervals
and cohort_size
slots.
v_cohort_size_dlt()
: validates that the CohortSizeDLT
object
contains valid intervals
and cohort_size
slots.
v_cohort_size_const()
: validates that the CohortSizeConst
object
contains valid size
slot.
v_cohort_size_parts()
: validates that the CohortSizeParts
object
contains valid sizes
slot.
v_cohort_size_max()
: validates that the CohortSizeMax
object
contains valid cohort_sizes
slot.
GeneralData
ObjectsThese functions are only used internally to validate the format of an input
GeneralData
or inherited classes and therefore not exported.
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)
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)
object |
( |
dose |
( |
cohort |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
TRUE
if dose
is unique per cohort
, otherwise FALSE
.
v_general_data()
: validates that the GeneralData
object contains unique ID
, non-negative cohort
indices and
ID
and cohort
vectors are of the same length nObs
.
h_doses_unique_per_cohort()
: helper function which verifies whether
the dose
values are unique in each and every different cohort
.
v_data()
: validates that the Data
object contains
valid elements with respect to their types, dependency and length.
v_data_dual()
: validates that the DataDual
object
contains valid biomarker vector with respect to its type and the length.
v_data_parts()
: validates that the DataParts
object
contains valid elements with respect to their types, dependency and length.
v_data_mixture()
: validates that the DataMixture
object
contains valid elements with respect to their types, dependency and length.
v_data_da()
: validates that the DataDA
object
contains valid elements with respect to their types, dependency and length.
v_data_ordinal()
: validates that the DataOrdinal
object
contains valid elements with respect to their types, dependency and length.
v_data_grouped()
: validates that the DataGrouped
object
contains valid group information.
RuleDesign
ObjectsThese 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.
v_rule_design(object) v_rule_design_ordinal(object) v_design_grouped(object)
v_rule_design(object) v_rule_design_ordinal(object) v_design_grouped(object)
object |
( |
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.
v_rule_design()
: validates that the RuleDesign
object
contains valid startingDose
.
v_rule_design_ordinal()
: validates that the RuleDesignOrdinal
object
contains valid starting_dose
.
v_design_grouped()
: validates that the DesignGrouped
object
contains valid flags.
GeneralSimulations
ObjectsThese functions are only used internally to validate the format of an input
GeneralSimulations
or inherited classes and therefore not exported.
v_general_simulations(object) v_simulations(object) v_dual_simulations(object) v_da_simulations(object)
v_general_simulations(object) v_simulations(object) v_dual_simulations(object) v_da_simulations(object)
object |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
v_general_simulations()
: validates that the GeneralSimulations
object
contains valid data
object and valid dose
simulations.
v_simulations()
: validates that the Simulations
object
contains valid object fit
, stop_reasons
, stop_report
, and
additional_stats
compared to the general class GeneralSimulations
.
v_dual_simulations()
: validates that the DualSimulations
object and
capture the dose-biomarker fits
, and the sigma2W
and rho
estimates.
v_da_simulations()
: validates that the DASimulations
object
contains valid trialduration
the vector of trial duration values for all
simulations.
Increments
ObjectsThese functions are only used internally to validate the format of an input
Increments
or inherited classes and therefore not exported.
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)
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)
object |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
v_increments_relative()
: validates that the IncrementsRelative
object
contains valid intervals
and increments
parameters.
v_increments_relative_parts()
: validates that the IncrementsRelativeParts
object
contains valid dlt_start
and clean_start
parameters.
v_increments_relative_dlt()
: validates that the IncrementsRelativeDLT
object
contains valid intervals
and increments
parameters.
v_increments_dose_levels()
: validates that the IncrementsDoseLevels
object
contains valid levels
and basis_level
option.
v_increments_hsr_beta()
: validates that the IncrementsHSRBeta
object contains valid probability target, threshold and shape parameters.
v_increments_min()
: validates that the IncrementsMin
object contains a list with Increments
objects.
v_increments_maxtoxprob()
: validates the IncrementsMaxToxProb
v_increments_ordinal()
: validates that the IncrementsOrdinal
object
contains valid grade
and standard Increments
rule.
v_cohort_size_ordinal()
: validates that the CohortSizeOrdinal
object
contains valid grade
and standard CohortSize
rule.
McmcOptions
ObjectsThese functions are only used internally to validate the format of an input
McmcOptions
or inherited classes and therefore not exported.
v_mcmc_options(object)
v_mcmc_options(object)
object |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
v_mcmc_options()
: validates that the McmcOptions
object contains valid integer scalars iterations
, burnin
and step
as well as proper parameters for Random Number Generator.
GeneralModel
and ModelPseudo
ObjectsThese functions are only used internally to validate the format of an input
GeneralModel
and ModelPseudo
or inherited classes and therefore are
not exported.
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)
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)
object |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
v_general_model()
: validates that the names of the
arguments in init
function are included in datanames
or datanames_prior
slots.
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 that weightpar
is valid.
v_model_logistic_normal_fixed_mix()
: validates that component
is a list with
valid ModelParamsNormal
objects as well as weights
are correct.
v_model_logistic_log_normal_mix()
: validates that share_weight
represents probability.
v_model_dual_endpoint()
: validates that DualEndpoint
class slots are valid.
v_model_dual_endpoint_rw()
: validates that DualEndpointRW
class slots are valid.
v_model_dual_endpoint_beta()
: validates that DualEndpointBeta
class slots are valid.
v_model_dual_endpoint_emax()
: validates that DualEndpointEmax
class slots are valid.
v_model_logistic_indep_beta()
: validates that LogisticIndepBeta
class slots are valid.
v_model_eff_log_log()
: validates that Effloglog
class slots are valid.
v_model_eff_flexi()
: validates that EffFlexi
class slots are valid.
v_model_da_logistic_log_normal()
: validates that DALogisticLogNormal
class slots are valid.
v_model_tite_logistic_log_normal()
: validates that TITELogisticLogNormal
class slots are valid.
v_model_one_par_exp_normal_prior()
: validates that OneParLogNormalPrior
class slots are valid.
v_model_one_par_exp_prior()
: validates that OneParExpPrior
class slots are valid.
v_logisticlognormalordinal()
: confirms that cov is diagonal
These functions are only used internally to validate the format of an object with model parameters or inherited classes and therefore not exported.
v_model_params_normal(object)
v_model_params_normal(object)
object |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
v_model_params_normal()
: a helper function that validates multivariate normal
parameters.
NextBest
ObjectsThese functions are only used internally to validate the format of an input
NextBest
or inherited classes and therefore not exported.
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_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)
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_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)
object |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
v_next_best_mtd()
: validates that the NextBestMTD
object
contains valid target
probability and derive
function.
v_next_best_ncrm()
: validates that the NextBestNCRM
object
contains valid target
probability, overdose
and max_overdose_prob
probability ranges.
v_next_best_ncrm_loss()
: validates that the NextBestNCRMLoss
object
contains valid objects.
v_next_best_dual_endpoint()
: validates that the NextBestDualEndpoint
object
contains valid probability objects.
v_next_best_min_dist()
: validates that the NextBestMinDist
object
contains valid target
object.
v_next_best_inf_theory()
: validates that the NextBestInfTheory
object
contains valid target
and asymmetry
objects.
v_next_best_td()
: validates that the NextBestTD
object
contains valid prob_target_drt
and prob_target_eot
probabilities.
v_next_best_td_samples()
: validates that the NextBestTDsamples
object
contains valid derive
function.
v_next_best_max_gain_samples()
: validates that the NextBestMaxGainSamples
object
contains valid derive
and mg_derive
functions.
v_next_best_prob_mtd_lte()
: validates that the NextBestProbMTDLTE
object
contains valid target
probability and method
string value.
v_next_best_prob_mtd_min_dist()
: validates that the NextBestProbMTDMinDist
object
contains valid target
probability and method
string value.
v_next_best_ordinal()
: validates that the NextBestOrdinal
object
contains valid grade
and standard NextBest
rule.
PseudoSimulations
ObjectsThese functions are only used internally to validate the format of an input
PseudoSimulations
or inherited classes and therefore not exported.
v_pseudo_simulations(object) v_pseudo_dual_simulations(object) v_pseudo_dual_flex_simulations(object)
v_pseudo_simulations(object) v_pseudo_dual_simulations(object) v_pseudo_dual_flex_simulations(object)
object |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
v_pseudo_simulations()
: validates that the PseudoSimulations
object
contains valid fit
, FinalTDtargetEndOfTrialEstimates
,
FinalTDtargetDuringTrialAtDoseGrid
,FinalTDtargetEndOfTrialAtDoseGrid
,
FinalTDEOTCIs
, FinalTDEOTRatios
, FinalCIs
, FinalRatios
,
object and valid stopReasons
simulations.
v_pseudo_dual_simulations()
: validates that the PseudoDualSimulations
object
contains valid 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
object and valid sigma2_est
simulations.
v_pseudo_dual_flex_simulations()
: validates that the PseudoDualFlexiSimulations
object contains valid sigma2betaWest
vector of the final posterior mean
sigma2betaW estimates.FinalGstarEstimates
, FinalGstarAtDoseGrid
,
SafetyWindow
ObjectsThese functions are only used internally to validate the format of an input
SafetyWindow
or inherited classes and therefore not exported.
v_safety_window_size(object) v_safety_window_const(object)
v_safety_window_size(object) v_safety_window_const(object)
object |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
v_safety_window_size()
: validates that the SafetyWindowSize
object
contains valid slots.
v_safety_window_const()
: validates that the SafetyWindowConst
object
contains valid slots.
Samples
ObjectsThese functions are only used internally to validate the format
of an input Samples
or inherited classes and therefore not exported.
v_samples(object)
v_samples(object)
object |
( |
A character
vector with the validation failure messages, or TRUE
in case validation passes.
v_samples()
: validates that the Samples
object contains
valid data
slot.
Stopping
ObjectsThese functions are only used internally to validate the format of an input
Stopping
or inherited classes and therefore not exported.
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)
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)
object |
( |
A character
vector with the validation failure messages,
or TRUE
in case validation passes.
v_stopping_cohorts_near_dose()
: validates that the StoppingCohortsNearDose
object contains valid nCohorts
and percentage
parameters.
v_stopping_patients_near_dose()
: validates that the StoppingPatientsNearDose
object contains valid nPatients
and percentage
parameters.
v_stopping_min_cohorts()
: validates that the StoppingMinCohorts
object contains valid nCohorts
parameter.
v_stopping_min_patients()
: validates that the StoppingMinPatients
object contains valid nPatients
parameter.
v_stopping_target_prob()
: validates that the StoppingTargetProb
object contains valid target
and prob
parameters.
v_stopping_mtd_distribution()
: validates that the StoppingMTDdistribution
object contains valid target
, thresh
and prob
parameters.
v_stopping_mtd_cv()
: validates that the StoppingMTDCV
object
contains valid probability target and percentage threshold.
v_stopping_target_biomarker()
: validates that the StoppingTargetBiomarker
object
contains valid target
, is_relative
and prob
slots.
v_stopping_list()
: validates that the StoppingList
object
contains valid stop_list
, summary
slots.
v_stopping_all()
: validates that the StoppingAll
object
contains valid stop_list
slot.
v_stopping_tdci_ratio()
: validates that the StoppingTDCIRatio
object
contains valid target_ratio
and prob_target
slots.
Validate
The Validate
class is a Reference Class
to help programming validation for new S4 classes.
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.
msg
(character
)
the cumulative messages.
check(test, string = "")
Check whether the test
is TRUE
; if so, return NULL
.
Otherwise, add the string
message into the cumulative messages vector msg
.
result()
Return either cumulative messages vector msg
(which contains the error messages from all the checks),
or NULL
, if msg
is empty (i.e. all the checks were successful).
This function determines the safety window length of the next cohort.
windowLength(safetyWindow, size, ...) ## S4 method for signature 'SafetyWindowSize' windowLength(safetyWindow, size, data, ...) ## S4 method for signature 'SafetyWindowConst' windowLength(safetyWindow, size, ...)
windowLength(safetyWindow, size, ...) ## S4 method for signature 'SafetyWindowSize' windowLength(safetyWindow, size, data, ...) ## S4 method for signature 'SafetyWindowConst' windowLength(safetyWindow, size, ...)
safetyWindow |
The rule, an object of class
|
size |
The next cohort size |
... |
additional arguments |
data |
The data input, an object of class |
the windowLength
as a list of safety window parameters
(gap
, follow
, follow_min
)
windowLength(SafetyWindowSize)
: Determine safety window length based
on the cohort size
windowLength(SafetyWindowConst)
: Constant safety window length
# 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
# 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