This class wraps the functionality of package dfcrm, adding efficient Rust implementations of some numerical routines.
An R6 class encapsulating CRM models
This class wraps the functionality of package dfcrm, adding efficient Rust implementations of some numerical routines.
An R6 class encapsulating CRM models
This class wraps the functionality of package dfcrm, adding efficient Rust implementations of some numerical routines.
precautionary::Cpe
-> Crm
new()
Crm$new(skeleton, scale = sqrt(1.34), target)
skeleton
CRM skeleton
scale
Sigma parameter of prior on beta parameter
target
Target toxicity rate
Create a new Crm
object.
A Crm
object.
# An example verbatim from dfcrm::crm() prior <- c(0.05, 0.10, 0.20, 0.35, 0.50, 0.70) target <- 0.2 level <- c(3, 4, 4, 3, 3, 4, 3, 2, 2, 2) y <- c(0, 0, 1, 0, 0, 1, 1, 0, 0, 0) s <- sqrt(1.34) old <- dfcrm::crm(prior, target, y, level) new <- Crm$new(skeleton = prior, target = target)$ dontcache()$ observe(level, y)$ est(impl="rusti", abbrev=FALSE)
max_dose()
Crm$max_dose(D)
D
Included to match signature of superclass method.
It is an error to call this method with non-missing D
parameter.
Return number of prespecified doses
Length of CRM skeleton.
skeleton()
Crm$skeleton(skeleton)
skeleton
A numeric vector to set as the model skeleton.
Set or query CRM skeleton
Self (invisibly), unless skeleton
is missing,
in which case the skeleton, a numeric vector, is returned.
dontcache()
Crm$dontcache()
Set private cache to NULL; useful for performance testing
Self, invisibly
report()
Crm$report(...)
...
Optional arguments specifying columns to add to report
Report lifetime duty & performance statistics
A named vector summarizing lifetime duty and performance
stop_func()
Crm$stop_func(sfunc)
sfunc
A function taking mtd
objects to mtd
objects,
attaching suitable stopping information
Set the stopping function
Self, invisibly
no_skip_esc()
Crm$no_skip_esc(tf)
tf
An atomic logical value, TRUE or FALSE
Set the no_skip_esc
behavior
Self, invisibly
no_skip_deesc()
Crm$no_skip_deesc(tf)
tf
An atomic logical value, TRUE or FALSE
Set the no_skip_deesc
behavior
Self, invisibly
global_coherent_esc()
Crm$global_coherent_esc(tf)
tf
An atomic logical value, TRUE or FALSE
Set the global_coherent_esc
behavior
Self, invisibly
conf_level()
Crm$conf_level(conf)
conf
A numeric confidence less than 1.0
Set the required confidence level for escalation decisions
Self, invisibly
observe()
Crm$observe(level, tox)
level
A patient-wise vector of dose assignments
tox
A patient-wise vector of 0/1 toxicity assessments
Set patient-wise toxicity observations
Self, invisibly
tally()
Crm$tally(x, o)
x
A dose-wise vector of toxicity counts
o
A dose-wise vector of non-toxicity counts
Set dose-wise toxicity observations
Self, invisibly
est()
Crm$est(impl = "rusti", abbrev = TRUE)
impl
A string choosing the low-level implementation to use.
Possible values include "dfcrm"
, "rusti"
and "ruste"
.
abbrev
Logical; if TRUE (the default), an abbreviated mtd
object is returned to save execution time. If FALSE, a complete object is
returned, suitable for regression testing against package dfcrm.
Estimate the model
An object of class mtd
as per package dfcrm
applied()
Crm$applied(x, o, last_dose = NA, max_dose = NULL)
x
A dose-wise vector of toxicity counts
o
A dose-wise vector of non-toxicity counts
last_dose
The most recently given dose, as required to implement
the global_coherent_esc=TRUE
behavior
max_dose
Unused; included for compatibility with superclass method
of required impl
parameter and optional abbrev
flag.
Return dose recommendation for given tox/no-tox tallies.
This function caches results, which greatly saves computation time in CPE -- yielding e.g. a 5x speedup for the VIOLA trial example.
An object of class mtd
as per package dfcrm,
or possibly an abbreviated version of such object as returned by
method Crm$est()
.
clone()
The objects of this class are cloneable with this method.
Crm$clone(deep = FALSE)
deep
Whether to make a deep clone.
Syntactically, the method chaining supported by R6 classes makes the invocation of CRM models more transparent. The mutability conferred by reference semantics enables memoization (caching) of results, which can speed up DTP calculations significantly.
Presently, this class supports only the 'empiric' (aka 'power') model. But it is hoped that inheritance will assist in rendering other models implemented in package dfcrm clearly, with code reuse.
# NOT RUN {
## ------------------------------------------------
## Method `Crm$new`
## ------------------------------------------------
# An example verbatim from dfcrm::crm()
prior <- c(0.05, 0.10, 0.20, 0.35, 0.50, 0.70)
target <- 0.2
level <- c(3, 4, 4, 3, 3, 4, 3, 2, 2, 2)
y <- c(0, 0, 1, 0, 0, 1, 1, 0, 0, 0)
s <- sqrt(1.34)
old <- dfcrm::crm(prior, target, y, level)
new <- Crm$new(skeleton = prior, target = target)$
dontcache()$
observe(level, y)$
est(impl="rusti", abbrev=FALSE)
# }
Run the code above in your browser using DataLab