R/crm.R
Crm-class.Rd
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.
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.
This specializes the superclass set/get method, consistent with the non-mutable number of doses of CRM with fixed skeleton.
precautionary::Cpe
-> Crm
new()
skeleton
CRM skeleton
scale
Sigma parameter of prior on beta parameter
target
Target toxicity rate
# 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()
stop_func()
observe()
est()
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.
An object of class mtd
as per package dfcrm
applied()
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()
.
## ------------------------------------------------
## 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)