Crm-class: An R6 class encapsulating CRM models This class wraps the...

Description Details Super class Methods Note Examples

Description

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.

Details

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.

Super class

precautionary::Cpe -> Crm

Methods

Public methods

Inherited methods

Method new()

Usage
Crm$new(skeleton, scale = sqrt(1.34), target)
Arguments
skeleton

CRM skeleton

scale

Sigma parameter of prior on beta parameter

target

Target toxicity rate

Details

Create a new Crm object.

Returns

A Crm object.

Examples
# 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)

Method max_dose()

Usage
Crm$max_dose(D)
Arguments
D

Included to match signature of superclass method. It is an error to call this method with non-missing D parameter.

Details

Return number of prespecified doses

Returns

Length of CRM skeleton.


Method skeleton()

Usage
Crm$skeleton(skeleton)
Arguments
skeleton

A numeric vector to set as the model skeleton.

Details

Set or query CRM skeleton

Returns

Self (invisibly), unless skeleton is missing, in which case the skeleton, a numeric vector, is returned.


Method dontcache()

Usage
Crm$dontcache()
Details

Set private cache to NULL; useful for performance testing

Returns

Self, invisibly


Method report()

Usage
Crm$report(...)
Arguments
...

Optional arguments specifying columns to add to report

Details

Report lifetime duty & performance statistics

Returns

A named vector summarizing lifetime duty and performance


Method stop_func()

Usage
Crm$stop_func(sfunc)
Arguments
sfunc

A function taking mtd objects to mtd objects, attaching suitable stopping information

Details

Set the stopping function

Returns

Self, invisibly


Method no_skip_esc()

Usage
Crm$no_skip_esc(tf)
Arguments
tf

An atomic logical value, TRUE or FALSE

Details

Set the no_skip_esc behavior

Returns

Self, invisibly


Method no_skip_deesc()

Usage
Crm$no_skip_deesc(tf)
Arguments
tf

An atomic logical value, TRUE or FALSE

Details

Set the no_skip_deesc behavior

Returns

Self, invisibly


Method global_coherent_esc()

Usage
Crm$global_coherent_esc(tf)
Arguments
tf

An atomic logical value, TRUE or FALSE

Details

Set the global_coherent_esc behavior

Returns

Self, invisibly


Method conf_level()

Usage
Crm$conf_level(conf)
Arguments
conf

A numeric confidence less than 1.0

Details

Set the required confidence level for escalation decisions

Returns

Self, invisibly


Method observe()

Usage
Crm$observe(level, tox)
Arguments
level

A patient-wise vector of dose assignments

tox

A patient-wise vector of 0/1 toxicity assessments

Details

Set patient-wise toxicity observations

Returns

Self, invisibly


Method tally()

Usage
Crm$tally(x, o)
Arguments
x

A dose-wise vector of toxicity counts

o

A dose-wise vector of non-toxicity counts

Details

Set dose-wise toxicity observations

Returns

Self, invisibly


Method est()

Usage
Crm$est(impl = "rusti", abbrev = TRUE)
Arguments
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.

Details

Estimate the model

Returns

An object of class mtd as per package dfcrm


Method applied()

Usage
Crm$applied(x, o, last_dose = NA, max_dose = NULL)
Arguments
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.

Details

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.

Returns

An object of class mtd as per package dfcrm, or possibly an abbreviated version of such object as returned by method Crm$est().


Method clone()

The objects of this class are cloneable with this method.

Usage
Crm$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Note

This specializes the superclass set/get method, consistent with the non-mutable number of doses of CRM with fixed skeleton.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## ------------------------------------------------
## 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)

precautionary documentation built on Aug. 9, 2021, 9:14 a.m.