---
title: "Time-to-Event Continual Reassessment Method"
author: "Kristian Brock"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
bibliography: library.bib
vignette: >
  %\VignetteIndexEntry{Time-to-Event Continual Reassessment Method}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

This vignette concerns the _Time to Event Continual Reassessment Method_ (TITE-CRM) dose-finding clinical trial design.

@Cheung2000 introduced TITE-CRM as a variant of the regular CRM [OQuigley1990] that handles late-onset toxicities.
Dose-finding trials tend to use a short toxicity window after the commencement of therapy, during which each patient is evaluated for the presence or absence of dose-limiting toxicity (DLT).
This approach works well in treatments like chemotherapy where toxic reactions are expected to manifest relatively quickly.
In contrast, one of the hallmarks of radiotherapy, for instance, is that related adverse reactions can manifest many months after the start of treatment.
A similar phenomenon may arise with immunotherapies.

In adaptive dose-finding clinical trials, where doses are selected mid-trial in response to the outcomes experienced by patients evaluated hitherto, late-onset toxic events present a distinct methodological challenge.
Naturally, the toxicity window will need to be long enough to give the trial a good chance of observing events of interest.
If, however, we wait until each patient completes the evaluation window before using their outcome to forecast the best dose, the trial may take an infeasibly long time and ignore pertinent interim data.

TITE-CRM presents a solution by introducing the notion of a _partial tolerance_ event. 
If a patient is half way through the evaluation window and has not yet experienced toxicity, we may say that they have experienced half a tolerance. 
This simple novelty allows partial information to be used in dose-recommendation decisions.
If the patient goes on to complete the window with no toxic reaction, they will be regarded as having completely tolerated treatment, as is normally the case with CRM and other dose-finding algorithms.
This notion of partial events is only applied to tolerances, however.
If a patient experiences toxicity at any point during the evaluation window, they are immediately regarded as having experienced 100% of a DLT event.

To illustrate TITE-CRM mathematically, we start with the likelihood from the plain vanilla CRM.
Let $Y_i$ be a random variable taking values $\{0, 1\}$ reflecting the absence and presence of DLT respectively in patient $i$.
A patient administered dose $x_i$ has estimated probability of toxicity $F(x_i, \theta)$, where $\theta$ represents the set of model parameters.
The likelihood component arising from patient $i$ is

$$ F(x_i, \theta)^{Y_i} (1 - F(x_i, \theta))^{1-Y_i} $$

and the aggregate likelihood after the evaluation of $J$ patients is 

$$ L_J(\theta) = \prod_{i=1}^J \left\{ F(x_i, \theta) \right\}^{Y_i} \left\{ 1 - F(x_i, \theta) \right\}^{1-Y_i} $$

@Cheung2000 observed that each patient may provide a weight, $w_i$, reflecting the extend to which their outcome has been evaluated.
The weighted likelihood is

$$ L_J(\theta) = \prod_{i=1}^J \left\{ w_i F(x_i, \theta) \right\}^{Y_i} \left\{ 1 - w_i F(x_i, \theta) \right\}^{1-Y_i} $$

TITE-CRM weights the outcomes according to the extend to which patients have completed the evaluation period.
To illustrate the design, we reproduce the example given on p.124 of @Cheung2011.
Four patients have been treated at dose-level 3 and all are part-way through the 126-day toxicity evaluation window.

The authors use the empiric model so that there is one parameter, $\theta = \beta$, the dose-toxicity relation is $F(x_i, \beta) = x_i^{exp(\beta)}$, and a $N(0, \sigma_{\beta}^2)$ prior is specified on $\beta$.

```{r, results='hide', message=FALSE}
library(trialr)

fit <- stan_crm(skeleton = c(0.05, 0.12, 0.25, 0.40, 0.55), target = 0.25,
                doses_given = c(3, 3, 3, 3),
                tox = c(0, 0, 0, 0),
                weights = c(73, 66, 35, 28) / 126,
                model = 'empiric', beta_sd = sqrt(1.34), seed = 123)
```
```{r}
fit
```

The first table gives a summary of the patient information.
We see that each patient has received dose-level 3, none have yet experienced toxicity although all are only partly through the evaluation window.
The second table summarises dose-level information.
We see that dose-level 4 has estimated mean probability of toxicity closest to the target 25%, although dose-level 5 is the dose most frequently advocated by the dose-toxicity curves generated by MCMC.
This exuberance should be tempered by the fact that we have not yet treated any patients at dose-level 4, although it is currently recommended for the next patient.

A TITE-CRM option is provided for each of the CRM variants implemented in `trialr`.
It is enabled simply by specifying the `weights` parameter.
The necessity to provide weights under TITE-CRM rather obscures the attraction of using the outcome string approach of describing patients' doses and DLT outcomes demonstrated in the CRM vignette.
Thus, we provide `stan_crm` the three vectors `doses_given`, `tox` and `weights` to convey the patient-level information.

The object returned by `stan_crm` is the same, regardless of whether `weights` are provided or not.
Thus, all of the visualistion methods presented in the CRM visualistion vignette apply.


## Other CRM vignettes## Other CRM vignettes
There are many vignettes illustrating the CRM and other dose-finding models in `trialr`.
Be sure to check them out.


# `trialr` and the `escalation` package
[`escalation`](https://cran.r-project.org/package=escalation) is an R package that provides a grammar for specifying dose-finding clinical trials.
For instance, it is common for trialists to say something like 'I want to use this published design... but I want it to stop once $n$ patients have been treated at the recommended dose' or '...but I want to prevent dose skipping' or '...but I want to select dose using a more risk-averse metric than merely _closest-to-target_'.

`trialr` and `escalation` work together to achieve these goals.
`trialr` provides model-fitting capabilities to `escalation`, including the CRM methods described here.
`escalation` then provides additional classes to achieve all of the above custom behaviours, and more.

`escalation` also provides methods for running simulations and calculating dose-paths.
Simulations are regularly used to appraise the operating characteristics of adaptive clinical trial designs.
Dose-paths are a tool for analysing and visualising all possible future trial behaviours.
Both are provided for a wide array of dose-finding designs, with or without custom behaviours like those identified above.
There are many examples in the `escalation` vignettes at https://cran.r-project.org/package=escalation.


# trialr
`trialr` is available at https://github.com/brockk/trialr and https://CRAN.R-project.org/package=trialr 


# References
