<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>crmPack Vignettes</title>
<link>https://www.crmpack.org/vignettes/</link>
<atom:link href="https://www.crmpack.org/vignettes/index.xml" rel="self" type="application/rss+xml"/>
<description>R Programming and Consulting.</description>
<language>en</language>
<image>
<url>https://www.crmpack.org/figures/logo_100.png</url>
<title>crmPack Vignettes</title>
<link>https://www.crmpack.org/vignettes/</link>
<height>100</height>
<width>100</width>
</image>
<generator>quarto-1.8.27</generator>
<lastBuildDate>Mon, 02 Mar 2026 09:08:07 GMT</lastBuildDate>
<item>
  <title>Ordinal continual reassessment method (CRM) examples</title>
  <dc:creator>John Kirkpatrick, Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/examples/crmPack_ordinal/</link>
  <description><![CDATA[ 




<section id="introduction" class="level1">
<h1>Introduction</h1>
<p>The original CRM model introduced by <span class="citation" data-cites="oquigley1990">(O’Quigley, Pepe, and Fisher 1990)</span> dichotomises toxicity events as either “Not toxic” or “DLT”. The ordinal CRM generalises this model by classifying toxicities on an ordinal scale with an arbitrary number of categories (though use of more than three or four would be unusual).</p>
<p>This approach is particularly useful in non-oncology settings, where there is a greater interest in adverse events that are not dose limiting but are nonetheless undesirable.</p>
</section>
<section id="implementation" class="level1">
<h1>Implementation</h1>
<section id="ordinal-data" class="level2">
<h2 class="anchored" data-anchor-id="ordinal-data">Ordinal data</h2>
<p><code>crmPack</code> uses the <code>DataOrdinal</code> class to record data observed during an ordinal CRM trial. The <code>OrdinalData</code> class differs from the <code>Data</code> class only in that it contains an extra slot, <code>yCategories</code>, that defines both the number of toxicity grades and their labels.For example:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">empty_ordinal_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataOrdinal</span>(</span>
<span id="cb1-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>)),</span>
<span id="cb1-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yCategories =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No tox"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>L, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sub-tox AE"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DLT"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>L),</span>
<span id="cb1-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placebo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb1-5">)</span></code></pre></div></div>
</div>
<p>defines a <code>DataOrdinal</code> object with three toxicity grades, labelled “No tox`”, “Sub-tox AE” and “DLT”.</p>
<blockquote class="blockquote">
<p>Note that the <code>yCategories</code> slot must be an integer vector with values ordered from <code>0</code> to <code>length(yCategories) - 1</code>. Its labels must be unique. The first entry, which must have value <code>0</code>, is always regarded as the “no event” category. See [The LogisticLogNormalOrdinal class] below.</p>
</blockquote>
<p>The <code>update</code>, <code>plot</code> and <code>dose_grid_range</code> methods work exactly as they do for <code>Data</code> objects:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dose_grid_range</span>(empty_ordinal_data)</span>
<span id="cb2-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1]  10 100</span></span>
<span id="cb2-3"></span>
<span id="cb2-4">ordinal_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(empty_ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb2-5">ordinal_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb2-6">ordinal_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb2-7">ordinal_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb2-8">ordinal_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb2-9">ordinal_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb2-10"></span>
<span id="cb2-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(ordinal_data)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_ordinal/index_files/figure-html/data-ordinal-2-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph showing Patient ID on the x axis and dose administered on the y axis.  The shape and colour of the symbols indicate the toxicity status of the patient: red triangles for DLTs, orange circles for sub-toxic AEs and black triangles for no reported toxicities.  Patients 1 to 4 are dosed at 10, 20, 30 and 40, with no toxicitis reported.  patients 5 to 7 are dosed at 50, with patient 6 reporting a sub-toxic AE.  Patients 8 to 10 are treated at 60.  Patient 9 reports a sub-toxic AE and patient 10 a DLT."></p>
</figure>
</div>
</div>
</div>
</section>
<section id="the-logisticlognormalordinal-class" class="level2">
<h2 class="anchored" data-anchor-id="the-logisticlognormalordinal-class">The <code>LogisticLogNormalOrdinal</code> class</h2>
<p><code>crmPack</code> fits a constrained logistic log normal model to ordinal data. The logit of the probability of toxicity at each grade for a given dose is modelled in the log odds space as a linear regression with common slope and a different intercept for each toxicity grade.</p>
<blockquote class="blockquote">
<p>Note, unlike other model classes, <code>LogisticLogNormalOrdinal</code> requires a diagonal covariance matrix. This is because the constraints on the $alpha;s - the intercept parameters - imposes a correlation on the model’s parameters. Thus, any covariance structure requested by the end user could not be honoured by the model.</p>
</blockquote>
<p>Let p<sub>k</sub>(d) be the probability that the response of a patient treated at dose d is in category k <em><em>or higher</em></em>, k=0, …, K; d=1, …, D.</p>
<p>Then</p>
<p><img src="https://latex.codecogs.com/png.latex?%20%5Clog%20%5Cleft(%20%5Cfrac%7Bp%7D%7B1-p%7D%5Cright)%20=%20%5Calpha_k%20+%20%5Cbeta%20%5Ccdot%20%5Clog%20%5Cleft(%20%5Cfrac%7Bd%7D%7Bd_%7Bref%7D%7D%20%5Cright)%20%20"> for k=1, …, K [p<sub>0</sub>(d) = 1 by definition] where d<sub>ref</sub> is a reference dose.</p>
<p>The αs are constrained such that α<sub>1</sub> &gt; α<sub>2</sub> &gt; … &gt; α<sub>K</sub>.</p>
<p>The priors for the model’s parameters are:</p>
<p><img src="https://latex.codecogs.com/png.latex?%20%5Calpha_k%20%5Csim%20N(%5Cmu_%7B%5Calpha_k%7D,%20%5Csigma_%7B%5Calpha_k%7D%5E2)%20"></p>
<p>and</p>
<p><img src="https://latex.codecogs.com/png.latex?%20%5Clog(%5Cbeta)%20%5Csim%20N(%5Cmu_%5Cbeta,%20%5Csigma_%5Cbeta%5E2)%20"></p>
<p>A <code>LogisticLogOrdinal</code> is initialised in exactly the same way as a <code>LogisticLogNormal</code> object:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">ordinal_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticLogNormalOrdinal</span>(</span>
<span id="cb3-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb3-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diag</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)),</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ref_dose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">55</span></span>
<span id="cb3-5">)</span></code></pre></div></div>
</div>
<p>The entries in the <code>mean</code> and <code>cov</code> parameters define the hyper priors for α<sub>1</sub> to α<sub>K-1</sub> and β in that order.</p>
</section>
<section id="model-fitting" class="level2">
<h2 class="anchored" data-anchor-id="model-fitting">Model fitting</h2>
<p><code>mcmc</code> works as expected with ordinal models:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">opts <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.DefaultMcmcOptions</span>()</span>
<span id="cb4-2"></span>
<span id="cb4-3">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(ordinal_data, ordinal_model, opts)</span></code></pre></div></div>
</div>
<blockquote class="blockquote">
<p>The warning message is expected and can be ignored. It will be suppressed in a future version of <code>crmPack</code>. See issue 748.</p>
</blockquote>
<p>The <code>Samples</code> object returned by <code>mcmc</code> is a standard <code>Samples object</code>. The names of the entries in its <code>data</code> slot are</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data)</span>
<span id="cb5-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "alpha1" "alpha2" "beta"</span></span></code></pre></div></div>
</div>
<p>It can be passed to the <code>fit</code> method, using the <code>grade</code> parameter to specify the toxicity grade for which cumulative probabilities of toxicity are required:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit</span>(samples, ordinal_model, ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L)</span>
<span id="cb6-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    dose     middle        lower     upper</span></span>
<span id="cb6-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1    10 0.04502133 2.346493e-10 0.2875517</span></span>
<span id="cb6-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 2    20 0.08258782 1.919062e-06 0.3679803</span></span>
<span id="cb6-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 3    30 0.13648095 3.600144e-04 0.4437057</span></span>
<span id="cb6-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 4    40 0.22102079 1.452660e-02 0.5296442</span></span>
<span id="cb6-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 5    50 0.35518587 1.092286e-01 0.6427068</span></span>
<span id="cb6-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 6    60 0.51429432 2.002098e-01 0.8541449</span></span>
<span id="cb6-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 7    70 0.62448735 2.325440e-01 0.9686036</span></span>
<span id="cb6-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 8    80 0.69190604 2.526258e-01 0.9943650</span></span>
<span id="cb6-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 9    90 0.73595437 2.668559e-01 0.9988900</span></span>
<span id="cb6-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 10  100 0.76674321 2.854392e-01 0.9997201</span></span>
<span id="cb6-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit</span>(samples, ordinal_model, ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>L)</span>
<span id="cb6-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    dose     middle        lower     upper</span></span>
<span id="cb6-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1    10 0.02445520 9.695675e-11 0.1646648</span></span>
<span id="cb6-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 2    20 0.04484939 7.477829e-07 0.2297410</span></span>
<span id="cb6-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 3    30 0.07462018 1.465875e-04 0.2865612</span></span>
<span id="cb6-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 4    40 0.12350902 4.680967e-03 0.3332346</span></span>
<span id="cb6-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 5    50 0.20980001 5.368287e-02 0.4492896</span></span>
<span id="cb6-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 6    60 0.34517482 9.621433e-02 0.6883669</span></span>
<span id="cb6-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 7    70 0.46966989 1.169156e-01 0.9276934</span></span>
<span id="cb6-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 8    80 0.55581894 1.322795e-01 0.9840434</span></span>
<span id="cb6-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 9    90 0.61528941 1.416466e-01 0.9965699</span></span>
<span id="cb6-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 10  100 0.65809407 1.448025e-01 0.9991818</span></span></code></pre></div></div>
</div>
<p>The <code>cumulative</code> flag can be used to request grade-specific probabilities.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit</span>(samples, ordinal_model, ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cumulative =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb7-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    dose     middle        lower     upper</span></span>
<span id="cb7-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1    10 0.02056612 6.358354e-11 0.1424556</span></span>
<span id="cb7-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 2    20 0.03773843 4.507357e-07 0.2014339</span></span>
<span id="cb7-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 3    30 0.06186077 6.863616e-05 0.2579801</span></span>
<span id="cb7-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 4    40 0.09751177 1.448986e-03 0.3332912</span></span>
<span id="cb7-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 5    50 0.14538586 4.264423e-03 0.4144488</span></span>
<span id="cb7-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 6    60 0.16911950 5.554296e-03 0.4707010</span></span>
<span id="cb7-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 7    70 0.15481747 4.665079e-03 0.4673285</span></span>
<span id="cb7-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 8    80 0.13608710 1.874058e-03 0.4512181</span></span>
<span id="cb7-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 9    90 0.12066496 5.940632e-04 0.4331846</span></span>
<span id="cb7-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 10  100 0.10864914 1.398681e-04 0.4114724</span></span>
<span id="cb7-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit</span>(samples, ordinal_model, ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>L, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cumulative =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb7-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    dose     middle        lower     upper</span></span>
<span id="cb7-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1    10 0.02445520 9.695675e-11 0.1646648</span></span>
<span id="cb7-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 2    20 0.04484939 7.477829e-07 0.2297410</span></span>
<span id="cb7-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 3    30 0.07462018 1.465875e-04 0.2865612</span></span>
<span id="cb7-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 4    40 0.12350902 4.680967e-03 0.3332346</span></span>
<span id="cb7-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 5    50 0.20980001 5.368287e-02 0.4492896</span></span>
<span id="cb7-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 6    60 0.34517482 9.621433e-02 0.6883669</span></span>
<span id="cb7-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 7    70 0.46966989 1.169156e-01 0.9276934</span></span>
<span id="cb7-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 8    80 0.55581894 1.322795e-01 0.9840434</span></span>
<span id="cb7-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 9    90 0.61528941 1.416466e-01 0.9965699</span></span>
<span id="cb7-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 10  100 0.65809407 1.448025e-01 0.9991818</span></span></code></pre></div></div>
</div>
<blockquote class="blockquote">
<p>Note that, for <code>grade == K - 1</code>, the cumulative and grade-specific probabilities of toxicities are identical.</p>
</blockquote>
<p>The <code>plot</code> method also takes <code>grade</code> and <code>cumulative</code> parameters.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(samples, ordinal_model, ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>L)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_ordinal/index_files/figure-html/plot1-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph of the posterior probability of toxicity (DLT only) against dose.  The mean probability of toxicity is barely above 0% at a dose of zero and rises in a sigmoidal curve to around 65% at a dose of 100.  The confidence interval is relatively narrow for low doses but widens considerably for doses over 60, extending from around 15% to 100% for a dose of 100."></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(samples, ordinal_model, ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_ordinal/index_files/figure-html/plot2-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph of the posterior cumulative probability of toxicity (sub-toxic AE or DLT) against dose.  The mean probability of toxicity is barely above 0% at a dose of zero and rises in a sigmoidal curve to around 75% at a dose of 100.  The confidence interval is relatively narrow for low doses but widens considerably for doses over 60, extending from around 30% to 100% for a dose of 100."></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(samples, ordinal_model, ordinal_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cumulative =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_ordinal/index_files/figure-html/plot3-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph of the posterior probability of sub toxic AE against dose.  The mean probability of toxicity is barely above 0% at a dose of zero, rises to a peak of about 18% at a dose of 60 before falling to around 12% at a dose of 100.  The confidence interval is relatively narrow for low doses but widens considerably for doses over 60, extending from around 30% to 100% for a dose of 100."></p>
</figure>
</div>
</div>
</div>
</section>
<section id="rules-classes-for-ordinal-models" class="level2">
<h2 class="anchored" data-anchor-id="rules-classes-for-ordinal-models"><code>Rules</code> classes for ordinal models</h2>
<p>For each class of <code>Rule</code> (that is, <code>CohortSize</code>, <code>Increments</code>, <code>NextBest</code> and <code>Stopping</code>), <code>crmPack</code> provides a single wrapper class that allows the <code>Rule</code> to be applied in trials using ordinal CRM models. The wrapper class has the name <code>&lt;Rule&gt;Ordinal</code> and takes two parameters, <code>rule</code> and <code>grade</code>. <code>rule</code> defines the standard <code>crmPck</code> <code>Rule</code> and <code>grade</code> the toxicity grade at which the rule should be applied.</p>
<p>For example</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">dlt_rule <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeDLT</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>))</span>
<span id="cb11-2">ordinal_rule_1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeOrdinal</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rule =</span> dlt_rule)</span>
<span id="cb11-3">ordinal_rule_2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeOrdinal</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>L, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rule =</span> dlt_rule)</span>
<span id="cb11-4"></span>
<span id="cb11-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">size</span>(ordinal_rule_1, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, empty_ordinal_data)</span>
<span id="cb11-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 1</span></span>
<span id="cb11-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">size</span>(ordinal_rule_2, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, empty_ordinal_data)</span>
<span id="cb11-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 1</span></span>
<span id="cb11-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">size</span>(ordinal_rule_1, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, ordinal_data)</span>
<span id="cb11-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 5</span></span>
<span id="cb11-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">size</span>(ordinal_rule_2, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, ordinal_data)</span>
<span id="cb11-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 3</span></span></code></pre></div></div>
</div>
<p><code>Rules</code> based on different toxicity grades can be combined to produce complex rules. Here we define two <code>Increments</code> rules, one based on toxicity grade 1, the other on toxicity grade 2. Recall two sub toxic AEs and one DLT have been reported in the example data set.</p>
<p>Thus, the rule based on sub-toxic AEs allows a maximum increment of 0.67 because three events have been reported, giving a maximum permitted dose of 100.2. As only one DLT has been reported, the second rule allows an increment of 0.5, giving a maximum permitted dose of 90.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">ordinal_rule_1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsOrdinal</span>(</span>
<span id="cb12-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L,</span>
<span id="cb12-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rule =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelativeDLT</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.67</span>))</span>
<span id="cb12-4">)</span>
<span id="cb12-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(ordinal_rule_1, ordinal_data)</span>
<span id="cb12-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 100.2</span></span>
<span id="cb12-7">ordinal_rule_2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsOrdinal</span>(</span>
<span id="cb12-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grade =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>L,</span>
<span id="cb12-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rule =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelativeDLT</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>))</span>
<span id="cb12-10">)</span>
<span id="cb12-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(ordinal_rule_2, ordinal_data)</span>
<span id="cb12-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 90</span></span></code></pre></div></div>
</div>
<p>The two grade-specific rules can be combined into a single rule using <code>IncrementsMin</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">trial_rule <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsMin</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(ordinal_rule_1, ordinal_rule_2))</span>
<span id="cb13-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(trial_rule, ordinal_data)</span>
<span id="cb13-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 90</span></span></code></pre></div></div>
</div>
</section>
</section>
<section id="on-the-need-for-a-diagonal-covariance-matrix" class="level1">
<h1>On the need for a diagonal covariance matrix</h1>
<p>Consider a standard logistic log Normal CRM model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticLogNormal</span>(</span>
<span id="cb14-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb14-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb14-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ref_dose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span></span>
<span id="cb14-5">)</span>
<span id="cb14-6"></span>
<span id="cb14-7">model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>cov</span>
<span id="cb14-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;      [,1] [,2]</span></span>
<span id="cb14-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1,]  4.0 -0.5</span></span>
<span id="cb14-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [2,] -0.5  3.0</span></span></code></pre></div></div>
</div>
<p>We can estimate the prior using an empty <code>Data</code> object…</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>))</span>
<span id="cb15-2">options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb15-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30000</span>,</span>
<span id="cb15-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rng_kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mersenne-Twister"</span>,</span>
<span id="cb15-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rng_seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8191316</span></span>
<span id="cb15-6">)</span>
<span id="cb15-7">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(data, model, options)</span></code></pre></div></div>
</div>
<p>and then obtain the correlation between the model’s parameters [recalling that the prior is defined in terms of log(alpha1)]…</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1">d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cbind</span>(samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha0, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha1)))</span>
<span id="cb16-2">sigmaHat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cov</span>(d)</span>
<span id="cb16-3">sigmaHat</span>
<span id="cb16-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;            [,1]       [,2]</span></span>
<span id="cb16-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1,]  4.0094331 -0.5416752</span></span>
<span id="cb16-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [2,] -0.5416752  3.0363958</span></span></code></pre></div></div>
</div>
<p>So we requested a covariance of -0.5 and got -0.5416755.2. Pretty good!</p>
<p>Now look an ordinal CRM model with non-zero correlation between its parameters.</p>
<p>To begin, take a copy of the current <code>LogisticLogNormalOrdinal</code> model and give it a non-diagonal covariance matrix by accessing its <code>params@cov</code> slot directly, deliberately avoiding object validation.</p>
<blockquote class="blockquote">
<p>NB This is poor practice and not recommended. It is done here purely for illustration.</p>
</blockquote>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">ordinal_model_temp <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ordinal_model</span>
<span id="cb17-2">ordinal_model_temp<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>cov <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb17-3"></span>
<span id="cb17-4">ordinal_model_temp<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>cov</span>
<span id="cb17-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;      [,1] [,2] [,3]</span></span>
<span id="cb17-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1,]  4.0 -0.5 -0.5</span></span>
<span id="cb17-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [2,] -0.5  3.0 -0.5</span></span>
<span id="cb17-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [3,] -0.5 -0.5  1.0</span></span></code></pre></div></div>
</div>
<p>Fit the revised model to obtain the prior.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1">ordinal_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataOrdinal</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>))</span>
<span id="cb18-2">ordinal_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(ordinal_data, ordinal_model_temp, options)</span></code></pre></div></div>
</div>
<p>Finally, look at the covariance matrix, remembering to use <code>log(beta)</code> rather than <code>beta</code>…</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1">ordinalD <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.matrix</span>(</span>
<span id="cb19-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cbind</span>(</span>
<span id="cb19-3">    ordinal_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha1,</span>
<span id="cb19-4">    ordinal_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha2,</span>
<span id="cb19-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(ordinal_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>beta)</span>
<span id="cb19-6">  )</span>
<span id="cb19-7">)</span>
<span id="cb19-8">sigmaHat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cov</span>(ordinalD)</span>
<span id="cb19-9">sigmaHat</span>
<span id="cb19-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;             [,1]        [,2]         [,3]</span></span>
<span id="cb19-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1,]  4.00158899 2.768345336 -0.001112980</span></span>
<span id="cb19-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [2,]  2.76834534 2.924696828  0.008697924</span></span>
<span id="cb19-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [3,] -0.00111298 0.008697924  1.012033823</span></span></code></pre></div></div>
</div>
<p>The correlations are nothing like what we requested. This is due to the constraints imposed on the intercepts by the model. The situation will most likely worsen as the number of toxicity categories increases.</p>
<p>We have an open issue - <a href="https://github.com/openpharma/crmPack/issues/755">#755</a> - to examine options for allowing end users to specify correlation structures for ordinal CRM models. If you would like to contribute, please do so.</p>
</section>
<section id="some-observations" class="level1">
<h1>Some observations</h1>
<ul>
<li>We are currently considering the need for making grade-specific functionality available across more <code>crmPack</code> methods. If you have a specific use case that is not currently supported, please contact us.</li>
<li>If you have a need for ordinal CRM in dual endpoint models, please let us know.</li>
<li>Had <code>crmPack</code> supported ordinal CRM from the outset, the classes that support standard, binary, CRM models would have been sub-classes of the more general ordinal implementations. We did consider taking this approach when adding support for ordinal CRM models to the existing code. We decided against doing so for purely defensive and conservative reasons. Had we introduced the ordinal classes as parents of the existing classes, changes to the code base would have been much more substantial and we were concerned that we might miss some implicit assumptions about the dimensionality of the existing models. We therefore chose to implement ordinal classes as siblings, rather than parents, of the existing classes. This approach minimises the risk of breaking existing end-user code at the risk of slightly greater complexity in using the new classes.</li>
</ul>
</section>
<section id="references" class="level1">




</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-oquigley1990" class="csl-entry">
O’Quigley, John, Margaret Pepe, and Lloyd Fisher. 1990. <span>“Continual Reassessment Method: A Practical Design for Phase 1 Clinical Trials in Cancer.”</span> <em>Biometrics</em> 46 (1): 33–48.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Examples</category>
  <guid>https://www.crmpack.org/vignettes/examples/crmPack_ordinal/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_03.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Rolling continual reassessment method (CRM) for dose escalation</title>
  <dc:creator>Jiawen Zhu, Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/examples/crmPack_rolling/</link>
  <description><![CDATA[ 




<p>Please note that for understanding this vignette easily, it is recommended to first read the methodology paper introducing the rolling CRM design. <span class="citation" data-cites="ZhuSabanes2021">(Zhu et al. 2021)</span></p>
<section id="example-1-recommend-a-dose-for-the-next-cohort" class="level2">
<h2 class="anchored" data-anchor-id="example-1-recommend-a-dose-for-the-next-cohort">Example 1: Recommend a dose for the next cohort</h2>
<section id="setting-up-the-data" class="level3">
<h3 class="anchored" data-anchor-id="setting-up-the-data">Setting up the data</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(crmPack)</span>
<span id="cb1-2">data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataDA</span>(</span>
<span id="cb1-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>),</span>
<span id="cb1-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb1-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>),</span>
<span id="cb1-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)),</span>
<span id="cb1-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span></span>
<span id="cb1-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb1-9">      <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>,</span>
<span id="cb1-10">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb1-11">    ),</span>
<span id="cb1-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">u =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>),</span>
<span id="cb1-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t0 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>),</span>
<span id="cb1-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Tmax =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span></span>
<span id="cb1-15">)</span>
<span id="cb1-16"></span>
<span id="cb1-17">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataDA</span>(</span>
<span id="cb1-18">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb1-19">    <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>,</span>
<span id="cb1-20">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb1-21">  ),</span>
<span id="cb1-22">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Tmax =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span></span>
<span id="cb1-23">)</span></code></pre></div></div>
</div>
</section>
<section id="structure-of-the-model-class" class="level3">
<h3 class="anchored" data-anchor-id="structure-of-the-model-class">Structure of the model class</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">npiece_ <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span></span>
<span id="cb2-2">Tmax_ <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span></span>
<span id="cb2-3"></span>
<span id="cb2-4">lambda_prior <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(k) {</span>
<span id="cb2-5">  npiece_ <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (Tmax_ <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (npiece_ <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> k <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>))</span>
<span id="cb2-6">}</span>
<span id="cb2-7"></span>
<span id="cb2-8">model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DALogisticLogNormal</span>(</span>
<span id="cb2-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb2-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb2-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ref_dose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">56</span>,</span>
<span id="cb2-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">npiece =</span> npiece_,</span>
<span id="cb2-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">l =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">t</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">apply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>npiece_), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, npiece_), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, lambda_prior))),</span>
<span id="cb2-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">c_par =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb2-15">)</span></code></pre></div></div>
</div>
</section>
<section id="obtain-the-posterior" class="level3">
<h3 class="anchored" data-anchor-id="obtain-the-posterior">Obtain the posterior</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb3-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb3-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e2</span></span>
<span id="cb3-5">)</span>
<span id="cb3-6"></span>
<span id="cb3-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">94</span>)</span>
<span id="cb3-8">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(data, model, options)</span></code></pre></div></div>
</div>
</section>
<section id="use-ggmcmc-to-diagnose" class="level3">
<h3 class="anchored" data-anchor-id="use-ggmcmc-to-diagnose">Use ggmcmc to diagnose</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggmcmc)</span>
<span id="cb4-2">alpha0samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get</span>(samples, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"alpha0"</span>)</span>
<span id="cb4-3"></span>
<span id="cb4-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggs_traceplot</span>(alpha0samples))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_rolling/index_files/figure-html/Diagnose-1-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A trace plot for alpha0.  It looks like skyscrapers ina big city, but there are only just over 200 samples in the chain."></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggs_autocorrelation</span>(alpha0samples))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_rolling/index_files/figure-html/Diagnose-2-1.png" class="img-fluid figure-img" style="width:100.0%" alt="An auto correlation plot for aplha0.  There is significant auto-correlation of 0.25 or more even at lags of 50.  There is seasonality too, with three groups of negative auto-correlation and four of positive."></p>
</figure>
</div>
</div>
</div>
</section>
<section id="plot-the-model-fit" class="level3">
<h3 class="anchored" data-anchor-id="plot-the-model-fit">Plot the model fit</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(samples, model, data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hazard =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_rolling/index_files/figure-html/Fit-1-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two plots in a single row.  The first shows the posterior mean and ci for the probability of toxicity by dose.  The second shows 100 times the posterior hazard by time."></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(samples, model, data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hazard =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_rolling/index_files/figure-html/Fit-2-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two plots in a single row.  Both show the posterior mean and ci for the probability of toxicity by dose on the y axis.  In the first plot, the x axis is dose.  In the second, it is time."></p>
</figure>
</div>
</div>
</div>
</section>
<section id="prior-mean-curve" class="level3">
<h3 class="anchored" data-anchor-id="prior-mean-curve">prior mean curve</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataDA</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb8-2">  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>,</span>
<span id="cb8-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb8-4">), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Tmax =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>)</span>
<span id="cb8-5"></span>
<span id="cb8-6">Priorsamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(emptydata, model, options)</span>
<span id="cb8-7"></span>
<span id="cb8-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(Priorsamples, model, emptydata, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hazard =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_rolling/index_files/figure-html/Prior-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two plots in a single row.  Both show the prior mean and ci for the probability of toxicity by dose on the y axis.  In the first plot, the x axis is dose.  In the second, it is time."></p>
</figure>
</div>
</div>
</div>
</section>
<section id="escalation-rules" class="level3">
<h3 class="anchored" data-anchor-id="escalation-rules">Escalation rules</h3>
<p>Need to fill in (use the same rule in the section 8 of “using the package crmPack: introductory examples”)</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">myIncrements <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelative</span>(</span>
<span id="cb9-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>),</span>
<span id="cb9-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.33</span>)</span>
<span id="cb9-4">)</span>
<span id="cb9-5"></span>
<span id="cb9-6">nextMaxDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(myIncrements, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data)</span>
<span id="cb9-7"></span>
<span id="cb9-8">myNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestNCRM</span>(</span>
<span id="cb9-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>),</span>
<span id="cb9-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overdose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb9-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_overdose_prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span></span>
<span id="cb9-12">)</span>
<span id="cb9-13"></span>
<span id="cb9-14">mySize1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeRange</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb9-15">mySize2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeDLT</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb9-16">mySize <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxSize</span>(mySize1, mySize2)</span>
<span id="cb9-17"></span>
<span id="cb9-18">myStopping1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingTargetProb</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb9-19">myStopping2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinPatients</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>)</span>
<span id="cb9-20">myStopping <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (myStopping1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> myStopping2)</span></code></pre></div></div>
</div>
</section>
<section id="recommended-dose-for-the-next-cohort" class="level3">
<h3 class="anchored" data-anchor-id="recommended-dose-for-the-next-cohort">Recommended dose for the next cohort</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">doseRecommendation <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(myNextBest,</span>
<span id="cb10-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> nextMaxDose,</span>
<span id="cb10-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> samples,</span>
<span id="cb10-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb10-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data</span>
<span id="cb10-6">)</span>
<span id="cb10-7"></span>
<span id="cb10-8">doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plot</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_rolling/index_files/figure-html/Recommend-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two graphs arranged in a single column.  The upper graph shoes green lines of various heights that show the probability each dose is in the target toxicity range.  There is a big arrow pointing to the bar at a dose of 0.5, that this is the recommended dose for the next cohort.  The bars for other doses are higher, but they are not eligible for dosing because of the overdose rule illustrated in the second graph below.  The lower graph as a similar series of red lines, indicating the probability that each dose is in the overdose range.  There is a horizontal black dashed line at 25%, indicating that this is the highest acceptable probability of being in the overdose range.  The red bars for doses above 0.5 all extend above 25%, indicating that their toxicity is unacceptable.  The toxicity for doses of 0.1 and 0.5 lie below 25%."></p>
</figure>
</div>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb11-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 0.1</span></span></code></pre></div></div>
</div>
</section>
</section>
<section id="example-2-run-a-simulation-to-evaluate-operating-characteristics" class="level2">
<h2 class="anchored" data-anchor-id="example-2-run-a-simulation-to-evaluate-operating-characteristics">Example 2: Run a simulation to evaluate operating characteristics</h2>
<section id="set-up-safety-window-and-dadesign-to-be-completed" class="level3">
<h3 class="anchored" data-anchor-id="set-up-safety-window-and-dadesign-to-be-completed">Set up safety window and <code>DADesign</code> to be completed</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">mysafetywindow <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">SafetyWindowConst</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>)</span>
<span id="cb12-2"></span>
<span id="cb12-3">design <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DADesign</span>(</span>
<span id="cb12-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb12-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements,</span>
<span id="cb12-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> myNextBest,</span>
<span id="cb12-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping,</span>
<span id="cb12-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize,</span>
<span id="cb12-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> emptydata,</span>
<span id="cb12-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">safetyWindow =</span> mysafetywindow,</span>
<span id="cb12-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb12-12">)</span></code></pre></div></div>
</div>
</section>
<section id="set-up-true-curves" class="level3">
<h3 class="anchored" data-anchor-id="set-up-true-curves">Set up true curves</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">myTruth <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb13-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">curve</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruth</span>(x), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_rolling/index_files/figure-html/Truth-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A logistic dose response curverising from 0 at dose 0 to almost 100% for a dose of 100."></p>
</figure>
</div>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"></span>
<span id="cb14-2">onset <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span></span>
<span id="cb14-3">exp_cond.cdf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb14-4">  <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pexp</span>(x, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> onset, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lower.tail =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pexp</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">28</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> onset, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lower.tail =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pexp</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">28</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> onset)</span>
<span id="cb14-5">}</span></code></pre></div></div>
</div>
</section>
<section id="perform-the-simulations" class="level3">
<h3 class="anchored" data-anchor-id="perform-the-simulations">Perform the simulations</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">mySims <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(design,</span>
<span id="cb15-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb15-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truthTox =</span> myTruth,</span>
<span id="cb15-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truthSurv =</span> exp_cond.cdf,</span>
<span id="cb15-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueTmax =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>,</span>
<span id="cb15-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb15-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>,</span>
<span id="cb15-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> options,</span>
<span id="cb15-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">firstSeparate =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb15-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">deescalate =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb15-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb15-12">)</span></code></pre></div></div>
</div>
</section>
<section id="interpret-the-simulation-results" class="level3">
<h3 class="anchored" data-anchor-id="interpret-the-simulation-results">Interpret the simulation results</h3>
<p>Use a similar way as section 9.2 in the “using the package crmPack: introductory examples” document</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1">a <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(mySims, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth)</span>
<span id="cb16-2">b <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> mySims<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]]</span>
<span id="cb16-3"></span>
<span id="cb16-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(mySims)</span>
<span id="cb16-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(b)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_rolling/index_files/figure-html/Interpret-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two graphs in a single column, summarising the results of a single simulated trial.  The upper one plots patient number on the x axis and dose andministered on the y axis.  Different symbols indicate whether or not each participant reported a toxicity.  Sixteen patients were enrolled, four of which reported toxicities.  The points rise and fall like waves in response to changes in the model's recommended dose.  The lower one plots time on the x axis and patient number on the y axis.  For each patient, a horizontal line runs from their enrolment time to the time at which they reported a toxicity, completed their safety evaluatiuon window or (at the end of the trial) were censored.  Different coloured and shaped symbols at the right hand end of each line indicate whether or not the participant reported a toxicity."></p>
</figure>
</div>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"></span>
<span id="cb17-2">mySims<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>stop_reasons[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]]</span>
<span id="cb17-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[1]]</span></span>
<span id="cb17-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 84 % for dose 24 and thus above the required 50 %"</span></span>
<span id="cb17-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb17-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[2]]</span></span>
<span id="cb17-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 24 and thus below the prespecified minimum number 50"</span></span></code></pre></div></div>
</div>



</section>
</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-ZhuSabanes2021" class="csl-entry">
Zhu, Jiawen, Daniel Sabanés Bové, Ziwei Liao, Ulrich Beyer, Godwin Yung, and Somnath Sarkar. 2021. <span>“Rolling Continual Reassessment Method with Overdose Control: An Efficient and Safe Dose Escalation Design.”</span> <em>Contemporary Clinical Trials</em> 107: 106436. https://doi.org/<a href="https://doi.org/10.1016/j.cct.2021.106436">https://doi.org/10.1016/j.cct.2021.106436</a>.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Examples</category>
  <guid>https://www.crmpack.org/vignettes/examples/crmPack_rolling/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_04.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Several examples how to use crmPack for model-based dose escalation trial design</title>
  <dc:creator>Ziwei Liao, Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/examples/crmPack_example/</link>
  <description><![CDATA[ 




<p>This short vignette shall introduce into the usage of the package <code>crmPack</code>. Hopefully it makes it easy for you to set up your own CRM.</p>
<p>If you have any questions or feedback concerning the package, please write an email to the package maintainer: <script type="text/javascript">
<!--
h='&#114;&#x63;&#x6f;&#110;&#x69;&#x73;&#46;&#x63;&#x6f;&#x6d;';a='&#64;';n='&#100;&#x61;&#110;&#x69;&#x65;&#108;&#46;&#x73;&#x61;&#98;&#x61;&#110;&#x65;&#x73;&#x5f;&#98;&#x6f;&#118;&#x65;';e=n+a+h;
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>');
// -->
</script><noscript>daniel.sabanes_bove at rconis dot com</noscript>.</p>
<p>Thank you very much in advance!</p>
<section id="installation" class="level1">
<h1>Installation</h1>
<p>Many models in <code>crmPack</code> rely on <a href="https://mcmc-jags.sourceforge.io/">JAGS</a> (please click on the link for going to the webpage of the project) for the internal MCMC computations. WinBUGS is not required or supported anymore.</p>
</section>
<section id="getting-started" class="level1">
<h1>Getting started</h1>
<p>Before being able to run anything, you have to load the package with</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(crmPack)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(data.tree)</span></code></pre></div></div>
</div>
<p>For browsing the help pages for the package, it is easiest to start the web browser interface with</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">crmPackHelp</span>()</span></code></pre></div></div>
</div>
<p>This gives you the list of all help pages available for the package. The whole R-package is built in a modular form, by using S4 classes and methods. Please have a look at the help page “Methods” to read an introduction into the S4 object framework of R, by typing <code>?Methods</code> in the R console. In the next sections we will therefore go one by one through the important building blocks (S4 classes and corresponding methods) of CRM designs with <code>crmPack</code>.</p>
</section>
<section id="data" class="level1">
<h1>Data</h1>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb3-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pathString =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb3-3">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GeneralData/Data/DataDual"</span></span>
<span id="cb3-4">  )</span>
<span id="cb3-5">)</span>
<span id="cb3-6"></span>
<span id="cb3-7">tree <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.Node</span>(df)</span>
<span id="cb3-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">SetNodeStyle</span>(tree, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"box"</span>)</span>
<span id="cb3-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(tree)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="grViz html-widget html-fill-item" id="htmlwidget-b8a184f90190b08ed5ac" style="width:100%;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-b8a184f90190b08ed5ac">{"x":{"diagram":"digraph {\n\n\n\n\n  \"1\" [label = \"GeneralData\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"2\" [label = \"Data\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"3\" [label = \"DataDual\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"1\"->\"2\" \n  \"2\"->\"3\" \n}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
<p>Data classes structure</p>
</div>
</div>
<p>We have three data classes for this package. The parent class is the <code>GeneralData</code> class. The <code>Data</code> class is inheriting from the <code>GeneralData</code> class and the <code>DataDual</code> class is inheriting from the <code>Data</code> class. Inheritance means that the subclass has all the slots (attributes) of the parent class, but can also have additional slots. Methods that work on the parent class also work the same way on the subclass, unless a specialized method for the subclass has been defined.</p>
<p>First, we will set up the data set. If you are at the beginning of a trial, no observations will be available. Then we can define an empty data set, for example:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb4-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span></span>
<span id="cb4-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb4-4">      <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>,</span>
<span id="cb4-5">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb4-6">    )</span>
<span id="cb4-7">)</span></code></pre></div></div>
</div>
<p>The <code>R</code>-package <code>crmPack</code> uses the S4 class system for implementation of the dose-escalation designs. There is the convention that class initialization functions have the same name as the class, and all class names are capitalized. Note that in order to create this <code>Data</code> object, we use the initialization function of the same name, and give it as parameters the contents of the object to be constructed. At least the <code>doseGrid</code> parameter, which contains all possible dose levels to be potentially used in the trial, must be specified in a call of the <code>Data()</code> initialization function.</p>
<p>If you are in the middle of a trial and you would like to recommend the next dose, then you have data from the previous patients for input into the model. This data can also be captured in a <code>Data</code> object. For example:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb5-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>),</span>
<span id="cb5-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb5-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>),</span>
<span id="cb5-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span></span>
<span id="cb5-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb5-7">      <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>,</span>
<span id="cb5-8">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb5-9">    )</span>
<span id="cb5-10">)</span></code></pre></div></div>
</div>
<p>Most important are <code>x</code> (the doses) and <code>y</code> (the DLTs, <code>0</code> for no DLT and <code>1</code> for DLT), and we are using the same dose grid <code>doseGrid</code> as before. All computations are using the dose grid specified in the <code>Data</code> object. So for example, except for patient number 7, all patients were free of DLTs.</p>
<p>Again, you can find out the details in the help page <code>Data-class</code>. Note that you have received a warning here, because you did not specify the patient IDs – however, automatic ones just indexing the patients have been created for you:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>ID</span>
<span id="cb6-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 1 2 3 4 5 6 7 8</span></span></code></pre></div></div>
</div>
<p>You can get a visual summary of the data by applying <code>plot</code> to the object:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(data))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plotdata-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph with patient ID on the x axis and dose level on the y axis.  A red triangle indicates that patient 7 reported a DLT.  Black squares indicate that no other patient reported a toxicity.  Patients 1 to 5 are dosed in an ascending fashion from 0.1 to 6.  Patients 6 to 9 are dosed at 10."></p>
</figure>
</div>
</div>
</div>
<blockquote class="blockquote">
<p>Note that for all <code>plot</code> calls in this vignette, you can leave away the wrapping <code>print</code> function call if you are working interactively with <code>R</code>. It is only because of the <code>knitr</code> production of this vignette that the <code>print</code> statement is needed.</p>
</blockquote>
</section>
<section id="structure-of-the-model-class" class="level1">
<h1>Structure of the model class</h1>
<p>Figure @ref(fig:model-classes) shows the structure of the model class defined in this package. The <code>AllModels</code> class is the parent class from which all model classes inherit. There are two sub-classes: First, the <code>GeneralModel</code> class from which all models inherit that are using <code>JAGS</code> to specify the model and the prior distribution and will then be estimated by MCMC later on. Then, the second subclass is the <code>ModelPseudo</code> class for which the prior of the models are specified in terms of pseudo data and standard maximum likelihood routines from R will be used for computational purposes. All models included in this package will have a parent class of either the <code>GeneralModel</code> or the <code>ModelPseudo</code> classes. There are two further classes under <code>ModelPseudo</code> which are the <code>ModelTox</code> class include all DLT (the occurrence of a dose-limiting toxicity) class models, and class <code>ModelEff</code> which includes all efficacy class models.</p>
<div class="cell">
<div class="cell-output-display">
<div class="grViz html-widget html-fill-item" id="htmlwidget-cc1671d2359c4804d51c" style="width:100%;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-cc1671d2359c4804d51c">{"x":{"diagram":"digraph {\n\n\n\n\n  \"1\" [label = \"AllModels\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"2\" [label = \"GeneralModel\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"3\" [label = \"Model\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"4\" [label = \"LogisiticNormal\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"5\" [label = \"LogisticLogNormalSub\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"6\" [label = \"LogisiticKadane\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"7\" [label = \"ModelPseudo\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"8\" [label = \"ModelEff\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"9\" [label = \"Effloglog\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"10\" [label = \"EffFlexi\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"11\" [label = \"ModelTox\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"12\" [label = \"LogisticIndepBeta\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"1\"->\"2\" \n  \"1\"->\"7\" \n  \"2\"->\"3\" \n  \"7\"->\"8\" \n  \"7\"->\"11\" \n  \"3\"->\"4\" \n  \"3\"->\"5\" \n  \"3\"->\"6\" \n  \"8\"->\"9\" \n  \"8\"->\"10\" \n  \"11\"->\"12\" \n}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
<p>Model classes structure</p>
</div>
</div>
</section>
<section id="model-setup" class="level1">
<h1>Model setup</h1>
<section id="logistic-model-with-bivariate-log-normal-prior" class="level2">
<h2 class="anchored" data-anchor-id="logistic-model-with-bivariate-log-normal-prior">Logistic model with bivariate (log) normal prior</h2>
<p>First, we will show an example of setting up of a model inheriting from the <code>model</code> and <code>GeneralModel</code> classes, the logistic normal model. You can click on the corresponding help page <code>LogisticLogNormal-class</code> as background information for the next steps.</p>
<p>With the following command, we create a new model of class <code>LogisticLogNormal</code>, with certain mean and covariance prior parameters and reference dose:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticLogNormal</span>(</span>
<span id="cb8-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb8-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span></span>
<span id="cb8-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb8-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb8-6">    ),</span>
<span id="cb8-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ref_dose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">56</span></span>
<span id="cb8-8">)</span></code></pre></div></div>
</div>
<p>We can query the class that an object belongs to with the <code>class</code> function:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">class</span>(model)</span>
<span id="cb9-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "LogisticLogNormal"</span></span>
<span id="cb9-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"package")</span></span>
<span id="cb9-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "crmPack"</span></span></code></pre></div></div>
</div>
<p>We can look in detail at the structure of <code>model</code> as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(model)</span>
<span id="cb10-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Formal class 'LogisticLogNormal' [package "crmPack"] with 9 slots</span></span>
<span id="cb10-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ params         :Formal class 'ModelParamsNormal' [package "crmPack"] with 3 slots</span></span>
<span id="cb10-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ mean: num [1:2] -0.85 1</span></span>
<span id="cb10-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ cov : num [1:2, 1:2] 1 -0.5 -0.5 1</span></span>
<span id="cb10-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ prec: num [1:2, 1:2] 1.333 0.667 0.667 1.333</span></span>
<span id="cb10-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ ref_dose       :Formal class 'positive_number' [package "crmPack"] with 1 slot</span></span>
<span id="cb10-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ .Data: num 56</span></span>
<span id="cb10-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ datamodel      :function ()  </span></span>
<span id="cb10-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ priormodel     :function ()  </span></span>
<span id="cb10-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ modelspecs     :function (from_prior)  </span></span>
<span id="cb10-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ init           :function ()  </span></span>
<span id="cb10-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ datanames      : chr [1:3] "nObs" "y" "x"</span></span>
<span id="cb10-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ datanames_prior: chr(0) </span></span>
<span id="cb10-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ sample         : chr [1:2] "alpha0" "alpha1"</span></span></code></pre></div></div>
</div>
<p>We see that the object has 9 slots, and their names. These can be accessed with the <code>@</code> operator (similarly as for lists the <code>$</code> operator), for example we can extract the <code>ref_dose</code> slot:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>ref_dose</span>
<span id="cb11-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; An object of class "positive_number"</span></span>
<span id="cb11-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 56</span></span></code></pre></div></div>
</div>
<p>You can find out yourself about the other slots, by looking at the help page for <code>Model-class</code> in the help browser, because all univariate models with JAGS specification are just special cases (subclasses) of the <code>model</code> class. In the <code>Model-class</code> help page, you also find out that there are four additional specific model classes that are sub-classes of the <code>model</code> class, namely <code>LogisticLogNormalSub</code>, <code>LogisticNormal</code>, <code>LogisticKadane</code> and <code>DualEndpoint</code>.</p>
<p>Next, we will show an example of setting up a model of the <code>ModelPseudo</code> class, the <code>LogisticIndepBeta</code> model. More specifically, this is also a model in <code>ModelTox</code> class.</p>
<p>The <code>LogisticIndepBeta</code> model is a two-parameter logistic regression model to describe the relationship between the probability of the occurrence of DLT and its corresponding log dose levels. The model parameters are φ<sub>1</sub>, for the intercept and φ <sub>2</sub>, the slope. This is also a model for which its prior is expressed in form of pseudo data.</p>
<p>Here it is important that the data set has to be defined before defining any models from <code>ModelPseudo</code> class. This is to ensure we obtained the updated estimates for the model parameters using all currently available observations. Either an empty data set or a data set that contains all currently available observations is needed.</p>
<p>Therefore, let’s assume an empty data set is set up. For example, we will use 12 dose levels from 25 to 300 mg with increments of 25 mg. Then we have:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb12-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span></span>
<span id="cb12-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>)</span>
<span id="cb12-4">)</span>
<span id="cb12-5">data1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> emptydata</span></code></pre></div></div>
</div>
<p>Then we express our prior in form of pseudo data. The idea is as follows. First fix two dose level <img src="https://latex.codecogs.com/png.latex?d_%7B(-1)%7D"> and <img src="https://latex.codecogs.com/png.latex?d_%7B(0)%7D">, which are usually the lowest and the highest dose level, so here we choose 25 and 300 mg. Then we elicit from experts or clinicians the probability of the occurrence of DLT, <img src="https://latex.codecogs.com/png.latex?p_%7B(-1)%7D"> and <img src="https://latex.codecogs.com/png.latex?p_%7B(0)%7D"> at these two dose levels. That is, assuming <img src="https://latex.codecogs.com/png.latex?n_%7B(l)%7D"> subjects are treated at each of these two dose levels, <img src="https://latex.codecogs.com/png.latex?l=-1,0">, <img src="https://latex.codecogs.com/png.latex?t_%7B(l)%7D"> out of <img src="https://latex.codecogs.com/png.latex?n%7B(l)%7D"> subjects are expected to be observed with a DLT such that <img src="https://latex.codecogs.com/png.latex?p_%7B(l)%7D%20=%20t_%7B(l)%7D/n_%7B(l)%7D">. Let <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7Bp%7D_%7B(l)%7D"> be the probability of the occurrence of a DLT at dose <img src="https://latex.codecogs.com/png.latex?l"> for dose <img src="https://latex.codecogs.com/png.latex?l=-1,0">. <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7Bp%7D_%7B(l)%7D"> will follow independent Beta distributions and the joint probability density function of <img src="https://latex.codecogs.com/png.latex?p_%7B(l)%7D"> can be obtained. Therefore, this model is called <code>LogisticIndepBeta</code>. We expressed the prior as if we have some data (pseudo data) before the trial start. The prior modal estimates of φ<sub>1</sub> and φ<sub>2</sub>, which is also equivalent to the maximum likelihood estimators, can be obtained with the R function <code>glm</code>. Please refer to <span class="citation" data-cites="WhiteheadWilliamson1998">(Whitehead and Williamson 1998)</span> for details about the form of the prior and posterior density of the model parameters φ<sub>1</sub> and φ<sub>2</sub>.</p>
<p>With the following commands, we create the model of class <code>LogisticIndepBeta</code>, with the prior specified in form of pseudo data.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">DLTmodel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticIndepBeta</span>(</span>
<span id="cb13-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">binDLE =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">DLEweights =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb13-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">DLEdose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data1</span>
<span id="cb13-4">)</span></code></pre></div></div>
</div>
<p>(Note that in some functions including this initialization function, DLE instead of DLT is used. In this vignette we use the unified abbreviation DLT throughout the text and variable names.)</p>
<p>For the model specified, we have fixed two dose levels (25 and 300 mg) and represented them in the <code>DLEdose</code> slot. Then we assume that 3 subjects are treated at each of the dose levels, represented in the <code>DLEweights</code> slot. We have 1.05 subjects out of the 3 subjects treated at 25 mg observed with a DLT and 1.8 subjects out of the 3 subjects treated at 300 mg observed with a DLT and this is represented in the <code>binDLE</code> slot. Input to the <code>Data</code> slot is also need to ensure the all currently available observations will be incorporated in the model to obtain updated modal estimates of the model parameters. If an empty data set is used in the <code>Data</code> slot, the prior modal estimates of the model parameters, φ<sub>1</sub> for the intercept and φ<sub>2</sub> for the slope, can be obtained. If a data set with observations, e.g data1 in the DLTmodel above is used, we can obtain the posterior modal estimates for the model parameters. In addition, the pseudo data can be expressed by using more than 2 dose levels. On the other hand, at least two dose levels of pseudo information are needed to obtain modal estimates of the intercept and the slope parameter. Therefore, <code>binDLE</code>,<code>DLEweights</code>, <code>DLEdose</code> must be vectors of at least length 2 and with their corresponding values specified at the same position in the other two vectors.</p>
<p>Since the imaginary nature of the pseudo data, the value <img src="https://latex.codecogs.com/png.latex?t_l"> for the number of subjects observed with DLT can be non-integer values. In principle, <img src="https://latex.codecogs.com/png.latex?n_l"> can also be non-integer values.</p>
<p>Then we can look at the structure of this model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(DLTmodel)</span>
<span id="cb14-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Formal class 'LogisticIndepBeta' [package "crmPack"] with 7 slots</span></span>
<span id="cb14-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ binDLE    : num [1:2] 1.05 1.8</span></span>
<span id="cb14-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ DLEdose   : num [1:2] 25 300</span></span>
<span id="cb14-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ DLEweights: int [1:2] 3 3</span></span>
<span id="cb14-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ phi1      : num -1.95</span></span>
<span id="cb14-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ phi2      : num 0.412</span></span>
<span id="cb14-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ Pcov      : num [1:2, 1:2] 10.05 -2.077 -2.077 0.462</span></span>
<span id="cb14-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..- attr(*, "dimnames")=List of 2</span></span>
<span id="cb14-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..$ : chr [1:2] "(Intercept)" "log(x)"</span></span>
<span id="cb14-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..$ : chr [1:2] "(Intercept)" "log(x)"</span></span>
<span id="cb14-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ data      :Formal class 'Data' [package "crmPack"] with 11 slots</span></span>
<span id="cb14-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ x         : num(0) </span></span>
<span id="cb14-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ y         : int(0) </span></span>
<span id="cb14-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ doseGrid  : num [1:12] 25 50 75 100 125 150 175 200 225 250 ...</span></span>
<span id="cb14-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ nGrid     : int 12</span></span>
<span id="cb14-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ xLevel    : int(0) </span></span>
<span id="cb14-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ placebo   : logi FALSE</span></span>
<span id="cb14-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ backfilled: logi(0) </span></span>
<span id="cb14-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ response  : int(0) </span></span>
<span id="cb14-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ ID        : int(0) </span></span>
<span id="cb14-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ cohort    : int(0) </span></span>
<span id="cb14-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ nObs      : int 0</span></span></code></pre></div></div>
</div>
<p>There are in total 10 slots and their names are given. Remember that they can be accessed with the <code>@</code> operator (similarly as for lists the <code>$</code> operator), for example we can extract the <code>phi1</code> slot:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">DLTmodel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>phi1</span>
<span id="cb15-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] -1.946152</span></span></code></pre></div></div>
</div>
<p>This gives the updated modal estimate of the intercept parameter φ<sub>1</sub>. Please find out other slots using the <code>@</code> operator and looking at the help page for <code>ModelPseudo</code>, <code>ModelTox</code> and <code>LogisticIndepBeta</code> classes.</p>
</section>
<section id="advanced-model-specification" class="level2">
<h2 class="anchored" data-anchor-id="advanced-model-specification">Advanced model specification</h2>
<p>There are a few further, advanced ways to specify a model object in <code>crmPack</code>.</p>
<p>First, a minimal informative prior <span class="citation" data-cites="Neuenschwander2008">(Neuenschwander, Branson, and Gsponer 2008)</span> can be computed using the <code>MinimalInformative</code> function. The construction is based on the input of a minimal and a maximal dose, where certain ranges of DLT probabilities are deemed unlikely. A logistic function is then fitted through the corresponding points on the dose-toxicity plane in order to derive Beta distributions also for doses in-between. Finally these Beta distributions are approximated by a common <code>LogisticNormal</code> (or <code>LogisticLogNormal</code>) model. So the minimal informative construction avoids explicit specification of the prior parameters of the logistic regression model.</p>
<p>In our example, we could construct it as follows, assuming a minimal dose of 0.1 mg and a maximum dose of 100 mg:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1">coarseGrid <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb16-2">minInfModel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">MinimalInformative</span>(</span>
<span id="cb16-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dosegrid =</span> coarseGrid,</span>
<span id="cb16-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">refDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>,</span>
<span id="cb16-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">threshmin =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>,</span>
<span id="cb16-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">threshmax =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,</span>
<span id="cb16-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">control =</span></span>
<span id="cb16-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb16-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">threshold.stop =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.03</span>,</span>
<span id="cb16-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span></span>
<span id="cb16-11">    ),</span>
<span id="cb16-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">123</span></span>
<span id="cb16-13">)</span>
<span id="cb16-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; It: 1, obj value (lsEnd): 0.4448174141 indTrace: 1</span></span>
<span id="cb16-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; It: 7, obj value (lsEnd): 0.2718844409 indTrace: 7</span></span>
<span id="cb16-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Emini is: 0.2718844409</span></span>
<span id="cb16-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; xmini are:</span></span>
<span id="cb16-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 2.836749266 2.715608294 7.436100811 0.503005996 0.3658334745 </span></span>
<span id="cb16-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Totally it used 12.21096 secs</span></span>
<span id="cb16-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; No. of function call is: 2927</span></span>
<span id="cb16-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Algorithm reached max number of iterations.</span></span></code></pre></div></div>
</div>
<p>We use a few grid points between the minimum and the maximum to guide the approximation routine, which is based on a stochastic optimization method (the <code>control</code> argument is for this optimization routine, please see the help page for <code>Quantiles2LogisticNormal</code> for details). Therefore we need to set a random number generator seed beforehand to be able to reproduce the results in the future. Please note that currently the reproducibility is under testing– it is currently advised to save the approximation result in order to certainly be able to use the same model later on again. The <code>threshmin</code> and <code>threshmax</code> values specify the probability thresholds above and below, respectively, it is very unlikely (only 5% probability) to have the true probability of DLT at the minimum and maximum dose, respectively.</p>
<p>The result <code>minInfModel</code> is a list, and we can use its contents to illustrate the creation of the prior:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matplot</span>(</span>
<span id="cb17-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> coarseGrid,</span>
<span id="cb17-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> minInfModel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>required,</span>
<span id="cb17-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"b"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">19</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb17-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dose"</span>,</span>
<span id="cb17-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"prior probability of DLT"</span></span>
<span id="cb17-7">)</span>
<span id="cb17-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matlines</span>(</span>
<span id="cb17-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> coarseGrid,</span>
<span id="cb17-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> minInfModel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>quantiles,</span>
<span id="cb17-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"b"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">19</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb17-12">)</span>
<span id="cb17-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">legend</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"right"</span>,</span>
<span id="cb17-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"quantiles"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"approximation"</span>),</span>
<span id="cb17-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>),</span>
<span id="cb17-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb17-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span></span>
<span id="cb17-18">)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/min-inf-res-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph showing the relationship between the requested quantiles of the prior and those obtained from MinimalInformative.  The approximation is less than ideal."></p>
</figure>
</div>
</div>
</div>
<p>In this plot we see in blue the quantiles (2.5%, 50%, and 97.5%) of the Beta distributions that we approximate with the red quantiles of the logistic normal model. We see that the distance is still quite large, and the maximum distance between any red and blue point is:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1">minInfModel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>distance</span>
<span id="cb18-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 0.2718844</span></span></code></pre></div></div>
</div>
<p>Therefore usually we would let the computations take longer (by removing the <code>control</code> option from the <code>MinimalInformative</code> call) to obtain a better approximation. The final approximating model, which has produced the red points, is contained in the <code>model</code> list element:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(minInfModel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>model)</span>
<span id="cb19-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Formal class 'LogisticNormal' [package "crmPack"] with 9 slots</span></span>
<span id="cb19-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ params         :Formal class 'ModelParamsNormal' [package "crmPack"] with 3 slots</span></span>
<span id="cb19-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ mean: Named num [1:2] 2.84 2.72</span></span>
<span id="cb19-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. .. ..- attr(*, "names")= chr [1:2] "meanAlpha" "meanBeta"</span></span>
<span id="cb19-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ cov : num [1:2, 1:2] 55.296 1.368 1.368 0.253</span></span>
<span id="cb19-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ prec: num [1:2, 1:2] 0.0209 -0.1129 -0.1129 4.563</span></span>
<span id="cb19-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ ref_dose       :Formal class 'positive_number' [package "crmPack"] with 1 slot</span></span>
<span id="cb19-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ .Data: num 50</span></span>
<span id="cb19-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ datamodel      :function ()  </span></span>
<span id="cb19-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ priormodel     :function ()  </span></span>
<span id="cb19-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ modelspecs     :function (from_prior)  </span></span>
<span id="cb19-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ init           :function ()  </span></span>
<span id="cb19-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ datanames      : chr [1:3] "nObs" "y" "x"</span></span>
<span id="cb19-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ datanames_prior: chr(0) </span></span>
<span id="cb19-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ sample         : chr [1:2] "alpha0" "alpha1"</span></span></code></pre></div></div>
</div>
<p>Here we see in the slots <code>mean</code>, <code>cov</code> the parameters that have been determined. At this point a slight warning: you cannot directly change these parameters in the slots of the existing model object, because the parameters have also been saved invisibly in other places in the model object. Therefore, always use the class initialization function to create a new model object, if new parameters are required. But if we want to further use the approximation model, we can save it under a shorter name, e.g.:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1">myModel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> minInfModel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>model</span></code></pre></div></div>
</div>
</section>
</section>
<section id="obtaining-the-posterior" class="level1">
<h1>Obtaining the posterior</h1>
<p>As said before, models inheriting from the <code>GeneralModel</code> class rely on MCMC sampling for obtaining the posterior distribution of the model parameters, given the data. Most of the models, except the <code>EffFlexi</code> class model (please refer to Dual-endpoint dose escalation designs for details), inheriting from the <code>ModelPseudo</code> class do not necessarily require MCMC sampling to obtain posterior estimates. When no MCMC sampling is involved, the prior or posterior modal estimates of model estimates are used. But we can still obtain the full posterior distribution of the model parameters via MCMC for any models specified under <code>ModelPseudo</code> class. The MCMC sampling can be controlled with an object of class <code>mcmcOptions</code>, created for example as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1">options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb21-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb21-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb21-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span></span>
<span id="cb21-5">)</span></code></pre></div></div>
</div>
<p>Now the object <code>options</code> specifies that you would like to have <code>2000</code> parameter samples obtained from a Markov chain that starts with a <code>burn-in</code> phase of <code>100</code> iterations that are discarded, and then save a sample every <code>2</code> iterations. Note that these numbers are too low for actual production use and are only used for illustrating purposes here; normally you would specify at least the default parameters of the initialization function <code>mcmcOptions</code>: <code>10000</code> burn-in iterations and <code>10000</code> samples saved every 2<sup>nd</sup> iteration. You can look these up in help browser under the link <code>McmcOptions</code>.</p>
<p>After having set up the options, you can proceed to MCMC sampling by calling the <code>mcmc</code> function:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">94</span>)</span>
<span id="cb22-2">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(data, model, options)</span></code></pre></div></div>
</div>
<p>The <code>mcmc</code> function takes the data object, the model and the MCMC options. By default, JAGS is used for obtaining the samples. Use the option <code>verbose = TRUE</code> to show a progress bar and detailed JAGS messages.</p>
<p>Finally, it is good practice to check graphically that the Markov chain has really converged to the posterior distribution. To this end, <code>crmPack</code> provides an interface to the convenient <code>R</code>-package <code>ggmcmc</code>. With the function <code>get</code> you can extract the individual parameters from the object of class <code>Samples</code>.</p>
<p>For example, we extract the <img src="https://latex.codecogs.com/png.latex?%5Calpha_%7B0%7D"> samples: (please have a look at the help page for the <code>LogisticLogNormal</code> model class for the interpretation of the parameters)</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## look at the structure of the samples object:</span></span>
<span id="cb23-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples)</span>
<span id="cb23-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Formal class 'Samples' [package "crmPack"] with 2 slots</span></span>
<span id="cb23-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ data   :List of 2</span></span>
<span id="cb23-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..$ alpha0: num [1:2000] 0.723 0.723 0.945 -1.262 -1.262 ...</span></span>
<span id="cb23-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..$ alpha1: num [1:2000] 1.54 1.54 1.66 1.17 1.17 ...</span></span>
<span id="cb23-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ options:Formal class 'McmcOptions' [package "crmPack"] with 5 slots</span></span>
<span id="cb23-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ iterations: int 4100</span></span>
<span id="cb23-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ burnin    : int 100</span></span>
<span id="cb23-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ step      : int 2</span></span>
<span id="cb23-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ rng_kind  : chr NA</span></span>
<span id="cb23-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ rng_seed  : int NA</span></span>
<span id="cb23-13"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## now extract the alpha0 samples (intercept of the regression model)</span></span>
<span id="cb23-14">alpha0samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get</span>(samples, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"alpha0"</span>)</span></code></pre></div></div>
</div>
<p><code>alpha0samples</code> now contains the <img src="https://latex.codecogs.com/png.latex?%5Calpha_%7B0%7D"> samples in a format understood by <code>ggmcmc</code> and we can produce plots with it, e.g.&nbsp;a trace plot and an autocorrelation plot:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggmcmc)</span>
<span id="cb24-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggs_traceplot</span>(alpha0samples))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/ggmcmc-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A trace plot for alpha0"></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggs_autocorrelation</span>(alpha0samples))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/ggmcmc2-1.png" class="img-fluid figure-img" style="width:100.0%" alt="An autocorrelation plot for alpha0"></p>
</figure>
</div>
</div>
</div>
<p>So here we see that we have some autocorrelation in the samples, and might consider using a higher thinning parameter in order to decrease it.</p>
<p>You can find other useful plotting functions in the package information:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">help</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">package =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ggmcmc"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">help_type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"html"</span>)</span></code></pre></div></div>
</div>
<p>Similarly, using models from <code>ModelPseudo</code> class, we can also obtain the prior and posterior samples of the model parameters via MCMC.</p>
<p>For example, using the DLTmodel, <code>data1</code>, the empty data set and options specified in earlier examples.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">DLTsamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> DLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> options)</span></code></pre></div></div>
</div>
<p>The prior samples of the model parameters are now saved in the variable <code>DLTsamples</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1">data3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb28-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">225</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>),</span>
<span id="cb28-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb28-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>),</span>
<span id="cb28-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>),</span>
<span id="cb28-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>)</span>
<span id="cb28-7">)</span>
<span id="cb28-8">DLTpostsamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data3, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> DLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> options)</span></code></pre></div></div>
</div>
<p>Similarly, <code>DLTpostsamples</code> now contains the posterior samples of the model parameters. %Since an output message as seen from the above example will be display after each MCMC sampling when some observed data are involved, the <code>suppressMessages</code> function is used from now and throughout this document to avoid showing all of these message in this document</p>
<p>This <code>mcmc</code> function also takes the data object, model and the MCMC options. This is not using JAGS but just R for the computations.</p>
<p>Under this <code>DLTmodel</code>, we will obtain samples of φ<sub>1</sub> and φ<sub>2</sub>. Using what has been described earlier in this section , we can also look at the structure using function <code>str</code>, extracting model parameters samples with <code>get</code> and produce plots with <code>ggs_traceplot</code> and <code>ggs_autocorrelation</code> for each of the model parameters.</p>
<p>When no MCMC sampling is involved, the posterior modal estimates of the model parameters can be obtained for models (except the <code>EffFlexi</code> class object) inheriting from the <code>ModelPseudo</code> class object. First you need to put together all currently available observations in form of a <code>Data</code> object (when only DLT responses are modelled) or texttt{DataDual} object (when both DLT and efficacy responses are modelled) class object. Then using the <code>update</code> function to update your model, the posterior modal estimates of the model parameters will be display in the output of the model.</p>
<p>For example, we have some new observations specified in the data set <code>data3</code> and update the DLT model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">newDLTmodel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">object =</span> DLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data3)</span>
<span id="cb29-2">newDLTmodel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>phi1</span>
<span id="cb29-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] -5.070681</span></span>
<span id="cb29-4">newDLTmodel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>phi2</span>
<span id="cb29-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 1.125107</span></span></code></pre></div></div>
</div>
<p>In the example, the <code>update</code> function is used to obtain the posterior modal estimates of the model parameters, φ<sub>1</sub> and φ<sub>2</sub>, which can then be extracted using the operator on the updated result <code>newDLTmodel</code>.</p>
</section>
<section id="plotting-the-model-fit" class="level1">
<h1>Plotting the model fit</h1>
<p>After having obtained the parameter samples, we can plot the model fit, by supplying the samples, model and data to the generic plot function:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(samples, model, data))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plot-model-fit-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph with dose level on the x axis and the probability of DLT on the y axis.  The posterior mean probability of toxicity increases smoothly with dose.  The 95% credible interval is roughly symmetric about the mean."></p>
</figure>
</div>
</div>
</div>
<p>This plot shows the posterior mean curve and 95% equi-tailed credible intervals at each point of the dose grid from the <code>Data</code> object.</p>
<p>Note that you can also produce a plot of the prior mean curve and credible intervals, i.e.&nbsp;from the model without any data. This works in principle the same way as with data, just that we use an empty data object:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb31" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## provide only the dose grid:</span></span>
<span id="cb31-2">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid)</span>
<span id="cb31-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## obtain prior samples with this Data object</span></span>
<span id="cb31-4">priorsamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(emptydata, model, options)</span>
<span id="cb31-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## then produce the plot</span></span>
<span id="cb31-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(priorsamples, model, emptydata))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/empty-data-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph with dose level on the x axis and the probability of DLT on the y axis.  The prior mean probability of toxicity increases with dose, but is much less smooth than the posterior.  Similarly, The 95% credible interval is not symmetric about the mean."></p>
</figure>
</div>
</div>
</div>
<p>This <code>plot</code> function can also apply to the <code>DLTmodel</code> when samples of the parameters have been generated:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(DLTsamples, DLTmodel, data1))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plot-samplesdata1-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph similar to those above, but based on the DLTmodel object."></p>
</figure>
</div>
</div>
</div>
<p>In addition, we can also plot the fitted dose-response curve using the prior or the posterior modal estimates of the model parameters when no MCMC sampling is used. For example, we have the <code>DLTmodel</code> specified earlier under the <code>ModelTox</code> class with the data set <code>data1</code> we specified earlier:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb33" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb33-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(data1, DLTmodel))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/emptydatanoDLTsamples-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph with dose level on the x axis and the probability of DLT on the y axis.  The modal probability of toxicity increases with dose.  No credible interval is plotted."></p>
</figure>
</div>
</div>
</div>
<p>Since no samples are involved, only the curve using the prior or posterior modal estimates of the parameters are produced, without 95% credibility intervals.</p>
</section>
<section id="escalation-rules" class="level1">
<h1>Escalation Rules</h1>
<p>For the dose escalation, there are four kinds of rules:</p>
<ul>
<li><code>Increments</code>: For specifying maximum allowable increments between doses</li>
<li><code>NextBest</code>: How to derive the next best dose</li>
<li><code>CohortSize</code>: For specifying the cohort size</li>
<li><code>Stopping</code>: Stopping rules for finishing the dose escalation</li>
</ul>
<p>We have listed here the classes of these rules, and there are multiple subclasses for each of them, which you can find as links in the help pages <code>Increments-class</code>, <code>NextBest-class</code>, <code>CohortSize-class</code> and <code>Stopping-class</code>.</p>
<section id="increments-rules" class="level2">
<h2 class="anchored" data-anchor-id="increments-rules">Increments rules</h2>
<p>Figure @ref(fig:increments) shows the structure of the <code>Increments</code> classes:</p>
<div class="cell">
<div class="cell-output-display">
<div class="grViz html-widget html-fill-item" id="htmlwidget-79dbd8c5b35669423797" style="width:100%;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-79dbd8c5b35669423797">{"x":{"diagram":"digraph {\n\n\n\n\n  \"1\" [label = \"Increments\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"2\" [label = \"IncrementsRelative\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"3\" [label = \"IncrementsRelativeParts\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"4\" [label = \"IncrementsRelativeDLT\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"1\"->\"2\" \n  \"1\"->\"4\" \n  \"2\"->\"3\" \n}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
<p>Increments classes structure</p>
</div>
</div>
<p>The <code>Increments</code> class is the basis for all maximum increments rule classes within this package. There are three subclasses, the <code>IncrementsRelative</code>, the <code>IncrementsRelativeParts</code> and the <code>IncrementsRelativeDLTs</code> classes. Let us start with looking in detail at the increments rules. Currently two specific rules are implemented: Maximum relative increments based on the current dose (<code>IncrementsRelative</code> and <code>IncrementsRelativeParts</code>, which only works with <code>DataParts</code> objects), and maximum relative increments based on the current cumulative number of DLTs that have happened (<code>IncrementsRelativeDLT</code>).</p>
<p>For example, in order to specify a maximum increase of 100% for doses up to 20 mg, and a maximum of 33% for doses above 20 mg, we can setup the following increments rule:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1">myIncrements <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelative</span>(</span>
<span id="cb34-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>),</span>
<span id="cb34-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.33</span>)</span>
<span id="cb34-4">)</span></code></pre></div></div>
</div>
<p>Here the <code>intervals</code> slot specifies the left bounds of the intervals, in which the maximum relative <code>Increments</code> (note: decimal values here, no percentages!) are valid.</p>
<p>The increments rule is used by the <code>maxDose</code> function to obtain the maximum allowable dose given the current data:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb35" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1">nextMaxDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(myIncrements,</span>
<span id="cb35-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data</span>
<span id="cb35-3">)</span>
<span id="cb35-4">nextMaxDose</span>
<span id="cb35-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 20</span></span></code></pre></div></div>
</div>
<p>So in this case, the next dose could not be larger than 20 mg.</p>
<p>In the following example the dose escalation will be restricted to a 3-fold (= 200%) increase:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">myIncrements1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelative</span>(</span>
<span id="cb36-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>),</span>
<span id="cb36-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb36-4">)</span></code></pre></div></div>
</div>
<p>From all doses (since the dose grid starts at 25 mg) there is a maximum increase of 200% here.</p>
<p>The <code>IncrementsRelativeDLT</code> class works similarly, taking the number of DLTs in the whole trial so far as the basis for the maximum increments instead of the last dose.</p>
</section>
<section id="rules-for-next-best-dose-recommendation" class="level2">
<h2 class="anchored" data-anchor-id="rules-for-next-best-dose-recommendation">Rules for next best dose recommendation</h2>
<p>Figure @ref(fig:rules) show the structure of the next best dose recommendation rules currently implemented in <code>crmPack</code>.</p>
<div class="cell">
<div class="cell-output-display">
<div class="grViz html-widget html-fill-item" id="htmlwidget-c38dcf8fbece9b9e77e6" style="width:100%;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-c38dcf8fbece9b9e77e6">{"x":{"diagram":"digraph {\n\n\n\n\n  \"1\" [label = \"NextBest\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"2\" [label = \"NextBestMTD\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"3\" [label = \"NextBestNCRM\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"4\" [label = \"NextBestThreePlusThree\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"5\" [label = \"NextBestDualEndpoint\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"6\" [label = \"NextBestTD\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"7\" [label = \"NextBestTDSamples\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"8\" [label = \"NextBestMaxGain\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"9\" [label = \"NextBestMaxGainSamples\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"1\"->\"2\" \n  \"1\"->\"3\" \n  \"1\"->\"4\" \n  \"1\"->\"5\" \n  \"1\"->\"6\" \n  \"1\"->\"7\" \n  \"1\"->\"8\" \n  \"1\"->\"9\" \n}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
<p>Escalation classes structure</p>
</div>
</div>
<p>All classes of escalation rules are contained in the <code>nextBest</code> class. There are two main types of escalation rules: either only the binary DLT responses are incorporated into the escalation process, or a binary DLT and a continuous efficacy/biomarker response are jointly incorporated into the escalation process.</p>
<p>There are two implemented rules for toxicity endpoint CRMs inheriting from the <code>GeneralModel</code> class: <code>NextBestMTD</code> that uses the posterior distribution of the MTD estimate (given a target toxicity probability defining the MTD), and <code>nextBestCRM</code> that implements the N-CRM, using posterior probabilities of target-dosing and overdosing at the dose grid points to recommend a next best dose.</p>
<p>For example, in order to use the N-CRM with a target toxicity interval from 20% to 35%, and a maximum overdosing probability of 25%, we specify:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb37" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1">myNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestNCRM</span>(</span>
<span id="cb37-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>),</span>
<span id="cb37-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overdose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb37-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_overdose_prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span></span>
<span id="cb37-5">)</span></code></pre></div></div>
</div>
<p>Alternatively, we could use an MTD driven recommendation rule. For example, with a target toxicity rate of 33%, and recommending the 25% posterior quantile of the MTD, we specify</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb38" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb38-1">mtdNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestMTD</span>(</span>
<span id="cb38-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.33</span>,</span>
<span id="cb38-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">derive =</span></span>
<span id="cb38-4">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(mtd_samples) {</span>
<span id="cb38-5">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">quantile</span>(mtd_samples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">probs =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>)</span>
<span id="cb38-6">    }</span>
<span id="cb38-7">)</span></code></pre></div></div>
</div>
<p>Note that the <code>NextBestMTD</code> class is quite flexible, because you can specify a function <code>derive</code> that derives the next best dose from the posterior MTD samples.</p>
<p>There are also two further next best dose recommendation rules when the model is inheriting from the <code>ModelTox</code> class. One rule is specified when no samples for the model parameters are involved and the other one is when samples of the model parameters are generated and are incorporated into the dose-escalation procedure.</p>
<p>The details about these rules are as follows. First, two probabilities of the occurrence of a DLT have to be fixed. The first one is called <code>targetDuringTrial</code> which is the target probability of the occurrence of a DLT to be used during the trial. The second probability is called <code>targetEndOfTrial</code> is the target probability of the occurrence of a DLT to be used at the end of a trial. The above two targets always have to be specified. For cases when samples are involved, an additional argument has to be used, which is a function to advise what we should recommend using the samples that we have. This will be elaborated in details in the example below.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb39" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb39-1">TDNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestTD</span>(</span>
<span id="cb39-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target_drt =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>,</span>
<span id="cb39-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target_eot =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span></span>
<span id="cb39-4">)</span></code></pre></div></div>
</div>
<p>In this example, we fixed the target probability of the occurrence of a DLT to be used during the trial be 0.35. This means we will allow subjects to dose levels with probability of DLT closest and less than or equal 0.35 during the trial. At the end of the trial, we will therefore recommend a dose level which is closest and with probability of DLT less than or equal to 0.3. This <code>NextBestTD</code> rule class can be only used when no samples are involved in the escalation procedure. Next we will show an example of the <code>NextBestTDsamples</code> rule class when samples are involved in the escalation process.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1">TDsamplesNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestTDsamples</span>(</span>
<span id="cb40-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target_drt =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>,</span>
<span id="cb40-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target_eot =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,</span>
<span id="cb40-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">derive =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(samples) {</span>
<span id="cb40-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">quantile</span>(samples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">probs =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>))</span>
<span id="cb40-6">  }</span>
<span id="cb40-7">)</span></code></pre></div></div>
</div>
<p>The slot for <code>targetDuringTrial</code> and <code>targetEndOfTrial</code> are specified in the same way as in the last example given the value of 0.35 and 0.3, respectively. The <code>derive</code> slot should always be specified with a function. In this example, using the function specified in the <code>derive</code> slot says that we will recommend the 30% posterior quantiles of the samples to be the estimates for the doses corresponding to the <code>targetDuringTrial</code> and <code>targetEndOfTrial</code> doses.</p>
<p>During the study, in order to derive the next best dose, we supply the generic <code>nextBest</code> function with the rule, the maximum dose, the posterior samples, the model and the data:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb41" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb41-1">doseRecommendation <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(myNextBest,</span>
<span id="cb41-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> nextMaxDose,</span>
<span id="cb41-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> samples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data</span>
<span id="cb41-4">)</span></code></pre></div></div>
</div>
<p>The result is a list with two elements: <code>value</code> contains the numeric value of the recommended next best dose, and <code>plot</code> contains a plot that illustrates how the next best dose was computed. In this case we used the N-CRM rule, therefore the plot gives the target-dosing and overdosing probabilities together with the safety bar of 25%, the maximum dose and the final recommendation (the red triangle):</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb42" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1">doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb42-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 20</span></span>
<span id="cb42-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plot)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/next-best-results-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two graphs, one above the other.  Both have dose on the x axis.  In the upper plot, green vertical bars indicate the probability that each dose is in the target toxicity range.  In the lower, vertical red bars indicate the probability that each dose is in the overdose range.  On the lower graph, a horizontal black dashed line at 25% indicates that all doses above 20 have an unacceptable risk of toxicity.  On the upper graph, a red arrow pointing at 20 indicates that it is the dose with the highest probability of being in the target toxicity range whilst at the same time not being unacceptably toxic."></p>
</figure>
</div>
</div>
</div>
<p>Similarly, we can use the the generic <code>nextBest</code> function for the<code>NextBestTD</code> and <code>NextBestTDsamples</code> rules. In the example below we will use the data set <code>data3</code> with DLT observations. We can compute the next best dose to be given to the next cohort using the posterior modal estimates of the DLT model (i.e., no MCMC sampling involved here):</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb43" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1">doseRecDLT <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(TDNextBest, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> newDLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data3)</span></code></pre></div></div>
</div>
<p>A list of numerical values and a plot showing how the next best dose was computed will be given. This list of results will provide the numerical values for the next dose level, <code>next_dose_drt</code>; the target probability of DLT used during the trial, <code>prob_target_drt</code>; the estimated dose level for which its probability of DLT equals the target probability used during the trial, <code>dose_target_drt</code>; the target probability of DLT used at the end of a trial, <code>prob_target_eot</code>; the estimated dose level for which its probability of DLT equals the target probability of DLT used at the end of a trial <code>dose_target_eot</code>; and the dose level at dose grid closest and less than the <code>dose_target_eot</code>, <code>next_dose_eot</code>. We can use the <code>$</code> operator to obtain these values and the plot from the list. For example,</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb44" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1">doseRecDLT<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>next_dose_drt</span>
<span id="cb44-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 50</span></span>
<span id="cb44-3">doseRecDLT<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>prob_target_drt</span>
<span id="cb44-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 0.35</span></span>
<span id="cb44-5">doseRecDLT<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dose_target_drt</span>
<span id="cb44-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 52.28128</span></span>
<span id="cb44-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(doseRecDLT<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plot)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/next-bestTD-results-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph describing the results of applying TDNextBest rule to the data3 dataset and newDLTmodel model.  A red line indicates the posterior modal estimate of toxicity.  Vertical porle and dark red lines indicate the recommended dose for the next cohort (labelled Next) and the maximum dose permitted by the increments rule.  The maximum dose is 300, the recommended dose, 50.  A puple square and an orange triangle indicate the TD30 and TD35 estimates, both of which are close to 50."></p>
</figure>
</div>
</div>
</div>
<p>We can see that the next dose suggested to be given to the next cohort of subjects is 50 mg. The target probability of DLT during the trial is 0.35 and the TD35 (the tolerated dose with probability of DLT equal to 0.35) is estimated to be 52.28 mg. As we are using 12 dose levels or dose grids from 25 mg to 300 mg with increments of 25 mg for this data set, <code>data3</code>, we can see that what is suggested for the next dose 50 mg is also the dose level closest below 52.28 mg, the estimated <code>dose_target_drt</code>. Similarly, at the end of a trial we could also obtain all “End Of Trial” estimates by using the <code>$</code> operator. In addition, we also have a plot to show next dose allocation. The red curve shows the estimated DLT curve obtained using the posterior modal estimates of the model parameters. We also assumed the maximum allowable dose be 300 mg which was specified as the <code>doselimit</code> parameter of the <code>nextBest</code> function call and the red vertical line denoted with “Max” shows the maximum dose level (at x-axis) that is allowed in this case. The vertical purple line denoted with “Next” marks the dose level to be allocated to the next cohort of subjects. In this example, the target probability of DLT used during trial and at the end of a trial were 0.35 and 0.3, respectively. The circle and the square on the DLT curve show where the probability of DLT is estimated to be equal to 0.3 and 0.35, respectively. Hence, the value of the estimated TD30 and TD35 can be checked at the x-axis vertically below these symbols.</p>
<p>When MCMC sampling is involved, we will use the samples of model parameters to choose the next best dose. For example, in the following code chunk we use the data set, <code>data3</code>, with some DLT observations and the posterior samples of the model parameters, <code>DLTpostsamples</code> to compute the next best dose:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb45" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb45-1">doseRecDLTSamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(TDsamplesNextBest,</span>
<span id="cb45-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>,</span>
<span id="cb45-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> DLTpostsamples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> newDLTmodel,</span>
<span id="cb45-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data3</span>
<span id="cb45-5">)</span></code></pre></div></div>
</div>
<p>The same list of results will be produced as in the example before: The values of the <code>next_dose_drt</code>, <code>prob_target_drt</code>, <code>dose_target_drt</code>, <code>prob_target_eot</code>, <code>dose_target_eot</code> and <code>next_dose_eot</code> can be obtained using the <code>$</code> operator. The only difference is that the plot in this example will look slightly different than in the previous example:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb46" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb46-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(doseRecDLTSamples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plot)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/next-bestTDsamples-results-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A denisty plot showing the PDFs for the TD35 and TD30 against dose.  Both are highly skewed to the left. Vertical blue and red lines indicate the recommended dose for the next cohort and the maximum dose permitted by the increments rule. The recommended dose is 50 and the maximum dose 300."></p>
</figure>
</div>
</div>
</div>
<blockquote class="blockquote">
<p>This graph is incorrect</p>
</blockquote>
<p>In the plot, vertical lines are given to show the value for the next dose, the TD30 estimate, the TD35 estimate and the maximum allowable dose level. Since samples of model parameters were utilized, the density curves of the TD30 (pink) and the TD35 (grey) are plotted.</p>
</section>
<section id="cohort-size-rules" class="level2">
<h2 class="anchored" data-anchor-id="cohort-size-rules">Cohort size rules</h2>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb47" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb47-1">df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb47-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pathString =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb47-3">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CohortSize/CohortSizeRange"</span>,</span>
<span id="cb47-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CohortSize/CohortSizeDLT"</span>,</span>
<span id="cb47-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CohortSize/CohortSizeConst"</span>,</span>
<span id="cb47-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CohortSize/CohortSizeParts"</span>,</span>
<span id="cb47-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CohortSize/CohortSizeMax"</span>,</span>
<span id="cb47-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CohortSize/CohortSizeMin"</span></span>
<span id="cb47-9">  )</span>
<span id="cb47-10">)</span>
<span id="cb47-11"></span>
<span id="cb47-12">tree <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.Node</span>(df)</span>
<span id="cb47-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">SetNodeStyle</span>(tree, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"box"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fig.alt =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A dendrogram showing the inheritance stricture of the CohortSize classes.  CohortSie is the parent class.  All other classes are children of CohortSize."</span>)</span>
<span id="cb47-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(tree)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="grViz html-widget html-fill-item" id="htmlwidget-6798b201a6a91a0b30b3" style="width:100%;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-6798b201a6a91a0b30b3">{"x":{"diagram":"digraph {\n\n\n\n\n  \"1\" [label = \"CohortSize\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"2\" [label = \"CohortSizeRange\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"3\" [label = \"CohortSizeDLT\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"4\" [label = \"CohortSizeConst\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"5\" [label = \"CohortSizeParts\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"6\" [label = \"CohortSizeMax\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"7\" [label = \"CohortSizeMin\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"1\"->\"2\" \n  \"1\"->\"3\" \n  \"1\"->\"4\" \n  \"1\"->\"5\" \n  \"1\"->\"6\" \n  \"1\"->\"7\" \n}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
<p>CohortSize classes structure</p>
</div>
</div>
<p>% All classes related to cohort size in this package are contains within <code>CohortSize</code> class.</p>
<p>Similarly to the increments rules, you can define intervals in the dose space and/or the DLT space to define the size of the cohorts. For example, let’s assume we want to have one patient only in the cohorts until we reach 30 mg or the first DLT is encountered, and then proceed with three patients per cohort.</p>
<p>We start by creating the two separate rules, first for the dose range:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb48" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb48-1">mySize1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeRange</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span></code></pre></div></div>
</div>
<p>Then for the DLT range:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb49" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb49-1">mySize2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeDLT</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span></code></pre></div></div>
</div>
<p>Finally we combine the two rules by taking the maximum number of patients of both rules:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb50" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb50-1">mySize <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxSize</span>(mySize1, mySize2)</span></code></pre></div></div>
</div>
<p>The <code>CohortSize</code> rule is used by the size}` function, together with the next dose and the current data, in order to determine the size of the next cohort:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb51" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb51-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">size</span>(mySize,</span>
<span id="cb51-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value,</span>
<span id="cb51-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data</span>
<span id="cb51-4">)</span>
<span id="cb51-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 3</span></span></code></pre></div></div>
</div>
<p>Here, because we have one DLT already, we would go for 3 patients for the next cohort.</p>
<p>Moreover, if you would like to have a constant cohort size, you can use the following <code>CohortSizeConst</code> class, which we will use (with three patients) for simplicity for the remainder of this vignette:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb52" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb52-1">mySize <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div></div>
</div>
</section>
<section id="stopping-rules" class="level2">
<h2 class="anchored" data-anchor-id="stopping-rules">Stopping rules</h2>
<p>All of the stopping rules classes inherit directly from the <code>Stopping</code> class. There are in total 9 stopping rules, listed as follows:</p>
<ul>
<li><code>StoppingCohortNearDose</code></li>
<li><code>StoppingPatientsNearDose</code></li>
<li><code>StoppingMinCohorts</code></li>
<li><code>StoppingMinPatients</code></li>
<li><code>StoppingTargetProb</code></li>
<li><code>StoppingMTDdistribution</code></li>
<li><code>StoppingTargetBiomarker</code></li>
<li><code>StoppingTDCIRatio</code></li>
<li><code>StoppingMaxGainCIRatio</code></li>
</ul>
<p>From the names of these stopping rules, we can have an idea of what criteria have been used for stopping decisions and we will explain briefly here what are these criteria. For further details please refer to examples presented later in this vignette or examples given in the help pages. You can find a link to all implemented stopping rule parts in the help page <code>Stopping-class</code>.</p>
<p>For example, <code>StoppingCohortNearDose</code> class objects can be used to stop the dose escalation based on the numbers of cohorts treated near to the next best dose (where the required proximity is given as the percentage of relative deviation from the next best dose). Similarly, for <code>StoppingPatientsNearDose</code>, stopping is based on the number of patients treated near the next best dose. <code>StoppingMinCohorts</code> and <code>StoppingMinPatients</code> rules can be used to stop the dose escalation if a minimum overall number of patients or cohorts have been enrolled. We have also other stopping rules such that a trial will be stopped either based on the MTD distribution (<code>StoppingMTDdistribution</code>), or reached a pre-specified probability of the next dose being in the target toxicity interval (<code>StoppingTargetProb</code>) or target biomarker interval (<code>StoppingTargetBiomarker</code>) or when the current estimate of the quantity of interest is ‘accurate’ enough (<code>StoppingTDCIRatio</code> and <code>StoppingMaxGainCIRatio</code>)</p>
<p>Stopping rules are often quite complex, because they are built from “and/or” combinations of multiple parts. Therefore the <code>crmPack</code> implementation mirrors this, and multiple atomic stopping rules can be combined easily. For example, let’s assume we would like to stop the trial if there are at least 3 cohorts and at least 50% probability in the target toxicity interval <img src="https://latex.codecogs.com/png.latex?(20%25,%2035%25)">, or the maximum sample size of 20 patients has been reached.</p>
<p>Then we start by creating the three pieces the rule is composed of:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb53" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb53-1">myStopping1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinCohorts</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nCohorts =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb53-2">myStopping2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingTargetProb</span>(</span>
<span id="cb53-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>),</span>
<span id="cb53-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span></span>
<span id="cb53-5">)</span>
<span id="cb53-6">myStopping3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinPatients</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>)</span></code></pre></div></div>
</div>
<p>Finally we combine these with the <code>and</code> operator <code>&amp;</code> and the <code>or</code> operator <code>|</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb54" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb54-1">myStopping <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (myStopping1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> myStopping2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> myStopping3</span></code></pre></div></div>
</div>
<p>We can also stop the trial when the current estimate of the quantity of interest, such as the TD30 given in earlier examples, is ‘accurate’ enough. The accuracy of the current estimate of TD30 is quantified by the width of the associated 95% credibility interval. The wider the interval, the less accurate the estimate is. In particular, the ratio of the upper to the lower limit of this 95% credibility interval is used. The smaller the ratio, the more accurate is the estimate.</p>
<p>For example, we will stop our trial if we obtain a ratio of less than 5 for the 95% credibility interval of the TD30 estimate in this case, deciding that we have obtained an estimate which is ‘accurate’ enough.</p>
<p>The <code>StoppingTDCIRatio</code> function can be used in both cases when no DLT samples or DLT samples are involved:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb55" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb55-1">myStopping4 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingTDCIRatio</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target_ratio =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)</span></code></pre></div></div>
</div>
<blockquote class="blockquote">
<p>In the above two examples, the <code>targetRatio</code> and <code>targetEndOfTrial</code> has to be specified.</p>
</blockquote>
<p>During the dose escalation study, any (atomic or combined) stopping rule can be used by the function <code>stopTrial</code> to determine if the rule has already been fulfilled. For example in our case:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb56" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb56-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb56-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value,</span>
<span id="cb56-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> samples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data</span>
<span id="cb56-4">)</span>
<span id="cb56-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb56-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb56-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]]</span></span>
<span id="cb56-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]][[1]]</span></span>
<span id="cb56-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 6 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb56-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb56-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]][[2]]</span></span>
<span id="cb56-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 33 % for dose 20 and thus below the required 50 %"</span></span>
<span id="cb56-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb56-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb56-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]]</span></span>
<span id="cb56-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 8 and thus below the prespecified minimum number 20"</span></span>
<span id="cb56-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb56-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")</span></span>
<span id="cb56-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[1]]</span></span>
<span id="cb56-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb56-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb56-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]]</span></span>
<span id="cb56-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 6 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb56-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb56-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]]</span></span>
<span id="cb56-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 33 % for dose 20 and thus below the required 50 %"</span></span>
<span id="cb56-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb56-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")</span></span>
<span id="cb56-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[1]]</span></span>
<span id="cb56-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span>
<span id="cb56-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb56-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 6 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb56-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb56-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "≥ 3 cohorts dosed"</span></span>
<span id="cb56-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb56-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[2]]</span></span>
<span id="cb56-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb56-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb56-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 33 % for dose 20 and thus below the required 50 %"</span></span>
<span id="cb56-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb56-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5"</span></span>
<span id="cb56-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb56-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb56-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] NA</span></span>
<span id="cb56-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb56-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[2]]</span></span>
<span id="cb56-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb56-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb56-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 8 and thus below the prespecified minimum number 20"</span></span>
<span id="cb56-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb56-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "≥ 20 patients dosed"</span></span>
<span id="cb56-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb56-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb56-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] NA</span></span></code></pre></div></div>
</div>
<p>We receive here <code>FALSE</code>, which means that the stopping rule criteria have not been met. The attribute <code>message</code> contains the textual results of the atomic parts of the stopping rule. Here we can read that the probability for target toxicity was just 30% for the recommended dose 20 mg and therefore too low, and also the maximum sample size has not been reached, therefore the trial shall continue.</p>
<p>In the same way the stopping rule <code>myStopping4</code> (no samples and with samples) can be evaluated:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb57" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb57-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb57-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping4, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecDLTSamples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>next_dose_drt,</span>
<span id="cb57-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> DLTpostsamples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> newDLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data3</span>
<span id="cb57-4">)</span>
<span id="cb57-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb57-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb57-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "95% CI is (0.000611274483578011, 10459.1345133637), Ratio = 17110373.1537 is greater than target_ratio = 5"</span></span>
<span id="cb57-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb57-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "TD 5 for 0.3 target prob"</span></span>
<span id="cb57-10"></span>
<span id="cb57-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb57-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping4, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecDLT<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>next_dose_drt,</span>
<span id="cb57-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> newDLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data3</span>
<span id="cb57-14">)</span>
<span id="cb57-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb57-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb57-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "95% CI is ( 11.0662 , 164.618 ), Ratio = 14.8758 is  greater than target_ratio = 5"</span></span>
<span id="cb57-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb57-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "TD 5 for 0.3 target prob"</span></span></code></pre></div></div>
</div>
<p>when DLT samples or no DLT samples are involved.</p>
<blockquote class="blockquote">
<p>Note that at the moment the <code>and</code> operator <code>&amp;</code> and the <code>or</code> operator <code>|</code> cannot be used together with <code>StoppingTDCIRatio</code> class objects. This is still under development.</p>
</blockquote>
</section>
</section>
<section id="simulations" class="level1">
<h1>Simulations</h1>
<p>In order to run simulations, we first have to build a specific design, that comprises a model, the escalation rules, starting data, a cohort size and a starting dose.</p>
<p>The structure of the design classes in this package is shown in figure @ref(fig:Design).</p>
<div class="cell">
<div class="cell-output-display">
<div class="grViz html-widget html-fill-item" id="htmlwidget-1fd356c559ab70fa3048" style="width:100%;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-1fd356c559ab70fa3048">{"x":{"diagram":"digraph {\n\n\n\n\n  \"1\" [label = \"RuleDesign\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"2\" [label = \"Design\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"3\" [label = \"DualDesign\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"4\" [label = \"TDDesign\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"5\" [label = \"DualResponsesDesign\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"6\" [label = \"TDSamplesDesign\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"7\" [label = \"DualResponsesTDSamplesDesign\", shape = \"box\", fillcolor = \"#FFFFFF\", fontcolor = \"#000000\"] \n  \"1\"->\"2\" \n  \"1\"->\"4\" \n  \"1\"->\"6\" \n  \"2\"->\"3\" \n  \"4\"->\"5\" \n  \"6\"->\"7\" \n}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
<p>Design classes structure</p>
</div>
</div>
<p>It might seem strange at first sight that we have to supply starting data to the design, but we will show below that this makes sense. First, we use our <code>emptydata</code> object that only contains the dose grid, and a cohorts of 3 patients, starting from 0.1 mg:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb58" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb58-1">design <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Design</span>(</span>
<span id="cb58-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb58-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> myNextBest,</span>
<span id="cb58-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping,</span>
<span id="cb58-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements,</span>
<span id="cb58-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize,</span>
<span id="cb58-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> emptydata,</span>
<span id="cb58-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb58-9">)</span></code></pre></div></div>
</div>
<p>Another example will be given when the <code>TDDesign</code> class is used. The empty data set, <code>data1</code> will be used, and the starting dose will be 25 mg. The code below will be a design defined when no MCMC sampling is involved. The <code>nextBest</code> slot under this <code>TDDesign</code> class function has to be defined with the <code>TDNextBest</code> class object to ensure we will pick the next best dose using rules as defined when no MCMC sampling is involved. In addition, we define here with <code>myStopping4</code> that the trial will only stop when the ratio of the 95% credibility interval limits of the current estimate of TD30 (<code>TDtargetEndOfTrial</code>) is less than or equal to 5. In addition, we also use <code>myIncrements1</code>, <code>mySize</code> and <code>data1</code> defined in earlier examples for the <code>increments</code>, <code>cohort_size</code> and <code>data</code> slots in defining the <code>TDDesign</code> object:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb59" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb59-1">DLTdesign <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">TDDesign</span>(</span>
<span id="cb59-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> DLTmodel,</span>
<span id="cb59-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> TDNextBest,</span>
<span id="cb59-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping4,</span>
<span id="cb59-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements1,</span>
<span id="cb59-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize,</span>
<span id="cb59-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data1,</span>
<span id="cb59-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span></span>
<span id="cb59-9">)</span></code></pre></div></div>
</div>
<p>When MCMC samples are involved, we also have to specify a design to ensure our package will run the simulations using the MCMC samples of the model parameters for models specified under the <code>ModelPseudo</code> class object. In the example, the <code>TDsamplesDesign</code> class object has to be used with the <code>TDsamplesNextBest</code> class object in the <code>nextBest</code> slot to ensure MCMC sampling is involved for this design. We also apply the stopping rule <code>myStopping4</code> or <code>myStopping3</code> such that the trial will stop either when the ratio of the 95% credibility interval limits of the current estimate of TD30 (<code>TDtargetEndOfTrial</code>) is less than or equal to 5 (<code>myStopping4</code>) or when a maximum of 30 patients has been enrolled in the trial (<code>myStopping3</code>):</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb60" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb60-1">DLTsamplesDesign <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">TDsamplesDesign</span>(</span>
<span id="cb60-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> DLTmodel,</span>
<span id="cb60-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> TDsamplesNextBest,</span>
<span id="cb60-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> (myStopping4 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> myStopping3),</span>
<span id="cb60-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements1,</span>
<span id="cb60-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize,</span>
<span id="cb60-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data1,</span>
<span id="cb60-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span></span>
<span id="cb60-9">)</span></code></pre></div></div>
</div>
<section id="examining-single-trial-behavior" class="level2">
<h2 class="anchored" data-anchor-id="examining-single-trial-behavior">Examining single trial behavior</h2>
<p>Before looking at the “many trials” operating characteristics, it is important to look at the “single trial” operating characteristics of the dose escalation design. For this, <code>crmPack</code> provides the function <code>examine</code>, which generates a <code>data.frame</code> showing the beginning of several hypothetical trial courses under the design. Assuming no DLTs have been seen until a certain dose, then the consequences of different number of DLTs being observed at this dose are shown. In the current example we have</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb61" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb61-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">23</span>)</span>
<span id="cb61-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">examine</span>(design)</span>
<span id="cb61-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    dose DLTs nextDose  stop increment</span></span>
<span id="cb61-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1     3    0      6.0 FALSE       100</span></span>
<span id="cb61-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 2     3    1      3.0 FALSE         0</span></span>
<span id="cb61-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 3     3    2      0.1 FALSE       -97</span></span>
<span id="cb61-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 4     3    3       NA FALSE        NA</span></span>
<span id="cb61-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 5     6    0     12.0 FALSE       100</span></span>
<span id="cb61-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 6     6    1     12.0 FALSE       100</span></span>
<span id="cb61-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 7     6    2      3.0 FALSE       -50</span></span>
<span id="cb61-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 8     6    3      1.5 FALSE       -75</span></span>
<span id="cb61-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 9    12    0     24.0 FALSE       100</span></span>
<span id="cb61-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 10   12    1     24.0 FALSE       100</span></span>
<span id="cb61-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 11   12    2     14.0 FALSE        17</span></span>
<span id="cb61-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 12   12    3      6.0 FALSE       -50</span></span>
<span id="cb61-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 13   24    0     30.0 FALSE        25</span></span>
<span id="cb61-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 14   24    1     30.0 FALSE        25</span></span>
<span id="cb61-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 15   24    2     26.0 FALSE         8</span></span>
<span id="cb61-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 16   24    3     18.0 FALSE       -25</span></span>
<span id="cb61-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 17   30    0     38.0 FALSE        27</span></span>
<span id="cb61-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 18   30    1     38.0 FALSE        27</span></span>
<span id="cb61-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 19   30    2     32.0 FALSE         7</span></span>
<span id="cb61-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 20   30    3     26.0 FALSE       -13</span></span>
<span id="cb61-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 21   38    0     50.0 FALSE        32</span></span>
<span id="cb61-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 22   38    1     50.0 FALSE        32</span></span>
<span id="cb61-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 23   38    2     42.0 FALSE        11</span></span>
<span id="cb61-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 24   38    3     36.0 FALSE        -5</span></span>
<span id="cb61-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 25   50    0     58.0  TRUE        16</span></span>
<span id="cb61-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 26   50    1     54.0  TRUE         8</span></span>
<span id="cb61-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 27   50    2     50.0  TRUE         0</span></span>
<span id="cb61-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 28   50    3     44.0  TRUE       -12</span></span></code></pre></div></div>
</div>
<p>Note that it is important to set a seed, since minor changes might occur due to sampling variations. However, the <code>mcmcOptions</code> parameter should be chosen in order to minimize such variation. The default setting, used implicitly in the above call, should normally be sufficient, but checking this (by running the function twice with different seeds and comparing the results) is important.</p>
<p>The resulting data frame gives the dose of the cohort until which no DLTs are observed, the number of DLTs, the resulting next dose recommendation, whether the design would stop, and the relative increment of the next dose compared to the current dose in percentage. Note that cohort size rules are taken into account by <code>examine</code>. <code>NA</code> entries mean that the design would stop without a valid dose, since all doses are considered too toxic after observing the number of DLTs at that dose.</p>
</section>
<section id="simulating-from-a-true-scenario" class="level2">
<h2 class="anchored" data-anchor-id="simulating-from-a-true-scenario">Simulating from a true scenario</h2>
<p>For the “many trials” operating characteristics, we have to define a true scenario, from which the data should arise. In this case, this only requires a function that computes the probability of DLT given a dose. Here we use a specific case of the function contained in the model space:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb62" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb62-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## define the true function</span></span>
<span id="cb62-2">myTruth <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)</span>
<span id="cb62-3"></span>
<span id="cb62-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## plot it in the range of the dose grid</span></span>
<span id="cb62-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">curve</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruth</span>(x), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/true-def-1.png" class="img-fluid figure-img" style="width:100.0%" alt="The CDF defined by the myTruth function"></p>
</figure>
</div>
</div>
</div>
<p>In a similar way, we can also simulate trials based on a true DLT scenario using the <code>TDDesign</code> and the <code>TDsamplesDesign</code>.</p>
<p>First, we will specified the true DLT scenario such that</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb63" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb63-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## define the true function</span></span>
<span id="cb63-2">TrueDLT <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(DLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phi1 =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">53.66584</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phi2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">10.50499</span>)</span>
<span id="cb63-3"></span>
<span id="cb63-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## plot it in the range of the dose grid</span></span>
<span id="cb63-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">curve</span>(TrueDLT, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/trueDLT-1.png" class="img-fluid figure-img" style="width:100.0%" alt="The CDF defined by the TrueDLT function"></p>
</figure>
</div>
</div>
</div>
<p>This true DLT scenario will be used for both the <code>TDDesign</code> and the <code>TDsamplesDesign</code></p>
<p>Now we can proceed to the simulations. We only generate 100 trial outcomes here for illustration, for the actual study this should be increased of course to at least 500:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb64" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb64-1">time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">system.time</span>(mySims <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(design,</span>
<span id="cb64-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb64-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth,</span>
<span id="cb64-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb64-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>,</span>
<span id="cb64-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> options,</span>
<span id="cb64-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb64-8">))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]</span>
<span id="cb64-9">time</span>
<span id="cb64-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; elapsed </span></span>
<span id="cb64-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 157.088</span></span></code></pre></div></div>
</div>
<p>We have wrapped the call to <code>simulate</code> in a <code>system.time</code> to obtain the required time for the simulations (about 157 seconds in this case). The argument <code>args</code> could contain additional arguments for the <code>truth</code> function, which we did not require here and therefore let it at the default <code>NULL</code>. We specify the number of simulations with <code>nsim</code> and the random number generator seed with <code>seed</code>. Note that we also pass again the MCMC options object, because during the trial simulations the MCMC routines are used. Finally, the argument <code>parallel</code> can be used to enable the use of all processors of the computer for running the simulations in parallel. This can yield a meaningful speedup, especially for larger number of simulations.</p>
<p>As (almost) always, the result of this call is again an object with a class, in this case <code>Simulations</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb65" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb65-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">class</span>(mySims)</span>
<span id="cb65-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Simulations"</span></span>
<span id="cb65-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"package")</span></span>
<span id="cb65-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "crmPack"</span></span></code></pre></div></div>
</div>
<p>From the help page</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb66" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb66-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">help</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Simulations-class"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">help =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"html"</span>)</span></code></pre></div></div>
</div>
<p>we see that this class is a subclass of the <code>GeneralSimulations</code> class. By looking at the help pages for <code>Simulations</code> and the parent class <code>GeneralSimulations</code>, we can find the description of all slots of <code>mySims</code>. In particular, the <code>Data</code> slot contains the list of produced <code>Data</code> objects of the simulated trials. Therefore, we can plot the course of e.g.&nbsp;the third simulated trial as follows:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb67" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb67-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(mySims<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]]))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/third-trial-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph summarising dose allocations for the third trial in the simulation.  Patient number runs along the x axis, dose administered along the y axis.  Red triangle indicate patients who reported a DLT, black circles those who did not.  DLTs were reported by patients 10, 11, 12, 16 and 18, all at a dose of 24.  No other patients reported DLTs."></p>
</figure>
</div>
</div>
</div>
<p>The final dose for this trial was</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb68" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb68-1">mySims<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doses[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]</span>
<span id="cb68-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 22</span></span></code></pre></div></div>
</div>
<p>and the stopping reason was</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb69" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb69-1">mySims<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>stop_reasons[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]]</span>
<span id="cb69-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[1]]</span></span>
<span id="cb69-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[1]][[1]]</span></span>
<span id="cb69-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 7 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb69-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb69-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[1]][[2]]</span></span>
<span id="cb69-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 56 % for dose 22 and thus above the required 50 %"</span></span>
<span id="cb69-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb69-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb69-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[2]]</span></span>
<span id="cb69-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 21 and thus reached the prespecified minimum number 20"</span></span></code></pre></div></div>
</div>
<p>Furthermore, with this object, we can apply two methods. First, we can plot it, i.e.&nbsp;we can apply the plot method:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb70" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb70-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(mySims))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/sim-plot-1.png" class="img-fluid figure-img" style="width:100.0%" alt="two plots in a single column.  The first shows patient number on the x axis and dose administered on the y axis.  Lines in various styles indicate the minimum, maximum, median, lower quartile and upper quartile of the dose administered tat each patient number, calculated over all simulations.  The lower graph has dose on the x axis and proportion of patients treated at that dose on the y axis.  The proportuon of patients treated is avreaged over all simulations."></p>
</figure>
</div>
</div>
</div>
<p>The resulting plot shows on the top panel a summary of the trial trajectories. On the bottom, the proportions of doses tried, averaged over the simulated trials, are shown. Note that you can select the plots by changing the <code>type</code> argument of <code>plot</code>, which by default is <code>type =   c("trajectory", "dosesTried")</code>.</p>
<p>Second, we can summarize the simulation results. Here again we have to supply a true dose-toxicity function. We take the same (<code>myTruth</code>) as above:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb71" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb71-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(mySims,</span>
<span id="cb71-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth</span>
<span id="cb71-3">)</span>
<span id="cb71-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 100 simulations</span></span>
<span id="cb71-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb71-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target toxicity interval was 20, 35 %</span></span>
<span id="cb71-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target dose interval corresponding to this was 19.6, 21.6 </span></span>
<span id="cb71-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Intervals are corresponding to 10 and 90 % quantiles</span></span>
<span id="cb71-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb71-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 19 (18, 21) </span></span>
<span id="cb71-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above target tox interval : mean 7 (6, 9) </span></span>
<span id="cb71-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of DLTs in the trials : mean 26 % (22 %, 33 %) </span></span>
<span id="cb71-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients on active : mean 25 % (18 %, 36 %) </span></span>
<span id="cb71-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as MTD : mean 21.1 (18, 24.2) </span></span>
<span id="cb71-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at doses selected : mean 32 % (11 %, 57 %) </span></span>
<span id="cb71-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting target MTD: 16 %</span></span>
<span id="cb71-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as MTD: 18 </span></span>
<span id="cb71-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 11 %</span></span>
<span id="cb71-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted toxicity rate at dose most often selected : mean 24 % (19 %, 28 %) </span></span>
<span id="cb71-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb71-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 3 cohorts dosed :  100 %</span></span>
<span id="cb71-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5 :  99 %</span></span>
<span id="cb71-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 20 patients dosed :  44 %</span></span></code></pre></div></div>
</div>
<p>Note that sometimes the observed toxicity rate at the dose most often selected (here 20 mg) is not available, because it can happen that no patients were actually treated that dose during the simulations. (Here it is available.) This illustrates that the MTD can be selected based on the evidence from the data at other dose levels – which is an advantage of model-based dose-escalation designs.</p>
<p>Now we can also produce a plot of the summary results, which gives a bit more detail than the textual summary we have just seen:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb72" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb72-1">simSum <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(mySims,</span>
<span id="cb72-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth</span>
<span id="cb72-3">)</span>
<span id="cb72-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(simSum))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/sim-sum-plot-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A 2x2 panel of four plots.  A description of each panel element is provided in the paragraph below."></p>
</figure>
</div>
</div>
</div>
<p>The top left panel shows the distribution of the sample size across the simulated trials. In this case the trials had between 15 and 21 patients. The top right panel shows the distribution of the final MTD estimate / recommended dose across the simulated trials. The middle left panel shows the distribution across the simulations of the DLT proportions observed in the patients dosed. Here in most trials between 20 and 30% of the patients had DLTs. The middle right panel shows the distribution across simulations of the number of patients treated above the target toxicity window (here we used the default from 20% to 35%). Finally, in the bottom panel we see a comparison of the true dose-toxicity curve (black) with the estimated dose-toxicity curves, averaged (continuous red line) across the trials and with 95% credible interval across the trials. Here we see that the steep true dose-toxicity curve is not recovered by the model fit.</p>
<p>If we find that e.g.&nbsp;the top right plot with the distribution of the final selected doses is too small and shows not the right x-axis window, we can only plot this one and add x-axis customization on top: (see the <code>ggplot2</code> documentation for more information on customizing the plots)</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb73" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb73-1">dosePlot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(simSum, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"doseSelected"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb73-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">limits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>))</span>
<span id="cb73-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(dosePlot)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/sim-sum-plot2-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A fistogram showing the proportion of simulatd trials that identified each dose as the MTD.  All but one of the simulated trials identified a dose between 16 and 26 as the MTD."></p>
</figure>
</div>
</div>
</div>
<p>Some further examples will be given for simulations using the <code>TDDesign</code> and the <code>TDsamplesDesign</code> classes. For illustration purpose, we will generate only 10 trial outcomes.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb74" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb74-1">DLTSim <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(DLTdesign,</span>
<span id="cb74-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb74-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> TrueDLT,</span>
<span id="cb74-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb74-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>,</span>
<span id="cb74-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb74-7">)</span></code></pre></div></div>
</div>
<p>The above is an example when no MCMC sampling is involved and we have another example below for simulation when MCMC sampling is involved:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb75" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb75-1">DLTsampSim <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(DLTsamplesDesign,</span>
<span id="cb75-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb75-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> TrueDLT,</span>
<span id="cb75-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb75-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>,</span>
<span id="cb75-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> options,</span>
<span id="cb75-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb75-8">)</span></code></pre></div></div>
</div>
<p>The meaning of these arguments are the same as those defined and explained above in the <code>simulate</code> example for the <code>Design</code> class. % With slots <code>args</code> to specify any additional arguments for the <code>truth</code> function, <code>truth</code> for the real DLT scenario to simulate responses from, <code>nsim</code> for the number of simulations, <code>seed</code>, the random generator seed and <code>parallel</code> to specify whether parallel computing is to be used for running the simulations.</p>
<p>Similarly, the results of individual simulations can be obtained graphically using the <code>plot</code> function. The dose level for recommendation that is the dose levels closest below the final estimated TD30 (the final estimates of the dose level with probability of DLT equals to the target end of trial) was</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb76" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb76-1">DLTSim<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doses[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]</span>
<span id="cb76-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 100</span></span></code></pre></div></div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb77" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb77-1">DLTsampSim<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doses[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]</span>
<span id="cb77-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 100</span></span></code></pre></div></div>
</div>
<p>The overall results of the 100 trials for these two simulations can also be plotted as</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb78" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb78-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(DLTSim))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plotDLTSim-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two graphs in a single column describing the dose allocations in the DLTSim object."></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb79" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb79-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(DLTsampSim))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plotDLTsampSim-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two graphs in a single column describing the dose allocations in the DLTsampSim object."></p>
</figure>
</div>
</div>
</div>
<p>which show the trial trajectories and the proportion of doses level tried.</p>
<p>These simulation results can also be summarized using the <code>summary</code> function given the truth:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb80" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb80-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(DLTSim,</span>
<span id="cb80-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> TrueDLT</span>
<span id="cb80-3">)</span>
<span id="cb80-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 10 simulations</span></span>
<span id="cb80-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb80-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target probability of DLE p(DLE) used at the end of a trial was 30 %</span></span>
<span id="cb80-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The dose level corresponds to the target p(DLE) used at the end of a trial, TDEOT, was 152.6195 </span></span>
<span id="cb80-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; TDEOT at dose Grid was 150 </span></span>
<span id="cb80-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target p(DLE) used during a trial was 35 %</span></span>
<span id="cb80-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The dose level corresponds to the target p(DLE) used during a trial, TDDT, was 155.972 </span></span>
<span id="cb80-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; TDDT at dose Grid was 150 </span></span>
<span id="cb80-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 16 (15, 18) </span></span>
<span id="cb80-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above the target p(DLE) used at the end of a trial : mean 3 (3, 3) </span></span>
<span id="cb80-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above the target p(DLE) used during a trial : mean 3 (3, 3) </span></span>
<span id="cb80-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of observed DLT in the trials : mean 21 % (20 %, 22 %) </span></span>
<span id="cb80-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients : mean 20 % (17 %, 21 %) </span></span>
<span id="cb80-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as TDEOT : mean 100 (100, 100) </span></span>
<span id="cb80-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at TDEOT : mean 1 % (1 %, 1 %) </span></span>
<span id="cb80-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting the TDEOT: 0 %</span></span>
<span id="cb80-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting the TDDT: 0 %</span></span>
<span id="cb80-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as TDEOT: 100 </span></span>
<span id="cb80-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 6 %</span></span>
<span id="cb80-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted probabilities of DLE at dose most often selected : mean 24 % (24 %, 25 %) </span></span>
<span id="cb80-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final TDEOT across all simulations</span></span>
<span id="cb80-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb80-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    117.3   120.1   123.8   122.0   123.8   123.8  </span></span>
<span id="cb80-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the TDEOT across all simulations</span></span>
<span id="cb80-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb80-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    4.054   4.157   4.447   4.330   4.447   4.447  </span></span>
<span id="cb80-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final TDDT across all simulations</span></span>
<span id="cb80-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb80-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    137.5   140.7   144.4   142.5   144.4   144.4  </span></span>
<span id="cb80-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of dose levels, the optimal dose</span></span>
<span id="cb80-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  to recommend for subsequent study across all simulations</span></span>
<span id="cb80-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb80-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    117.3   120.1   123.8   122.0   123.8   123.8  </span></span>
<span id="cb80-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the optimal dose for stopping across</span></span>
<span id="cb80-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                   all simulations</span></span>
<span id="cb80-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb80-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    4.054   4.157   4.447   4.330   4.447   4.447  </span></span>
<span id="cb80-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb80-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb80-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  TD 5 for 0.3 target prob :  100 %</span></span></code></pre></div></div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb81" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb81-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(DLTsampSim,</span>
<span id="cb81-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> TrueDLT</span>
<span id="cb81-3">)</span>
<span id="cb81-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 10 simulations</span></span>
<span id="cb81-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb81-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target probability of DLE p(DLE) used at the end of a trial was 30 %</span></span>
<span id="cb81-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The dose level corresponds to the target p(DLE) used at the end of a trial, TDEOT, was 152.6195 </span></span>
<span id="cb81-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; TDEOT at dose Grid was 150 </span></span>
<span id="cb81-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target p(DLE) used during a trial was 35 %</span></span>
<span id="cb81-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The dose level corresponds to the target p(DLE) used during a trial, TDDT, was 155.972 </span></span>
<span id="cb81-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; TDDT at dose Grid was 150 </span></span>
<span id="cb81-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 21 (21, 21) </span></span>
<span id="cb81-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above the target p(DLE) used at the end of a trial : mean 1 (0, 3) </span></span>
<span id="cb81-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above the target p(DLE) used during a trial : mean 1 (0, 3) </span></span>
<span id="cb81-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of observed DLT in the trials : mean 10 % (5 %, 14 %) </span></span>
<span id="cb81-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients : mean 6 % (1 %, 10 %) </span></span>
<span id="cb81-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as TDEOT : mean 100 (75, 125) </span></span>
<span id="cb81-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at TDEOT : mean 2 % (0 %, 5 %) </span></span>
<span id="cb81-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting the TDEOT: 0 %</span></span>
<span id="cb81-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting the TDDT: 0 %</span></span>
<span id="cb81-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as TDEOT: 100 </span></span>
<span id="cb81-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 6 %</span></span>
<span id="cb81-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted probabilities of DLE at dose most often selected : mean 22 % (18 %, 26 %) </span></span>
<span id="cb81-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final TDEOT across all simulations</span></span>
<span id="cb81-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb81-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    97.28  100.35  115.37  114.40  125.23  135.76  </span></span>
<span id="cb81-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the TDEOT across all simulations</span></span>
<span id="cb81-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;       Min.   1st Qu.    Median      Mean   3rd Qu.      Max.  </span></span>
<span id="cb81-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  1.000e+01 6.800e+01 4.079e+06 5.241e+11 1.917e+11 3.806e+12  </span></span>
<span id="cb81-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final TDDT across all simulations</span></span>
<span id="cb81-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb81-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    118.8   122.2   144.9   143.3   161.5   170.3  </span></span>
<span id="cb81-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of dose levels, the optimal dose</span></span>
<span id="cb81-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  to recommend for subsequent study across all simulations</span></span>
<span id="cb81-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb81-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    97.28  100.35  115.37  114.40  125.23  135.76  </span></span>
<span id="cb81-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the optimal dose for stopping across</span></span>
<span id="cb81-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                   all simulations</span></span>
<span id="cb81-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;       Min.   1st Qu.    Median      Mean   3rd Qu.      Max.  </span></span>
<span id="cb81-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  1.000e+01 6.800e+01 4.079e+06 5.241e+11 1.917e+11 3.806e+12  </span></span>
<span id="cb81-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb81-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb81-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  TD 5 for 0.3 target prob :  0 %</span></span>
<span id="cb81-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 20 patients dosed :  100 %</span></span></code></pre></div></div>
</div>
<p>Then we can also plot the summary of these two simulations using the <code>plot</code> function:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb82" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb82-1">DLTsimSum <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(DLTSim,</span>
<span id="cb82-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> TrueDLT</span>
<span id="cb82-3">)</span>
<span id="cb82-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(DLTsimSum))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/DLTSim-plotsummary-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A 2x2 panel of graphs summarising the results of the DLTSim object.  Refer to simSum above for a description of the individual panel elements."></p>
</figure>
</div>
</div>
</div>
<p>and</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb83" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb83-1">DLTsimsampSum <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(DLTsampSim,</span>
<span id="cb83-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> TrueDLT</span>
<span id="cb83-3">)</span>
<span id="cb83-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(DLTsimsampSum))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/DLTsampSim-plotsummary-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A 2x2 panel of graphs summarising the results of the DLTsampSim object.  Refer to simSum above for a description of the individual panel elements."></p>
</figure>
</div>
</div>
</div>
</section>
<section id="predicting-the-future-course-of-the-trial" class="level2">
<h2 class="anchored" data-anchor-id="predicting-the-future-course-of-the-trial">Predicting the future course of the trial</h2>
<p>By simulating parameters from their current posterior distribution instead of an assumed true scenario, it is possible to generate trial simulations from the posterior predictive distribution at any time point during the trial. This means that we can predict the future course of the trial, given the current data. In our illustrating example, this would work as follows.</p>
<p>The rationale of the <code>simulate</code> call is now that we specify as the <code>truth</code> argument the <code>prob</code> function from our assumed model.</p>
<p>For the simulations, these arguments are internally given by the values contained in the data frame given to <code>simulate</code> as the <code>args</code> argument. In our case, we want to supply the posterior samples of <code>alpha0</code> and <code>alpha1</code> in this data frame. We take only 50 out of the 2000 posterior samples in order to reduce the runtime for this example:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb84" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb84-1">postSamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data)[(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, ]</span>
<span id="cb84-2">postSamples</span>
<span id="cb84-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          alpha0    alpha1</span></span>
<span id="cb84-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 50   -0.1016485 1.3609887</span></span>
<span id="cb84-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 100   0.1074864 0.8344500</span></span>
<span id="cb84-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 150  -1.0772617 1.5755517</span></span>
<span id="cb84-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 200  -1.6595007 1.3609433</span></span>
<span id="cb84-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 250  -1.5429162 1.4232225</span></span>
<span id="cb84-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 300   0.3414869 0.6244206</span></span>
<span id="cb84-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 350  -0.9906852 1.0162786</span></span>
<span id="cb84-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 400  -0.5169918 1.6338964</span></span>
<span id="cb84-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 450  -0.1544309 1.4376314</span></span>
<span id="cb84-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 500  -0.8659535 1.0388412</span></span>
<span id="cb84-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 550  -0.8706520 0.4457590</span></span>
<span id="cb84-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 600  -0.7674028 2.1486865</span></span>
<span id="cb84-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 650  -1.1095441 3.0232825</span></span>
<span id="cb84-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 700   0.3535289 1.0627549</span></span>
<span id="cb84-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 750  -1.5980855 0.8025533</span></span>
<span id="cb84-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 800  -0.6363305 1.1292668</span></span>
<span id="cb84-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 850   1.7741008 1.0538473</span></span>
<span id="cb84-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 900  -0.6202566 0.5123655</span></span>
<span id="cb84-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 950  -0.9395287 1.0115243</span></span>
<span id="cb84-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1000 -0.9690361 0.4150773</span></span></code></pre></div></div>
</div>
<p>Therefore, each simulated trial will come from a posterior sample of our estimated model, given all data so far.</p>
<p>Furthermore we have to make a new <code>Design</code> object that contains the current data to start from, and the current recommended dose as the starting dose:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb85" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb85-1">nowDesign <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Design</span>(</span>
<span id="cb85-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb85-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> myNextBest,</span>
<span id="cb85-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping,</span>
<span id="cb85-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements,</span>
<span id="cb85-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize,</span>
<span id="cb85-7">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## use the current data:</span></span>
<span id="cb85-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data,</span>
<span id="cb85-9">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## and the recommended dose as the starting dose:</span></span>
<span id="cb85-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb85-11">)</span></code></pre></div></div>
</div>
<p>Finally we can execute the simulations:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb86" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb86-1">time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">system.time</span>(futureSims <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(</span>
<span id="cb86-2">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## supply the new design here</span></span>
<span id="cb86-3">  nowDesign,</span>
<span id="cb86-4">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## the truth is the assumed prob function</span></span>
<span id="cb86-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose, alpha0, alpha1) {</span>
<span id="cb86-6">    samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Samples</span>(</span>
<span id="cb86-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> alpha0, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> alpha1),</span>
<span id="cb86-8">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb86-9">    )</span>
<span id="cb86-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">prob</span>(dose, model, samples)</span>
<span id="cb86-11">  },</span>
<span id="cb86-12">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## further arguments are the</span></span>
<span id="cb86-13">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## posterior samples</span></span>
<span id="cb86-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> postSamples,</span>
<span id="cb86-15">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## do exactly so many simulations as</span></span>
<span id="cb86-16">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## we have samples</span></span>
<span id="cb86-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(postSamples),</span>
<span id="cb86-18">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">918</span>,</span>
<span id="cb86-19">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## this remains the same:</span></span>
<span id="cb86-20">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> options,</span>
<span id="cb86-21">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb86-22">))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]</span>
<span id="cb86-23">time</span>
<span id="cb86-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; elapsed </span></span>
<span id="cb86-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  17.087</span></span></code></pre></div></div>
</div>
<p>And now, exactly in the same way as above for the operating characteristics simulations, we can summarize the resulting predictive simulations, for example show the predicted trajectories of doses:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb87" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb87-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(futureSims))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/sim-future-plot-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A histrogram showing the proportions of simulations in simSum that identified each dose as the MTD."></p>
</figure>
</div>
</div>
</div>
<p>In the summary, we do not need to look at the characteristics involving the true dose-toxicity function, because in this case we are not intending to compare the performance of our CRM relative to a truth:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb88" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb88-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(futureSims,</span>
<span id="cb88-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth</span>
<span id="cb88-3">)</span>
<span id="cb88-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 20 simulations</span></span>
<span id="cb88-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb88-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target toxicity interval was 20, 35 %</span></span>
<span id="cb88-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target dose interval corresponding to this was 19.6, 21.6 </span></span>
<span id="cb88-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Intervals are corresponding to 10 and 90 % quantiles</span></span>
<span id="cb88-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb88-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 19 (17, 20) </span></span>
<span id="cb88-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above target tox interval : mean 5 (0, 9) </span></span>
<span id="cb88-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of DLTs in the trials : mean 16 % (10 %, 25 %) </span></span>
<span id="cb88-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients on active : mean 26 % (4 %, 43 %) </span></span>
<span id="cb88-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as MTD : mean 32 (14, 48.6) </span></span>
<span id="cb88-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at doses selected : mean 66 % (2 %, 100 %) </span></span>
<span id="cb88-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting target MTD: 5 %</span></span>
<span id="cb88-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as MTD: 44 </span></span>
<span id="cb88-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 11 %</span></span>
<span id="cb88-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted toxicity rate at dose most often selected : mean 36 % (25 %, 52 %) </span></span>
<span id="cb88-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb88-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 3 cohorts dosed :  100 %</span></span>
<span id="cb88-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5 :  75 %</span></span>
<span id="cb88-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 20 patients dosed :  65 %</span></span></code></pre></div></div>
</div>
<p>We see here e.g.&nbsp;that the estimated number of patients overall is 19, so 11 more than the current 8 patients are expected to be needed before finishing the trial.</p>
</section>
</section>
<section id="simulating-33-design-outcomes" class="level1">
<h1>Simulating 3+3 design outcomes</h1>
<p>While <code>crmPack</code> focuses on model-based dose-escalation designs, it also includes the 3+3 design in order to allow for convenient comparisons. Note that actually no simulations would be required for the 3+3 design, because all possible outcomes can be enumerated, however we still rely here on simulations for consistency with the overall <code>crmPack</code> design.</p>
<p>The easiest way to setup a 3+3 design is the function <code>ThreePlusThreeDesign</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb89" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb89-1">threeDesign <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ThreePlusThreeDesign</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">35</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>))</span>
<span id="cb89-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">class</span>(threeDesign)</span>
<span id="cb89-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "RuleDesign"</span></span>
<span id="cb89-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"package")</span></span>
<span id="cb89-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "crmPack"</span></span></code></pre></div></div>
</div>
<p>We have used here a much coarser dose grid than for the model-based design before, because the 3+3 design cannot jump over doses. The starting dose is automatically chosen as the first dose from the grid. The outcome is a <code>RuleDesign</code> object, and you have more setup options if you directly use the <code>RuleDesign()</code> initialization function. We can then simulate trials, again assuming that the <code>myTruth</code> function gives the true dose-toxicity relationship:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb90" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb90-1">threeSims <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(threeDesign,</span>
<span id="cb90-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb90-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">35</span>,</span>
<span id="cb90-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth,</span>
<span id="cb90-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb90-6">)</span></code></pre></div></div>
</div>
<p>As before for the model-based design, we can summarize the simulations:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb91" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb91-1">threeSimsSum <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(threeSims,</span>
<span id="cb91-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth</span>
<span id="cb91-3">)</span>
<span id="cb91-4">threeSimsSum</span>
<span id="cb91-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 1000 simulations</span></span>
<span id="cb91-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb91-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target toxicity interval was 20, 35 %</span></span>
<span id="cb91-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target dose interval corresponding to this was 19.6, 21.6 </span></span>
<span id="cb91-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Intervals are corresponding to 10 and 90 % quantiles</span></span>
<span id="cb91-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb91-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 16 (15, 18) </span></span>
<span id="cb91-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above target tox interval : mean 4 (3, 6) </span></span>
<span id="cb91-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of DLTs in the trials : mean 17 % (13 %, 22 %) </span></span>
<span id="cb91-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients on active : mean 17 % (14 %, 22 %) </span></span>
<span id="cb91-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as MTD : mean 15.2 (15, 15) </span></span>
<span id="cb91-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at doses selected : mean 4 % (3 %, 3 %) </span></span>
<span id="cb91-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting target MTD: 0 %</span></span>
<span id="cb91-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as MTD: 15 </span></span>
<span id="cb91-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 3 %</span></span></code></pre></div></div>
</div>
<p>Here we see that 15 mg was the dose most often selected as MTD, and this is actually too low when comparing with the narrow target dose interval going from 19.6 to 21.6 mg. This is an inherent problem of dose-escalation designs where the dose grid has to be coarse: you might not know before starting the trial which is the range where you need a more refined dose grid. In this case we obtain doses that are too low, as one can see from the average true toxicity of 4~% at doses selected. Graphical summaries are again obtained by calling <code>plot</code> on the summary object:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb92" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb92-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(threeSimsSum))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/three-sims-plot-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A 2x2 panel of graphs summarising the results of the simulations in the threeSimsSum object."></p>
</figure>
</div>
</div>
</div>
</section>
<section id="dual-endpoint-dose-escalation-designs" class="level1">
<h1>Dual-endpoint dose escalation designs</h1>
<p>In this section, we will look into dose-escalation procedures included in this package where two end points are incorporated into the study. The first endpoint is the binary DLT response that we discussed already in the last sections. The second endpoint is the continuous biomarker/efficacy response. In this package, we can either model these two responses jointly (using a single model class, assuming correlation) or separately (using two separate model classes, assuming no correlation).</p>
<p>Now we will first describe how we model the two responses jointly.</p>
<section id="dual-endpoint-designs-with-a-joint-model" class="level2">
<h2 class="anchored" data-anchor-id="dual-endpoint-designs-with-a-joint-model">Dual-endpoint designs with a joint model</h2>
<blockquote class="blockquote">
<p>As a disclaimer, please note that the designs in this section are still under development, and so far we have not yet been published. Therefore please consider them as experimental.</p>
</blockquote>
<p>In the help page <code>DualEndpoint-class</code> the general joint model structure is described. Basically the idea is that a (single) biomarker variable is the second endpoint of the dose-escalation design, with the aim to maximize the biomarker response while controlling toxicity in a safe range. This is useful when it can not be assumed that just increasing the dose will always lead to better efficacy.</p>
<p>Let’s look at the data structure. Here is an example:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb93" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb93-1">data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataDual</span>(</span>
<span id="cb93-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span></span>
<span id="cb93-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb93-4">      <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb93-5">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span></span>
<span id="cb93-6">    ),</span>
<span id="cb93-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span></span>
<span id="cb93-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb93-9">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb93-10">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb93-11">    ),</span>
<span id="cb93-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>),</span>
<span id="cb93-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>)),</span>
<span id="cb93-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">w =</span></span>
<span id="cb93-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb93-16">      <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.31</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.42</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.59</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.45</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.55</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>,</span>
<span id="cb93-17">      <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.52</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.54</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.56</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.43</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.41</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.39</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.34</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.38</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.21</span></span>
<span id="cb93-18">    ),</span>
<span id="cb93-19">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span></span>
<span id="cb93-20">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb93-21">      <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>,</span>
<span id="cb93-22">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb93-23">    )</span>
<span id="cb93-24">)</span></code></pre></div></div>
</div>
<p>The corresponding plot can again be obtained with:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb94" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb94-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(data))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/dual-data-plot-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two graphs, side-by-side.  The first shows patient number on the x axis and dose administered on the y axis.  Different symbols indicate the toxicity status of each patient.  The second graph has dose on the x axis and biomarker value on the y axis.  Again, different symbols indicate toxicity status and annotations show the patient number with which each point is asscoated."></p>
</figure>
</div>
</div>
</div>
<p>Here we see that there seems to be a maximum biomarker response at around 10 mg already. In order to model this data, we consider a dual-endpoint model with a first-order random-walk (RW1) structure for the dose-biomarker relationship:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb95" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb95-1">model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DualEndpointRW</span>(</span>
<span id="cb95-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb95-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb95-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sigma2betaW =</span></span>
<span id="cb95-5">    <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>,</span>
<span id="cb95-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sigma2W =</span></span>
<span id="cb95-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>),</span>
<span id="cb95-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rho =</span></span>
<span id="cb95-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb95-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rw1 =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb95-11">)</span></code></pre></div></div>
</div>
<p>We use a smoothing parameter <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E%7B2%7D_%7B%5Cbeta_%7BW%7D%7D%20=%200.01">, an inverse-gamma prior <img src="https://latex.codecogs.com/png.latex?%5Cmathrm%7BIG%7D(0.1,%200.1)"> on the biomarker variance <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E%7B2%7D_%7BW%7D"> and a uniform prior (or <img src="https://latex.codecogs.com/png.latex?%5Cmathrm%7BBeta%7D(1,%201)"> prior) on the correlation <img src="https://latex.codecogs.com/png.latex?%5Crho"> between the latent DLT and the biomarker variable.</p>
<p>As the dual-endpoint models are more complex, it is advisable to use a sufficiently long Markov chain for fitting them. Here we just use for illustration purposes a quite small Markov chain – again, for the real application, this would need to be at least 25 times longer!</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb96" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb96-1">options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb96-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb96-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb96-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span></span>
<span id="cb96-5">)</span></code></pre></div></div>
</div>
<p>Then we can obtain the MCMC samples:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb97" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb97-1">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(data, model, options)</span></code></pre></div></div>
</div>
<p>And we check the convergence by picking a few of the fitted biomarker means and plotting their traceplots:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb98" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb98-1">data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>nGrid</span>
<span id="cb98-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 41</span></span>
<span id="cb98-3">betaWpicks <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get</span>(samples, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"betaW"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>L))</span>
<span id="cb98-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggs_traceplot</span>(betaWpicks)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/dual-conv-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Traceplots for selected elements of the betaW array."></p>
</figure>
</div>
</div>
</div>
<p>Here all 4 <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7BW,j%7D"> (<img src="https://latex.codecogs.com/png.latex?j=1,%205,%2010,%2025">) means, which are the biomarker means at the first, 5th, 10th and 25th gridpoint, respectively, seem to have converged, as the traceplots show. (Remember that <code>data@nGrid</code> gives the number of grid points.) So we can plot the model fit:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb99" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb99-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(samples, model, data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">extrapolate =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/dual-modelfit-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two plots, side-by-side.  The first shows the posterior estimate of the dose-toxicity curve, with a credible interval.  The second shows the posterior estimate of biomarker level against dose, again with a credible interval."></p>
</figure>
</div>
</div>
</div>
<p>We specify <code>extrapolate = FALSE</code> to focus the biomarker plot in the right panel on the observed dose range, so we don’t want to extrapolate the biomarker fit to higher dose levels. We can also look at the estimated biomarker precision <img src="https://latex.codecogs.com/png.latex?1%20/%20%5Csigma%5E%7B2%7D_%7BW%7D">. For that we extract the precision <code>precW</code> and then use another <code>ggmcmc</code> function to create the histogram:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb100" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb100-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggs_histogram</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get</span>(samples, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"precW"</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/dual-variance-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A histogram of the biomarker precision in the samples object."></p>
</figure>
</div>
</div>
</div>
<p>For the selection of the next best dose, a special class <code>NextBestDualEndpoint</code> has been implemented. It tries to maximize the biomarker response, under an NCRM-type safety constraint. If we want to have at least 90% of the maximum biomarker response, and a 25% maximum overdose probability for the next dose, we specify:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb101" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb101-1">myNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestDualEndpoint</span>(</span>
<span id="cb101-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb101-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overdose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb101-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_overdose_prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span></span>
<span id="cb101-5">)</span></code></pre></div></div>
</div>
<p>In our example, and assuming a dose limit of 50 mg given by the maximum allowable increments, the next dose can then be found as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb102" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb102-1">nextDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(myNextBest,</span>
<span id="cb102-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>,</span>
<span id="cb102-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> samples,</span>
<span id="cb102-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb102-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data</span>
<span id="cb102-6">)</span>
<span id="cb102-7">nextDose<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb102-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 10</span></span></code></pre></div></div>
</div>
<p>A corresponding plot can be produced by printing the <code>plot</code> element of the returned list:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb103" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb103-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(nextDose<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plot)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/dual-nextdose-plot-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two graphs in a single column that summarise the results of applying the NextBest rule.  For descriptions of the plots, refer to earlier examples in this vignette."></p>
</figure>
</div>
</div>
</div>
<p>Here the bottom panel shows (as for the NCRM) the overdose probability, and we see that doses above 14 mg are too toxic. In the top panel, we see the probability for each dose to reach at least 90% of the maximum biomarker response in the dose grid — this is here our target probability. While the numbers are low, we clearly see that there is a local maximum at 6 mg of the target probability, confirming what we have seen in the previous data and model fit plots.</p>
<p>A corresponding stopping rule exists. When we have a certain probability to be above a relative biomarker target, then the <code>StoppingTargetBiomarker</code> rule gives back <code>TRUE</code> when queried if it has been fulfilled by the <code>stopTrial</code> function. For example, if we require at least 50% probability to be above 90% biomarker response, we specify:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb104" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb104-1">myStopping6 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingTargetBiomarker</span>(</span>
<span id="cb104-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb104-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span></span>
<span id="cb104-4">)</span></code></pre></div></div>
</div>
<p>In this case, the rule has not been fulfilled yet, as we see here:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb105" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb105-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(myStopping6,</span>
<span id="cb105-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> nextDose<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value,</span>
<span id="cb105-3">  samples, model, data</span>
<span id="cb105-4">)</span>
<span id="cb105-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb105-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb105-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target biomarker is 10 % for dose 10 and thus below the required 50 %"</span></span>
<span id="cb105-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb105-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "P(0.9 ≤ Biomarker ≤ 1) ≥ 0.5 (relative)"</span></span></code></pre></div></div>
</div>
<p>Again, this dual-endpoint specific rule can be combined as required with any other stopping rule. For example, we could combine it with a maximum sample size of 40~patients:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb106" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb106-1">myStopping <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> myStopping6 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinPatients</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>)</span></code></pre></div></div>
</div>
<p>If one or both of the stopping rules are fulfilled, then the trial is stopped.</p>
<p>Let’s try to build a corresponding dual-endpoint design. We start with an empty data set, and use the relative increments rule defined in a previous section and use a constant cohort size of 3 patients:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb107" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb107-1">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataDual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid)</span>
<span id="cb107-2">design <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DualDesign</span>(</span>
<span id="cb107-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb107-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> emptydata,</span>
<span id="cb107-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> myNextBest,</span>
<span id="cb107-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping,</span>
<span id="cb107-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements,</span>
<span id="cb107-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb107-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span></span>
<span id="cb107-10">)</span></code></pre></div></div>
</div>
<p>In order to study operating characteristics, we need to determine true biomarker and DLT probability functions. Here we are going to use a biomarker function from the beta family. Note that there is a corresponding <code>DualEndpointBeta</code> model class, that allows to have dual-endpoint designs with the beta biomarker response function. Have a look at the corresponding help page for more information on that. But let’s come back to our scenario definition:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb108" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb108-1">betaMod <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose, e0, eMax, delta1, delta2, scal) {</span>
<span id="cb108-2">  maxDens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (delta1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>delta1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (delta2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>delta2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> ((delta1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> delta2)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>(delta1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> delta2))</span>
<span id="cb108-3">  dose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dose <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> scal</span>
<span id="cb108-4">  e0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> eMax <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> maxDens <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (dose<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>delta1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> dose)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>delta2</span>
<span id="cb108-5">}</span>
<span id="cb108-6">trueBiomarker <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose) {</span>
<span id="cb108-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">betaMod</span>(dose, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">e0 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eMax =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">delta1 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">delta2 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">scal =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb108-8">}</span>
<span id="cb108-9">trueTox <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose) {</span>
<span id="cb108-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pnorm</span>((dose <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>)</span>
<span id="cb108-11">}</span></code></pre></div></div>
</div>
<p>We can draw the corresponding curves:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb109" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb109-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">par</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mfrow =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb109-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">curve</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trueTox</span>(x), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>)</span>
<span id="cb109-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">curve</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trueBiomarker</span>(x), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/dual-sc-plot-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two graphs representing the true relationships between dose and toxicity and dose and biomarker level."></p>
</figure>
</div>
</div>
</div>
<p>So the biomarker response peaks at 50 mg, where the toxicity is still low. After deciding for a true correlation of <img src="https://latex.codecogs.com/png.latex?%5Crho=0"> and a true biomarker variance of <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E%7B2%7D_%7BW%7D%20=%200.01"> (giving a high signal-to-noise ratio), we can start simulating trials (starting each with 6 mg):</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb110" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb110-1">mySims <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(design,</span>
<span id="cb110-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueTox =</span> trueTox,</span>
<span id="cb110-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueBiomarker =</span> trueBiomarker,</span>
<span id="cb110-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sigma2W =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>,</span>
<span id="cb110-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rho =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb110-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb110-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb110-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb110-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>,</span>
<span id="cb110-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span></span>
<span id="cb110-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb110-12">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb110-13">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb110-14">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3000</span></span>
<span id="cb110-15">    )</span>
<span id="cb110-16">)</span></code></pre></div></div>
</div>
<p>Note that we are having a “small” MCMC option set here, in order to reduce simulation time — for the real application, this should be “larger”.</p>
<p>Plotting the result gives not only an overview of the final dose recommendations and trial trajectories, but also a summary of the biomarker variance and correlation estimates in the simulations:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb111" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb111-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(mySims))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/dual-sims-plot-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A panel of four plots summarisong the results of the simulation."></p>
</figure>
</div>
</div>
</div>
<p>Finally, a summary of the simulations can be obtained with the corresponding function:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb112" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb112-1">sumOut <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(mySims,</span>
<span id="cb112-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueTox =</span> trueTox,</span>
<span id="cb112-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueBiomarker =</span> trueBiomarker</span>
<span id="cb112-4">)</span>
<span id="cb112-5">sumOut</span>
<span id="cb112-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 10 simulations</span></span>
<span id="cb112-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb112-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target toxicity interval was 20, 35 %</span></span>
<span id="cb112-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target dose interval corresponding to this was 51.6, 56.1 </span></span>
<span id="cb112-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Intervals are corresponding to 10 and 90 % quantiles</span></span>
<span id="cb112-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb112-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 42 (42, 42) </span></span>
<span id="cb112-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above target tox interval : mean 0 (0, 0) </span></span>
<span id="cb112-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of DLTs in the trials : mean 0 % (0 %, 0 %) </span></span>
<span id="cb112-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients on active : mean 0 % (0 %, 0 %) </span></span>
<span id="cb112-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as MTD : mean 0.1 (0.1, 0.1) </span></span>
<span id="cb112-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at doses selected : mean 0 % (0 %, 0 %) </span></span>
<span id="cb112-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting target MTD: 0 %</span></span>
<span id="cb112-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as MTD: 0.1 </span></span>
<span id="cb112-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 0 %</span></span>
<span id="cb112-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted toxicity rate at dose most often selected : mean 2 % (1 %, 2 %) </span></span>
<span id="cb112-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb112-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  P(0.9 ≤ Biomarker ≤ 1) ≥ 0.5 (relative) :  0 %</span></span>
<span id="cb112-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 40 patients dosed :  100 %</span></span>
<span id="cb112-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted biomarker level at dose most often selected : mean 0.2 (0.2, 0.2)</span></span></code></pre></div></div>
</div>
<p>We see here that all trials proceeded until the maximum sample size of 40 patients (reaching 42 because of the cohort size 3). The doses selected are lower than the toxicity target range, because here we were aiming for a biomarker target instead, and the true biomarker response peaked at 50 mg.</p>
<p>The corresponding plot looks as follows:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb113" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb113-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(sumOut))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/dual-sim-sum-plot-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A panel of plots that dscribe the results of the simulation summary."></p>
</figure>
</div>
</div>
</div>
<p>We see that the average biomarker fit is not too bad in the range up to 50 mg, but the toxicity curve fit is bad — probably a result of the very low frequency of DLTs.</p>
<p>Again the warning here: the dual-endpoint designs are still experimental!</p>
<p>% Next we will talk about dose escalation designs where the two endpoints are modelled separately.</p>
</section>
<section id="dual-endpoint-designs-with-separate-models" class="level2">
<h2 class="anchored" data-anchor-id="dual-endpoint-designs-with-separate-models">Dual-endpoint designs with separate models</h2>
<p>In this subsection, we will look into the dose-escalation designs where we model the binary DLT responses and the continuous biomarker/efficacy responses separately. Here we hence assume that there is no correlation between the binary DLT and continuous efficacy responses.</p>
<p>First, we have to define the data sets for the dual responses using the <code>DataDual</code> function just like in the example given in the last subsection.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb114" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb114-1">data2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataDual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>))</span>
<span id="cb114-2"></span>
<span id="cb114-3">data4 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataDual</span>(</span>
<span id="cb114-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">225</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>),</span>
<span id="cb114-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb114-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>),</span>
<span id="cb114-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)),</span>
<span id="cb114-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">w =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.31</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.42</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.59</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.45</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.52</span>),</span>
<span id="cb114-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>)</span>
<span id="cb114-10">)</span></code></pre></div></div>
</div>
<p>In this example, <code>data2</code> is the empty data set where 12 dose levels, from 25 to 300 mg with increments of 25 mg are used. The variable <code>data4</code> contains the data set with both the binary DLT and continuous efficacy responses observations. The elements in the slot <code>x</code> are the dose levels where 8 subjects are treated. The elements in slot <code>y</code> represent the corresponding binary DLT responses observed for these 8 subjects and the elements in slot <code>w</code> represent the continuous efficacy responses obtained for the 8 subjects.</p>
<p>Similarly, we can also obtain a plot of the data sets using the <code>plot</code> function as described in the last subsection.</p>
<p>As described, we will model the two responses separately. In order to do so, we will only use models inheriting from the <code>ModelPseudo</code> class.</p>
<p>For the binary DLT responses, we can use any of the models inheriting from the <code>ModelTox</code> class. In the example below we will use models inheriting from the <code>LogisticIndepBeta</code> class which is the variable <code>DLTmodel</code> (or <code>newDLTmodel</code> with observations) given in previous examples.</p>
<p>For the continuous efficacy responses, we can use any models inheriting from the <code>ModelEff</code> class. In the current version of the package, there are two model classes, the <code>Effloglog</code> and the <code>EffFlexi</code> model, inheriting from the <code>ModelEff</code> class. Since <code>ModelEff</code> is also inheriting from the <code>ModelPseudo</code> class, the prior for this efficacy model also needs to be specified in the form of pseudo data. (Please refer to @ref(fig:model-classes) for the structure of model classes defined in this package.)</p>
<p>The following commands show how we set up the <code>Effloglog</code> model. This is an efficacy model to describe the relationship between the efficacy responses to their corresponding dose levels on a double logarithmic (“log-log”) scale. This refers to a linear model with three unknown parameters: the intercept θ<sub>1</sub>, the slope θ<sub>2</sub> and the precision <img src="https://latex.codecogs.com/png.latex?%5Cnu"> (inverse of the variance) of the efficacy responses. Similarly to other pseudo models, the data set has to be specified before setting up the model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb115" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb115-1">Effmodel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Effloglog</span>(</span>
<span id="cb115-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eff =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.223</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.513</span>),</span>
<span id="cb115-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eff_dose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>),</span>
<span id="cb115-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nu =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.025</span>),</span>
<span id="cb115-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2</span>
<span id="cb115-6">)</span></code></pre></div></div>
</div>
<p>For the specification of the prior pseudo data, two dose levels 25 and 300 mg are fixed and specified in the <code>eff_dose</code> slot. After eliciting the prior expected efficacy values at these two dose levels (e.g.&nbsp;by asking for experts’), these are specified in the <code>eff</code> slot. Here for example, 1.223 is the expected efficacy value for subjects treated at dose 25 mg and 2.513 is the expected efficacy value for subjects treated at 300 mg. The slot <code>nu</code> represents the prior precision of the efficacy responses. In this example, two positive scalars for <img src="https://latex.codecogs.com/png.latex?a"> and <img src="https://latex.codecogs.com/png.latex?b"> are specified suggesting the prior distribution of the precision is gamma with shape parameter <img src="https://latex.codecogs.com/png.latex?a=1"> and rate parameter <img src="https://latex.codecogs.com/png.latex?b=0.025">. Note here, since a gamma distribution is used as the prior distribution of <img src="https://latex.codecogs.com/png.latex?%5Cnu">, the posterior distribution will again be a gamma distribution, because the gamma prior on the precision is conjugate to the normal likelihood. If a fixed value of the precision is preferred, a single positive scalar can also be specified in <code>nu</code> slot. Finally the <code>Data</code> slot is specified either with an empty data set or a data set with all currently available observations.</p>
<p>Similarly, we can also look at the structure of the Effmodel by applying the <code>str</code> function:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb116" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb116-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(Effmodel)</span>
<span id="cb116-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Formal class 'Effloglog' [package "crmPack"] with 13 slots</span></span>
<span id="cb116-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ eff      : num [1:2] 1.22 2.51</span></span>
<span id="cb116-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ eff_dose : num [1:2] 25 300</span></span>
<span id="cb116-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ nu       : Named num [1:2] 1 0.025</span></span>
<span id="cb116-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..- attr(*, "names")= chr [1:2] "a" "b"</span></span>
<span id="cb116-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ use_fixed: logi FALSE</span></span>
<span id="cb116-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ theta1   : num -1.41</span></span>
<span id="cb116-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ theta2   : num 2.25</span></span>
<span id="cb116-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ Pcov     : num [1:2, 1:2] NaN NaN NaN NaN</span></span>
<span id="cb116-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..- attr(*, "dimnames")=List of 2</span></span>
<span id="cb116-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..$ : chr [1:2] "(Intercept)" "log(log(x))"</span></span>
<span id="cb116-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..$ : chr [1:2] "(Intercept)" "log(log(x))"</span></span>
<span id="cb116-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ X        : num [1:2, 1:2] 1 1 1.17 1.74</span></span>
<span id="cb116-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..- attr(*, "dimnames")=List of 2</span></span>
<span id="cb116-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..$ : chr [1:2] "1" "2"</span></span>
<span id="cb116-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..$ : chr [1:2] "(Intercept)" "log(log(x))"</span></span>
<span id="cb116-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..- attr(*, "assign")= int [1:2] 0 1</span></span>
<span id="cb116-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ Y        : num [1:2] 1.22 2.51</span></span>
<span id="cb116-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ mu       : num [1:2] -1.41 2.25</span></span>
<span id="cb116-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ Q        : num [1:2, 1:2] 2 2.91 2.91 4.4</span></span>
<span id="cb116-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..- attr(*, "dimnames")=List of 2</span></span>
<span id="cb116-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..$ : chr [1:2] "(Intercept)" "log(log(x))"</span></span>
<span id="cb116-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..$ : chr [1:2] "(Intercept)" "log(log(x))"</span></span>
<span id="cb116-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ const    : num 0</span></span>
<span id="cb116-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ data     :Formal class 'DataDual' [package "crmPack"] with 12 slots</span></span>
<span id="cb116-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ w         : num(0) </span></span>
<span id="cb116-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ x         : num(0) </span></span>
<span id="cb116-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ y         : int(0) </span></span>
<span id="cb116-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ doseGrid  : num [1:12] 25 50 75 100 125 150 175 200 225 250 ...</span></span>
<span id="cb116-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ nGrid     : int 12</span></span>
<span id="cb116-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ xLevel    : int(0) </span></span>
<span id="cb116-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ placebo   : logi FALSE</span></span>
<span id="cb116-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ backfilled: logi(0) </span></span>
<span id="cb116-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ response  : int(0) </span></span>
<span id="cb116-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ ID        : int(0) </span></span>
<span id="cb116-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ cohort    : int(0) </span></span>
<span id="cb116-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ nObs      : int 0</span></span></code></pre></div></div>
</div>
<p>There are 15 slots, which can be accessed with the <code>@</code> operator. From this efficacy model, we can obtain the prior (if using an empty data set) or the posterior modal estimates of model parameters θ<sub>1</sub> (intercept) and θ<sub>2</sub> (slope). In addition, if a gamma prior distribution is used for <img src="https://latex.codecogs.com/png.latex?%5Cnu"> and we have some observations (data) available, then we can obtain the updated values of the shape <img src="https://latex.codecogs.com/png.latex?a"> and the rate <img src="https://latex.codecogs.com/png.latex?b"> parameters for the gamma distribution, via the model. The joint prior and posterior density functions of θ<sub>1</sub> and θ<sub>2</sub> are described in details in <span class="citation" data-cites="wy15">(Yeung et al. 2015)</span>.</p>
<p>Next, we will describe an example when a flexible semi-parametric function is used to describe the relationship between the efficacy values and their corresponding dose levels. The differences of the mean efficacy responses of neighboring dose levels are modeled by the either first or second order random walk models. This flexible model aims to capture different shapes of the dose-efficacy curve. We will estimate the mean efficacy responses obtained at each of the dose levels by MCMC sampling. % will be involved to obtain the prior and posterior distribution of all these mean efficacy responses.</p>
<p>This flexible form can be specified by using the <code>EffFlexi</code> class object. The <code>EffFlexi</code> class is inheriting from the <code>ModelEff</code> class and its prior is also specified with pseudo data:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb117" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb117-1">Effmodel2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">EffFlexi</span>(</span>
<span id="cb117-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eff =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.223</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.513</span>),</span>
<span id="cb117-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eff_dose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>),</span>
<span id="cb117-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sigma2W =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>),</span>
<span id="cb117-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sigma2betaW =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>),</span>
<span id="cb117-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rw1 =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb117-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2</span>
<span id="cb117-8">)</span></code></pre></div></div>
</div>
<p>Here, similarly to above, we also fixed two dose levels 25 and 300 mg and supplied the prior expected efficacy responses 1.223 and 2.513. The variance of the efficacy responses <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E2"> under this model can be specified with a single positive scalar value or two positive scalar values for the shape <img src="https://latex.codecogs.com/png.latex?a"> and the scale <img src="https://latex.codecogs.com/png.latex?b"> parameters of the inverse gamma distribution in the slot <code>sigma2</code>. In here, we specified the variance of the efficacy responses with the inverse gamma distribution with shape parameter <img src="https://latex.codecogs.com/png.latex?a=0.1"> and scale parameter <img src="https://latex.codecogs.com/png.latex?b=0.1">. Then, the variance of the random walk model <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E2_%7B%5Cbeta_W%7D"> can also be specified either with a single positive scalar or two positive scalar for the parameters of the inverse gamma distribution in the slot <code>sigma2betaW</code>. In here, we specified the variance of the random walk model with the inverse gamma distribution with shape parameter <img src="https://latex.codecogs.com/png.latex?a=20"> and scale parameter <img src="https://latex.codecogs.com/png.latex?b=50">. In addition, we can also specify how we would like to smooth the mean efficacy response function. Either the first order (with <code>RW1</code>) or the second order (with <code>RW2</code>) random walk model can be used to describe the relationship between the neighbouring mean efficacy responses and is specified in the the slot <code>smooth</code>. As seen in our example, <code>RW2</code>, the second order random walk model is used. Finally, we also have to specify the data set in <code>Data</code> to be used for the model which is <code>data2</code> in this example.</p>
<p>The structure of the <code>EffFlexi</code> model object is as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb118" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb118-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(Effmodel2)</span>
<span id="cb118-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Formal class 'EffFlexi' [package "crmPack"] with 10 slots</span></span>
<span id="cb118-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ eff        : num [1:2] 1.22 2.51</span></span>
<span id="cb118-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ eff_dose   : num [1:2] 25 300</span></span>
<span id="cb118-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ sigma2W    : Named num [1:2] 0.1 0.1</span></span>
<span id="cb118-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..- attr(*, "names")= chr [1:2] "a" "b"</span></span>
<span id="cb118-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ sigma2betaW: Named num [1:2] 20 50</span></span>
<span id="cb118-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..- attr(*, "names")= chr [1:2] "a" "b"</span></span>
<span id="cb118-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ use_fixed  : Named logi [1:2] FALSE FALSE</span></span>
<span id="cb118-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. ..- attr(*, "names")= chr [1:2] "sigma2W" "sigma2betaW"</span></span>
<span id="cb118-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ rw1        : logi FALSE</span></span>
<span id="cb118-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ X          : int [1:2, 1:12] 1 0 0 0 0 0 0 0 0 0 ...</span></span>
<span id="cb118-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ RW         : num [1:12, 1:12] 1 -2 1 0 0 0 0 0 0 0 ...</span></span>
<span id="cb118-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ RW_rank    : int 10</span></span>
<span id="cb118-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   ..@ data       :Formal class 'DataDual' [package "crmPack"] with 12 slots</span></span>
<span id="cb118-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ w         : num(0) </span></span>
<span id="cb118-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ x         : num(0) </span></span>
<span id="cb118-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ y         : int(0) </span></span>
<span id="cb118-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ doseGrid  : num [1:12] 25 50 75 100 125 150 175 200 225 250 ...</span></span>
<span id="cb118-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ nGrid     : int 12</span></span>
<span id="cb118-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ xLevel    : int(0) </span></span>
<span id="cb118-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ placebo   : logi FALSE</span></span>
<span id="cb118-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ backfilled: logi(0) </span></span>
<span id="cb118-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ response  : int(0) </span></span>
<span id="cb118-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ ID        : int(0) </span></span>
<span id="cb118-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ cohort    : int(0) </span></span>
<span id="cb118-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   .. .. ..@ nObs      : int 0</span></span></code></pre></div></div>
</div>
<p>The slot and the names are shown which can be accessed with the <code>@</code> operator. The value ‘FALSE’ of the slot <code>useFixed</code> shows that both the variance of the efficacy response <code>sigma2</code> and the variance of the random walk model `sigma2betaW<code>are not fixed, but estimated and assigned an inverse gamma prior distribution in this model. The slot</code>useRW1<code>also gives a 'FALSE' value which means that the second order random walk model has been used to model the smooth dose-response function. In addition, the (only internally required) random walk difference matrix and the rank of this matrix are also shown in the slot</code>RWmat<code>and</code>RWmatRank`, respectively.</p>
<p>As discussed, the posterior estimates for model parameters specified under <code>ModelPseudo</code> class (except the <code>EffFlexi</code> model class) can be obtained as the modal estimates or via MCMC sampling. In here, we will first show how we obtain the estimates of the parameters via MCMC sampling. (Similarly, we can also use the <code>mcmc</code> function to obtain prior and posterior samples of the <code>Effloglog</code> and the <code>EffFlexi</code> models.) % using Effmodel or Effmodel2, respectively with data2 and options specified earlier</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb119" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb119-1">Effsamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> Effmodel, options)</span>
<span id="cb119-2">Effsamples2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> Effmodel2, options)</span></code></pre></div></div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb120" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb120-1">Effpostsamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> Effmodel, options)</span>
<span id="cb120-2">Effpostsamples2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> Effmodel2, options)</span></code></pre></div></div>
</div>
<p>Under the <code>Effloglog</code> (Effmodel) model, samples of the intercept θ<sub>1</sub>, the slope θ<sub>2</sub> of the efficacy linear log-log model and the precision <img src="https://latex.codecogs.com/png.latex?%5Cnu"> of the efficacy responses can be obtained. For the <code>EffFlexi</code> (Effmodel2) model, the samples of the mean efficacy responses at all dose levels, the variance <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E2"> (sigma2) of the efficacy responses and the variance <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E2_%7B%5Cbeta_W%7D"> (sigma2betaW) of the random walk model are obtained. It is also again possible to look at the structure (<code>str</code>) and extract (<code>get</code>) and obtain plots (<code>ggs_traceplot</code> and <code>ggs_autocorrelation</code>) of the samples of the parameters.</p>
<p>If no MCMC sampling is involved, the prior or the posterior modal estimates can be obtained in the output of the models. If some observations for both responses are available, they can be put in a <code>DataDual</code> data set, and given to the <code>Data</code> slot under each model. We can also do so by updating the current model with the new observations using the <code>update</code> function. Then the prior or the posterior modal estimates of the model parameters can be obtained using the <code>@</code> operator of the model. For example, for the <code>Effloglog</code> class model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb121" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb121-1">newEffmodel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">object =</span> Effmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data4)</span>
<span id="cb121-2">newEffmodel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>theta1</span>
<span id="cb121-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] -2.81695</span></span>
<span id="cb121-4">newEffmodel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>theta2</span>
<span id="cb121-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 2.709524</span></span>
<span id="cb121-6">newEffmodel<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>nu</span>
<span id="cb121-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;         a         b </span></span>
<span id="cb121-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 3.0000000 0.9832955</span></span></code></pre></div></div>
</div>
<p>The posterior modal estimates of θ<sub>1</sub> and θ<sub>2</sub> and the updated values of parameters of the gamma distribution of <img src="https://latex.codecogs.com/png.latex?%5Cnu"> can be read now from the output above.</p>
<p>Similarly we can update with new data for the <code>EffFlexi</code> class model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb122" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb122-1">newEffmodel2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">object =</span> Effmodel2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data4)</span>
<span id="cb122-2">newEffmodel2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>RW</span>
<span id="cb122-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]</span></span>
<span id="cb122-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1,]    1   -2    1    0    0    0    0    0    0     0     0     0</span></span>
<span id="cb122-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [2,]   -2    5   -4    1    0    0    0    0    0     0     0     0</span></span>
<span id="cb122-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [3,]    1   -4    6   -4    1    0    0    0    0     0     0     0</span></span>
<span id="cb122-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [4,]    0    1   -4    6   -4    1    0    0    0     0     0     0</span></span>
<span id="cb122-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [5,]    0    0    1   -4    6   -4    1    0    0     0     0     0</span></span>
<span id="cb122-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [6,]    0    0    0    1   -4    6   -4    1    0     0     0     0</span></span>
<span id="cb122-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [7,]    0    0    0    0    1   -4    6   -4    1     0     0     0</span></span>
<span id="cb122-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [8,]    0    0    0    0    0    1   -4    6   -4     1     0     0</span></span>
<span id="cb122-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [9,]    0    0    0    0    0    0    1   -4    6    -4     1     0</span></span>
<span id="cb122-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [10,]    0    0    0    0    0    0    0    1   -4     6    -4     1</span></span>
<span id="cb122-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [11,]    0    0    0    0    0    0    0    0    1    -4     5    -2</span></span>
<span id="cb122-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [12,]    0    0    0    0    0    0    0    0    0     1    -2     1</span></span></code></pre></div></div>
</div>
<p>The <code>plot</code> function can also be applied to the <code>Effloglog</code> model class or the <code>EffFlexi</code> model class objects, when samples of the parameters are generated under all these models:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb123" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb123-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(Effpostsamples, newEffmodel, data4))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plot-samplesdata2loglog-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Expected efficacy against dose for the data4 object, assuming the model described by the newEffmodel object."></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb124" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb124-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(Effpostsamples2, newEffmodel2, data4))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plot-samplesdata2Flexi-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Expected efficacy against dose for the data4 object, assuming the model described by the newEffmodel2 object."></p>
</figure>
</div>
</div>
</div>
<p>In addition, we can also plot the fitted dose-efficacy curve using the prior or the posterior modal estimates of the model parameters when no MCMC sampling is used. For example, using <code>Effmodel</code> and data set <code>data2</code> specified earlier:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb125" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb125-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(data2, Effmodel))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plot-nosamplesEffmodel-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Expected efficacy against dose for the data2 object, assuming the model described by the Effmodel object."></p>
</figure>
</div>
</div>
</div>
<p>Since no samples are involved, only the curves using the prior or posterior modal estimates of the parameters are produced, and no 95% credibility intervals are provided.</p>
<p>Furthermore, we can also plot the estimated DLT probability and efficacy curve side by side using the <code>plotDualResponses</code> function. For example, using the <code>DLTmodel</code>, <code>Effmodel</code> and <code>data2</code> specified in earlier examples:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb126" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb126-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plotDualResponses</span>(</span>
<span id="cb126-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">DLEmodel =</span> DLTmodel,</span>
<span id="cb126-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Effmodel =</span> Effmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2</span>
<span id="cb126-4">)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plotDualResponseNoSamples-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Model estimates of toxicity and biomarker level by dose."></p>
</figure>
</div>
</div>
</div>
<p>When the MCMC samples are used, we have:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb127" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb127-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plotDualResponses</span>(</span>
<span id="cb127-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">DLEmodel =</span> DLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">DLEsamples =</span> DLTsamples,</span>
<span id="cb127-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Effmodel =</span> Effmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Effsamples =</span> Effsamples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2</span>
<span id="cb127-4">)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plotDualResponseSamples-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Model estimates of toxicity and biomarker level by dose, both with credible intervals."></p>
</figure>
</div>
</div>
</div>
<p>Next we will talk about the dose escalation rules when two separate models are used for the dual responses. All <code>Increments</code>, <code>CohortSize</code> and the <code>Stopping</code> rules classes described earlier can be applied here. We will now look into additional <code>nextBest</code> and <code>Stopping</code> classes rules that we can use in this situation.</p>
<p>In here, the decision of choosing the next best dose for administration is based on a gain function we defined <span class="citation" data-cites="wy15">(Yeung et al. 2015)</span>. This gain function represents a trade-off between the DLT and efficacy responses such that we will allocate the dose which gives the best trade-off between these responses. In other words, the dose which gives the maximum gain value will be the dose allocated to the next cohort of subjects. The basic ideas of this rules are as follows. % old text: Assume that no DLT is observed in a subject, the gain value observed at a particular dose level is obtained by multiplying the probability of no DLT observed at this dose levels and all expected efficacy responses when no DLT is observed at this particular dose level. %new: The gain value at a particular dose level is obtained by multiplying the probability of no DLT at this dose level and the expected efficacy response at this dose level. As the data accumulates in the trial, the estimate of the gain function will improve. This gain function consists of two components, one part is about the DLT responses and the other about the efficacy response. It depends on the values obtained in each of the components which will affect the values of the gain.</p>
<p>For example, the most ideal case is that both the probability of no DLT and the expected value of the efficacy response are high. The gain value obtained will then be very high. This is the reason why the dose which gives the maximum gain value should be allocated to the next cohort of subjects.</p>
<p>We can plot the gain function given a DLT model specified under the <code>ModelTox</code> class and an efficacy model specified under the <code>ModelEff</code> class using the <code>plotGain</code> function. For example, using the variables <code>newDLTmodel</code>, <code>newEffmodel</code> and the data set with observations, <code>data4</code>, specified in earlier examples, we have:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb128" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb128-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plotGain</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">DLEmodel =</span> newDLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Effmodel =</span> newEffmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data4)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plotGain-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A summary of the gain function  for newDLEmodel and newEffmodel applied to data4."></p>
</figure>
</div>
</div>
</div>
<p>This is a case where no MCMC sampling is involved such that the prior and posterior modal estimates of the model parameters are used.</p>
<p>There are two implemented <code>nextBest</code> rules for the dual responses using the gain function: the <code>NextBestMaxGain</code> and the <code>NextBestMaxGainSamples</code> class object. The <code>NextBestMaxGain</code> is used when no MCMC sampling are involved and we will use the prior or the posterior modal estimates of the model parameters to obtain the gain values at each of the dose levels, while the <code>NextBestMaxGainSamples</code> is used when MCMC sampling is involved to obtain the posterior estimates. For example, when no MCMC sampling is involved:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb129" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb129-1">GainNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestMaxGain</span>(</span>
<span id="cb129-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target_drt =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>,</span>
<span id="cb129-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target_eot =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span></span>
<span id="cb129-4">)</span></code></pre></div></div>
</div>
<p>To use the <code>NextBestMaxGain</code>, we have to specify the target probability of the occurrence of a DLT to be used during the trial or at the end of the trial. In this example, the target probability of DLT to be used during the trial and at the end of the trial are 0.35 and 0.3, respectively. Therefore, under this rule we will suggest the dose level which gives the maximum gain value and has a probability of DLT less than or equal to 0.35 to administer to the next cohort of subjects. At the end of the trial, we will recommend the dose with maximum gain value and probability of DLT less than or equal to 0.3. In order to derive the next best dose for administration, we have to use the <code>nextBest</code> function with this <code>NextBestMaxGain</code> object given the doselimit, both the DLT and the efficacy models and the data set, which includes all currently available observations:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb130" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb130-1">doseRecGain <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(GainNextBest,</span>
<span id="cb130-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(data4<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid),</span>
<span id="cb130-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> newDLTmodel,</span>
<span id="cb130-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model_eff =</span> newEffmodel,</span>
<span id="cb130-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data4</span>
<span id="cb130-6">)</span></code></pre></div></div>
</div>
<p>The results will be a list of numerical values with a plot illustrating how the next best dose was computed. The list of numerical values include the next best dose suggested, the values of the target probabilities of DLT used during and at the end of a trial. Furthermore, the estimated doses for these two targets, as well as the “Gstar” estimated dose (the dose with gives the maximum gain value) are provided along with the corresponding dose level in the dose grid for the above three estimates. We can also get to see the plot about the next best dose recommendation using the <code>$</code> operator.</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb131" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb131-1">doseRecGain<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plot</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/nextbestplot-maxgain-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A summary the results of applying the GainNextBest object to the gain function for newDLEmodel and newEffmodel applied to data4."></p>
</figure>
</div>
</div>
</div>
<p>As usual, we have the solid red, blue and green lines as the curves to represent the relationship between the probability of DLT, the mean efficacy response and gain values, respectively, to their corresponding dose levels. The vertical line in purple shows the next best dose suggested for administration and the vertical brown line shows the maximum allowable dose level to be administered to the next cohort of subjects. Furthermore, the circle and the square on the DLT curve also show the current estimate of the estimated TD30 and TD35.</p>
<p>Next we will look at the <code>NextBestMaxGainSamples</code> class object when MCMC sampling is involved. In the following code, we specify the target probabilities of DLT used during or at the end of a trial to be 0.35 and 0.3 again, and we specify that the 30% posterior quantile will be used as the estimate for the TD35 and TD30, while we specify the 50% posterior quantile for the Gstar estimate:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb132" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb132-1">GainsamplesNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestMaxGainSamples</span>(</span>
<span id="cb132-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target_drt =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>,</span>
<span id="cb132-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target_eot =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,</span>
<span id="cb132-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">derive =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(TDsamples) {</span>
<span id="cb132-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">quantile</span>(TDsamples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>))</span>
<span id="cb132-6">  },</span>
<span id="cb132-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mg_derive =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(Gstarsamples) {</span>
<span id="cb132-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">quantile</span>(Gstarsamples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>))</span>
<span id="cb132-9">  }</span>
<span id="cb132-10">)</span></code></pre></div></div>
</div>
<p>Note that the two functions, <code>derive</code> and <code>mg_derive</code> have to be specified to derive the corresponding estimates from the posterior samples.</p>
<p>Again, the generic function <code>nextBest</code> will be used together with this rule object to derive the next best dose:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb133" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb133-1">doseRecGainSamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(GainsamplesNextBest,</span>
<span id="cb133-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(data4<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid),</span>
<span id="cb133-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> newDLTmodel,</span>
<span id="cb133-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> DLTpostsamples,</span>
<span id="cb133-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model_eff =</span> newEffmodel,</span>
<span id="cb133-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples_eff =</span> Effpostsamples,</span>
<span id="cb133-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data4</span>
<span id="cb133-8">)</span>
<span id="cb133-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Estimated TD 30 = 18.6611868271306 not within dose grid"</span></span></code></pre></div></div>
</div>
<p>The list of numerical results given in the output will be the same as those given using <code>NextBestMaxGain</code> class object which includes the next dose suggested, the current estimates of TD30, TD35 and Gstar and their corresponding dose levels at dose Grid. We can also see the plot:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb134" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb134-1">doseRecGainSamples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plot</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/nextbest-NextBestMaxGainSamplesplot-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A description of this graph is given in the text below."></p>
</figure>
</div>
</div>
</div>
<p>In this plot, the posterior distribution of Gstar is shown as a histogram. The vertical lines on the plot show all current estimates of TD30, TD35 and Gstar. In addition, the next dose and the maximum allowable dose are also given in blue and red lines, respectively.</p>
<p>Next, we will introduce some further <code>Stopping</code> rules that can be applied to the above two classes of escalation rules. After the escalation based on two responses and two separate pseudo DLT and efficacy models, we will select one dose, which is the minimum of the estimate of TD30 (TDtargetEndOfTrial) and the optimal gain dose (Gstar) as the recommended dose for potential further clinical trials. The main feature of these stopping rules is that the trial could be stopped if the current estimates of this selected quantity is ‘accurate’ enough. In particular, we will also consider the ratio of the 95% credibility interval bounds of its current estimate. The smaller this ratio, the more accurate is the estimate.</p>
<p>For example, we would like to stop our trial if the ratio is less than or equal to 5. The functions <code>StoppingMaxGainCIRatio</code> is used for this purpose:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb135" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb135-1">myStopping7 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMaxGainCIRatio</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target_ratio =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)</span>
<span id="cb135-2">myStopping8 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> myStopping7 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinPatients</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">72</span>)</span></code></pre></div></div>
</div>
<p>To note here, at the moment the class <code>stoppingMaxGainCIRatio</code> cannot be used together with other <code>stopping</code> class rules with the “and” operator <code>&amp;</code> and the <code>or</code> operator <code>|</code> (this is still under development).</p>
<p>Similarly, the <code>stopTrial</code> function can then be used in order to determine if the rule has been fulfilled:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb136" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb136-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb136-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping7, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecGain<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>next_dose, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> newDLTmodel,</span>
<span id="cb136-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data4, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Effmodel =</span> newEffmodel</span>
<span id="cb136-4">)</span>
<span id="cb136-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb136-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb136-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Gstar estimate is 79.7805 with 95% CI ( 21.5588 , 295.2361 ) and its ratio = 13.6945"               </span></span>
<span id="cb136-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [2] "TDtargetEndOfTrial estimate is  42.6813 with 95% CI ( 11.0662 , 164.618 ) and its ratio= 14.8758"   </span></span>
<span id="cb136-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [3] "TDtargetEndOfTrial estimate is smaller with ratio = 14.8758 which is  greater than target_ratio = 5"</span></span>
<span id="cb136-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb136-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "GStar 5 for 0.3 target prob"</span></span>
<span id="cb136-12"></span>
<span id="cb136-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb136-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping7,</span>
<span id="cb136-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecGainSamples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>next_dose,</span>
<span id="cb136-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> DLTpostsamples,</span>
<span id="cb136-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> newDLTmodel,</span>
<span id="cb136-18">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data4,</span>
<span id="cb136-19">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TDderive =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(TDsamples) {</span>
<span id="cb136-20">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">quantile</span>(TDsamples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)</span>
<span id="cb136-21">  },</span>
<span id="cb136-22">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Effmodel =</span> newEffmodel,</span>
<span id="cb136-23">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Effsamples =</span> Effpostsamples,</span>
<span id="cb136-24">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Gstarderive =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(Gstarsamples) {</span>
<span id="cb136-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">quantile</span>(Gstarsamples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb136-26">  }</span>
<span id="cb136-27">)</span>
<span id="cb136-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb136-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb136-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Gstar estimate is 50 with 95% CI ( 25 , 300 ) and its ratio = 12"                                          </span></span>
<span id="cb136-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [2] "TDtargetEndOfTrial estimate is  18.6612 with 95% CI ( 6e-04 , 10459.1345 ) and its ratio= 17110373.1537"   </span></span>
<span id="cb136-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [3] "TDtargetEndOfTrial estimate is smaller with ratio = 17110373.1537  which is  greater than target_ratio = 5"</span></span>
<span id="cb136-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb136-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "GStar 5 for 0.3 target prob"</span></span></code></pre></div></div>
</div>
<p>% For cases when either no or DLT and efficacy samples are involved.</p>
<p>Next, we will now look at how to construct the design objects. We will also start with an empty data set, the object <code>data3</code> of the <code>DataDual</code> class introduced in earlier examples.</p>
<p>There are two functions which we can used. The <code>DualResponsesDesign</code> can be used without MCMC samples, while <code>DualResponsesSamplesDesign</code> can be used when MCMC samples are involved. For example, we use the object <code>Effmodel</code> of the <code>Effloglog</code> class specified earlier as the efficacy model in the following code:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb137" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb137-1">design1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DualResponsesDesign</span>(</span>
<span id="cb137-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> GainNextBest,</span>
<span id="cb137-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> DLTmodel,</span>
<span id="cb137-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eff_model =</span> Effmodel,</span>
<span id="cb137-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2,</span>
<span id="cb137-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping7,</span>
<span id="cb137-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements1,</span>
<span id="cb137-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize,</span>
<span id="cb137-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span></span>
<span id="cb137-10">)</span>
<span id="cb137-11"></span>
<span id="cb137-12">design2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DualResponsesSamplesDesign</span>(</span>
<span id="cb137-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> GainsamplesNextBest,</span>
<span id="cb137-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> DLTmodel,</span>
<span id="cb137-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eff_model =</span> Effmodel,</span>
<span id="cb137-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2,</span>
<span id="cb137-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping8,</span>
<span id="cb137-18">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements1,</span>
<span id="cb137-19">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize,</span>
<span id="cb137-20">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span></span>
<span id="cb137-21">)</span></code></pre></div></div>
</div>
<p>We can use the function <code>DualResponsesSamplesDesign</code> to specify a design when an efficacy model is specified under the <code>EffFlexi</code> class object. For example, we use the object <code>Effmodel2</code> of the <code>EffFlexi</code> class specified in earlier examples here:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb138" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb138-1">design3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DualResponsesSamplesDesign</span>(</span>
<span id="cb138-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> GainsamplesNextBest,</span>
<span id="cb138-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> DLTmodel,</span>
<span id="cb138-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eff_model =</span> Effmodel2,</span>
<span id="cb138-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2,</span>
<span id="cb138-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping8,</span>
<span id="cb138-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements1,</span>
<span id="cb138-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize,</span>
<span id="cb138-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span></span>
<span id="cb138-10">)</span></code></pre></div></div>
</div>
<p>We specified the above three designs using all previous rules for nextBest (the escalation rule), stopping, increments and cohort size.</p>
<p>Next, we have to specify the scenarios for simulations. For example, for simulations using the DLT model and efficacy model from the <code>LogisticIndepBeta</code> and <code>Effloglog</code> objects, respectively, we can specify the scenario as below:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb139" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb139-1">myTruthDLT <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(DLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phi1 =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">53.66584</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phi2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">10.50499</span>)</span>
<span id="cb139-2">myTruthEff <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">efficacyFunction</span>(Effmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">theta1 =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.818429</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">theta2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.653058</span>)</span>
<span id="cb139-3"></span>
<span id="cb139-4">myTruthGain <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose) {</span>
<span id="cb139-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruthEff</span>(dose) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruthDLT</span>(dose)))</span>
<span id="cb139-6">}</span></code></pre></div></div>
</div>
<p>The true DLT, efficacy and gain curves can be obtained. We can see the corresponding curves as</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb140" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb140-1">TruthTD <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">doseFunction</span>(DLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phi1 =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">53.66584</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phi2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">10.50499</span>)</span>
<span id="cb140-2"></span>
<span id="cb140-3">GAIN <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(xi) {</span>
<span id="cb140-4">  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.8218429</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.653058</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(xi)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">53.66584</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">10.50499</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> xi))</span>
<span id="cb140-5">}</span>
<span id="cb140-6">Txi <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">optim</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, GAIN, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BFGS"</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>par)</span>
<span id="cb140-7">maxg <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">optim</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, GAIN, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BFGS"</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value)</span>
<span id="cb140-8">gstar <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(Txi)</span>
<span id="cb140-9">td30 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">TruthTD</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)</span>
<span id="cb140-10">td35 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">TruthTD</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>)</span>
<span id="cb140-11">DoseLevels <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb140-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(DoseLevels, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruthDLT</span>(DoseLevels),</span>
<span id="cb140-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"l"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Values"</span>,</span>
<span id="cb140-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruthEff</span>(DoseLevels))))</span>
<span id="cb140-15">)</span>
<span id="cb140-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">points</span>(td30, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb140-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">points</span>(td35, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb140-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(DoseLevels, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruthEff</span>(DoseLevels), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"l"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb140-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(DoseLevels, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruthGain</span>(DoseLevels), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"l"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb140-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">points</span>(gstar, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>maxg, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb140-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">legend</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"topright"</span>,</span>
<span id="cb140-22">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb140-23">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p(DLT)=0.3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p(DLT)=0.35"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max gain"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p(DLTs)"</span>,</span>
<span id="cb140-24">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"efficacy"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gain"</span></span>
<span id="cb140-25">  ), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text.col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>),</span>
<span id="cb140-26">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>)</span>
<span id="cb140-27">)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/Truecurves-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A description of this graph is given in the text below."></p>
</figure>
</div>
</div>
</div>
<p>Using all the above commands, we can obtained the DLT (red), efficacy(blue) and gain (green) curves and also their corresponding true values for the TD30 (TDtargetEndOfTrial), TD35 (TDtargetDuringTrial) and the Gstar. In addition, the above scenario for DLT and efficacy can be used for both cases (modal estimates or MCMC samples).</p>
<p>If the <code>EffFlexi</code> class object will be used for the simulations. Using the same DLT scenario and a new efficacy scenario will be specified such that</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb141" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb141-1">myTruthEff1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb141-2">  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5478867</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1645417</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5248031</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7604467</span>,</span>
<span id="cb141-3">  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9333009</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.0687031</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.1793942</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2726408</span>,</span>
<span id="cb141-4">  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.3529598</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.4233411</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.4858613</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5420182</span></span>
<span id="cb141-5">)</span>
<span id="cb141-6"></span>
<span id="cb141-7">d1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid</span>
<span id="cb141-8">myTruthGain1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> myTruthEff1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruthDLT</span>(d1))</span></code></pre></div></div>
</div>
<p>The corresponding curves can also be plotted as:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb142" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb142-1">maxg1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(myTruthGain1)</span>
<span id="cb142-2">gstar1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(myTruthGain1)]</span>
<span id="cb142-3">DoseLevels1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb142-4">TruthTD <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">doseFunction</span>(DLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phi1 =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">53.66584</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phi2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">10.50499</span>)</span>
<span id="cb142-5">td30 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">TruthTD</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)</span>
<span id="cb142-6">td35 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">TruthTD</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>)</span>
<span id="cb142-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(DoseLevels1, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruthDLT</span>(DoseLevels1),</span>
<span id="cb142-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"l"</span>,</span>
<span id="cb142-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Values"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(myTruthEff1)))</span>
<span id="cb142-10">)</span>
<span id="cb142-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">points</span>(td30, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb142-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">points</span>(td35, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb142-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(d1, myTruthEff1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"l"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb142-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(d1, myTruthGain1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"l"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb142-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">points</span>(gstar1, maxg1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb142-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">legend</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"topright"</span>,</span>
<span id="cb142-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb142-18">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p(DLT)=0.3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p(DLT)=0.35"</span>,</span>
<span id="cb142-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max gain"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p(DLTs)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"efficacy"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gain"</span></span>
<span id="cb142-20">  ), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text.col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb142-21">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>,</span>
<span id="cb142-22">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span></span>
<span id="cb142-23">  ), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>),</span>
<span id="cb142-24">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"violet"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"green3"</span>)</span>
<span id="cb142-25">)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/TruecurvesFlexi-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A description of this graph is given in the text below."></p>
</figure>
</div>
</div>
</div>
<p>Similarly, we also get the DLT, efficacy and gain values and the corresponding real values of the TD30, TD35 and Gstar.</p>
<p>Then after establishing the real scenarios, we can simulate the trials. First, we will look at two examples when the <code>Effloglog</code> class object is used as the efficacy model. We will show first an example when no MCMC samples are involved:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb143" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb143-1">Sim1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(</span>
<span id="cb143-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">object =</span> design1,</span>
<span id="cb143-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb143-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueDLE =</span> myTruthDLT,</span>
<span id="cb143-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueEff =</span> myTruthEff,</span>
<span id="cb143-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueNu =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.025</span>,</span>
<span id="cb143-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb143-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>,</span>
<span id="cb143-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb143-10">)</span></code></pre></div></div>
</div>
<p>The <code>simulate</code> function is used in all cases to simulate trials with specified scenarios. From the above, we specified the true precision (<code>trueNu</code>) of the efficacy responses be 1/0.025. In other words, we used a value of 0.025 as the true variance of the efficacy responses in this simulation. For the arguments <code>args</code>,<code>nsim</code>, <code>seed</code> and <code>parallel</code>, please refer to earlier examples for details for their specification and description details.</p>
<p>When MCMC samples are used, we can also specify the simulations in a similar way with an additional argument <code>mcmcOptions</code> such that we have</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb144" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb144-1">Sim2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(</span>
<span id="cb144-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">object =</span> design2,</span>
<span id="cb144-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb144-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueDLE =</span> myTruthDLT,</span>
<span id="cb144-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueEff =</span> myTruthEff,</span>
<span id="cb144-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueNu =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.025</span>,</span>
<span id="cb144-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb144-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>,</span>
<span id="cb144-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> options,</span>
<span id="cb144-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb144-11">)</span></code></pre></div></div>
</div>
<p>When the <code>EffFlexi</code> class object is used as the efficacy model, we will generate the simulations as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb145" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb145-1">Sim3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(</span>
<span id="cb145-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">object =</span> design3,</span>
<span id="cb145-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb145-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueDLE =</span> myTruthDLT,</span>
<span id="cb145-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueEff =</span> myTruthEff1,</span>
<span id="cb145-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueSigma2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.025</span>,</span>
<span id="cb145-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueSigma2betaW =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb145-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> options,</span>
<span id="cb145-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb145-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>,</span>
<span id="cb145-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb145-12">)</span></code></pre></div></div>
</div>
<p>For the specification of the arguments <code>object</code>, <code>args</code>, <code>trueDLE</code>, <code>trueEff</code>, <code>mcmcOptions</code>,<code>nsim</code>,<code>seed</code>,<code>parallel</code> please refer to earlier examples for details. In addition, two arguments have to be used when the <code>EffFlexi</code> class efficacy model is used for the simulations: First, <code>trueSigma2</code> has to be specified as the true variance of the efficacy responses and <code>trueSigma2betaW</code> as the true variance of the random walk model to be used in the simulation.</p>
<p>Furthermore, we can also plot, summarize and plot the summary of the simulated results using <code>plot</code> and <code>summary</code> function:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb146" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb146-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(Sim1)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plotsimulationresults1-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A description of the Sim1 object."></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb147" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb147-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(Sim2)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plotsimulationresults2-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A description of the Sim2 object."></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb148" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb148-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(Sim3)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/plotsimulationresults3-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A description of the Sim3 object."></p>
</figure>
</div>
</div>
</div>
<p>The plots give an overview of the final dose recommendations and trial trajectories. In addition, they also give a summary of the efficacy variance and also the random walk model variance when the <code>EffFlexi</code> class object is used for the efficacy model.</p>
<p>Then, the summary and the plot of the summary of the simulations can be obtained by:</p>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb149" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb149-1">Sum1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(Sim1,</span>
<span id="cb149-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueDLE =</span> myTruthDLT,</span>
<span id="cb149-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueEff =</span> myTruthEff</span>
<span id="cb149-4">)</span>
<span id="cb149-5">Sum1</span>
<span id="cb149-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 10 simulations</span></span>
<span id="cb149-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb149-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target probability of DLE p(DLE) used at the end of a trial was 30 %</span></span>
<span id="cb149-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The dose level corresponds to the target p(DLE) used at the end of a trial, TDEOT, was 152.6195 </span></span>
<span id="cb149-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; TDEOT at dose Grid was 150 </span></span>
<span id="cb149-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target p(DLE) used during a trial was 35 %</span></span>
<span id="cb149-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The dose level corresponds to the target p(DLE) used during a trial, TDDT, was 155.972 </span></span>
<span id="cb149-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; TDDT at dose Grid was 150 </span></span>
<span id="cb149-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 16 (15, 19) </span></span>
<span id="cb149-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above the target p(DLE) used at the end of a trial : mean 3 (3, 3) </span></span>
<span id="cb149-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above the target p(DLE) used during a trial : mean 3 (3, 3) </span></span>
<span id="cb149-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of observed DLT in the trials : mean 21 % (20 %, 23 %) </span></span>
<span id="cb149-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients : mean 21 % (20 %, 21 %) </span></span>
<span id="cb149-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as TDEOT : mean 100 (97.5, 102.5) </span></span>
<span id="cb149-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at TDEOT : mean 1 % (0 %, 1 %) </span></span>
<span id="cb149-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting the TDEOT: 0 %</span></span>
<span id="cb149-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting the TDDT: 0 %</span></span>
<span id="cb149-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as TDEOT: 100 </span></span>
<span id="cb149-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 0 %</span></span>
<span id="cb149-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted probabilities of DLE at dose most often selected : mean 24 % (24 %, 24 %) </span></span>
<span id="cb149-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final TDEOT across all simulations</span></span>
<span id="cb149-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb149-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    98.18  123.81  123.81  122.23  123.81  133.63  </span></span>
<span id="cb149-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the TDEOT across all simulations</span></span>
<span id="cb149-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb149-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    3.849   4.447   4.447   4.442   4.447   4.993  </span></span>
<span id="cb149-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final TDDT across all simulations</span></span>
<span id="cb149-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb149-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    118.2   144.4   144.4   143.5   144.4   161.5  </span></span>
<span id="cb149-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of dose levels, the optimal dose</span></span>
<span id="cb149-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  to recommend for subsequent study across all simulations</span></span>
<span id="cb149-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb149-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    98.18  123.81  123.81  122.23  123.81  133.63  </span></span>
<span id="cb149-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the optimal dose for stopping across</span></span>
<span id="cb149-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                   all simulations</span></span>
<span id="cb149-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb149-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    3.849   4.447   4.447   4.442   4.447   4.993  </span></span>
<span id="cb149-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb149-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb149-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  GStar 5 for 0.3 target prob :  100 %</span></span>
<span id="cb149-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target Gstar, the dose which gives the maximum gain value was 130.0097 </span></span>
<span id="cb149-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target Gstar at dose Grid was 125 </span></span>
<span id="cb149-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final Gstar across all simulations</span></span>
<span id="cb149-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb149-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    142.9   146.7   152.1   152.6   153.1   178.6  </span></span>
<span id="cb149-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the Gstar across all simulations</span></span>
<span id="cb149-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb149-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    6.807   6.985   7.188   7.691   7.472  10.729  </span></span>
<span id="cb149-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of dose levels, the optimal dose</span></span>
<span id="cb149-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  to recommend for subsequent study across all simulations</span></span>
<span id="cb149-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb149-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    98.18  123.81  123.81  122.23  123.81  133.63  </span></span>
<span id="cb149-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the optimal dose for stopping across</span></span>
<span id="cb149-59"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;         all simulations</span></span>
<span id="cb149-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb149-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    3.849   4.447   4.447   4.442   4.447   4.993  </span></span>
<span id="cb149-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted expected efficacy level at dose most often selected : mean 0.9 (0.9, 1) </span></span>
<span id="cb149-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb149-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  GStar 5 for 0.3 target prob :  100 %</span></span>
<span id="cb149-65"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(Sum1))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/summarysimulationresults1-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A description of the summary of the Sim1 object."></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb150" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb150-1">Sum2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(Sim2,</span>
<span id="cb150-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueDLE =</span> myTruthDLT,</span>
<span id="cb150-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueEff =</span> myTruthEff</span>
<span id="cb150-4">)</span>
<span id="cb150-5">Sum2</span>
<span id="cb150-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 10 simulations</span></span>
<span id="cb150-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb150-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target probability of DLE p(DLE) used at the end of a trial was 30 %</span></span>
<span id="cb150-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The dose level corresponds to the target p(DLE) used at the end of a trial, TDEOT, was 152.6195 </span></span>
<span id="cb150-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; TDEOT at dose Grid was 150 </span></span>
<span id="cb150-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target p(DLE) used during a trial was 35 %</span></span>
<span id="cb150-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The dose level corresponds to the target p(DLE) used during a trial, TDDT, was 155.972 </span></span>
<span id="cb150-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; TDDT at dose Grid was 150 </span></span>
<span id="cb150-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 45 (36, 51) </span></span>
<span id="cb150-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above the target p(DLE) used at the end of a trial : mean 8 (3, 12) </span></span>
<span id="cb150-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above the target p(DLE) used during a trial : mean 8 (3, 12) </span></span>
<span id="cb150-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of observed DLT in the trials : mean 19 % (17 %, 20 %) </span></span>
<span id="cb150-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients : mean 19 % (15 %, 25 %) </span></span>
<span id="cb150-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as TDEOT : mean 120 (100, 125) </span></span>
<span id="cb150-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at TDEOT : mean 4 % (1 %, 5 %) </span></span>
<span id="cb150-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting the TDEOT: 0 %</span></span>
<span id="cb150-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting the TDDT: 0 %</span></span>
<span id="cb150-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as TDEOT: 125 </span></span>
<span id="cb150-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 6 %</span></span>
<span id="cb150-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted probabilities of DLE at dose most often selected : mean 25 % (23 %, 27 %) </span></span>
<span id="cb150-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final TDEOT across all simulations</span></span>
<span id="cb150-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb150-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    115.0   127.6   135.9   132.4   138.6   143.8  </span></span>
<span id="cb150-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the TDEOT across all simulations</span></span>
<span id="cb150-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb150-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        1       1       1       1       1       1  </span></span>
<span id="cb150-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final TDDT across all simulations</span></span>
<span id="cb150-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb150-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    133.2   151.0   155.9   154.2   159.3   168.8  </span></span>
<span id="cb150-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of dose levels, the optimal dose</span></span>
<span id="cb150-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  to recommend for subsequent study across all simulations</span></span>
<span id="cb150-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb150-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    115.0   127.6   135.9   132.4   138.6   143.8  </span></span>
<span id="cb150-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the optimal dose for stopping across</span></span>
<span id="cb150-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                   all simulations</span></span>
<span id="cb150-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb150-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        1       1       1       1       1       1  </span></span>
<span id="cb150-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb150-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb150-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  GStar 5 for 0.3 target prob :  100 %</span></span>
<span id="cb150-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 72 patients dosed :  0 %</span></span>
<span id="cb150-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target Gstar, the dose which gives the maximum gain value was 130.0097 </span></span>
<span id="cb150-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target Gstar at dose Grid was 125 </span></span>
<span id="cb150-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final Gstar across all simulations</span></span>
<span id="cb150-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb150-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    150.0   175.0   187.5   182.5   200.0   200.0  </span></span>
<span id="cb150-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the Gstar across all simulations</span></span>
<span id="cb150-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb150-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;      2.4     2.4     2.4     2.4     2.4     2.4  </span></span>
<span id="cb150-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of dose levels, the optimal dose</span></span>
<span id="cb150-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  to recommend for subsequent study across all simulations</span></span>
<span id="cb150-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb150-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    115.0   127.6   135.9   132.4   138.6   143.8  </span></span>
<span id="cb150-59"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the optimal dose for stopping across</span></span>
<span id="cb150-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;         all simulations</span></span>
<span id="cb150-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb150-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        1       1       1       1       1       1  </span></span>
<span id="cb150-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted expected efficacy level at dose most often selected : mean 1 (1, 1) </span></span>
<span id="cb150-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb150-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  GStar 5 for 0.3 target prob :  100 %</span></span>
<span id="cb150-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 72 patients dosed :  0 %</span></span>
<span id="cb150-67"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(Sum2))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/summarysimulationresults2-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A description of the summary of the Sim2 object."></p>
</figure>
</div>
</div>
</div>
<div class="cell" data-fig="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb151" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb151-1">Sum3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(Sim3,</span>
<span id="cb151-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueDLE =</span> myTruthDLT,</span>
<span id="cb151-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueEff =</span> myTruthEff1</span>
<span id="cb151-4">)</span>
<span id="cb151-5">Sum3</span>
<span id="cb151-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 10 simulations</span></span>
<span id="cb151-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb151-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target probability of DLE p(DLE) used at the end of a trial was 30 %</span></span>
<span id="cb151-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The dose level corresponds to the target p(DLE) used at the end of a trial, TDEOT, was 152.6195 </span></span>
<span id="cb151-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; TDEOT at dose Grid was 150 </span></span>
<span id="cb151-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target p(DLE) used during a trial was 35 %</span></span>
<span id="cb151-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The dose level corresponds to the target p(DLE) used during a trial, TDDT, was 155.972 </span></span>
<span id="cb151-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; TDDT at dose Grid was 150 </span></span>
<span id="cb151-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 50 (39, 58) </span></span>
<span id="cb151-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above the target p(DLE) used at the end of a trial : mean 8 (6, 12) </span></span>
<span id="cb151-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above the target p(DLE) used during a trial : mean 8 (6, 12) </span></span>
<span id="cb151-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of observed DLT in the trials : mean 21 % (18 %, 24 %) </span></span>
<span id="cb151-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients : mean 20 % (15 %, 24 %) </span></span>
<span id="cb151-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as TDEOT : mean 115 (100, 125) </span></span>
<span id="cb151-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at TDEOT : mean 3 % (1 %, 5 %) </span></span>
<span id="cb151-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting the TDEOT: 0 %</span></span>
<span id="cb151-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting the TDDT: 0 %</span></span>
<span id="cb151-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as TDEOT: 125 </span></span>
<span id="cb151-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 4 %</span></span>
<span id="cb151-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted probabilities of DLE at dose most often selected : mean 27 % (25 %, 28 %) </span></span>
<span id="cb151-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final TDEOT across all simulations</span></span>
<span id="cb151-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb151-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    113.1   123.7   127.0   127.0   130.0   137.2  </span></span>
<span id="cb151-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the TDEOT across all simulations</span></span>
<span id="cb151-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb151-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        1       1       1       1       1       1  </span></span>
<span id="cb151-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final TDDT across all simulations</span></span>
<span id="cb151-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb151-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    128.9   143.6   149.2   149.0   154.4   169.5  </span></span>
<span id="cb151-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of dose levels, the optimal dose</span></span>
<span id="cb151-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  to recommend for subsequent study across all simulations</span></span>
<span id="cb151-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb151-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    113.1   123.7   127.0   127.0   130.0   137.2  </span></span>
<span id="cb151-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the optimal dose for stopping across</span></span>
<span id="cb151-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                   all simulations</span></span>
<span id="cb151-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb151-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        1       1       1       1       1       1  </span></span>
<span id="cb151-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb151-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb151-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  GStar 5 for 0.3 target prob :  100 %</span></span>
<span id="cb151-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 72 patients dosed :  0 %</span></span>
<span id="cb151-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target Gstar, the dose which gives the maximum gain value was 125 </span></span>
<span id="cb151-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target Gstar at dose Grid was 125 </span></span>
<span id="cb151-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final Gstar across all simulations</span></span>
<span id="cb151-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb151-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    250.0   250.0   250.0   262.5   275.0   300.0  </span></span>
<span id="cb151-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the Gstar across all simulations</span></span>
<span id="cb151-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb151-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    1.333   1.500   1.857   1.938   2.000   3.000  </span></span>
<span id="cb151-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of dose levels, the optimal dose</span></span>
<span id="cb151-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  to recommend for subsequent study across all simulations</span></span>
<span id="cb151-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb151-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    113.1   123.7   127.0   127.0   130.0   137.2  </span></span>
<span id="cb151-59"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The summary table of the final ratios of the optimal dose for stopping across</span></span>
<span id="cb151-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;         all simulations</span></span>
<span id="cb151-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  </span></span>
<span id="cb151-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        1       1       1       1       1       1  </span></span>
<span id="cb151-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted expected efficacy level at dose most often selected : mean 0.9 (0.9, 1) </span></span>
<span id="cb151-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb151-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  GStar 5 for 0.3 target prob :  100 %</span></span>
<span id="cb151-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 72 patients dosed :  0 %</span></span>
<span id="cb151-67"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(Sum3))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/examples/crmPack_example/index_files/figure-html/summarysimulationresults3-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A description of the summary of the Sim3 object."></p>
</figure>
</div>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb152" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb152-1"></span>
<span id="cb152-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># nolint end</span></span></code></pre></div></div>
</div>
<p>In the first simulation, <code>Sim1</code> the trial will only stop when the ratio of the 95% credibility interval bounds of the current estimate of the minimum between TD30(TDtargetEndOfTrial) and Gstar is less than or equal to 5. The last two simulations, <code>Sim2</code> and <code>Sim3</code>, use trials which only stop either when a maximum of 72 patients has been treated or when the ratio of the 95% credibility interval is less than or equal to 5. We can see that in all of the above simulations all trials require a total of around 60 patients for a study.</p>
<p>As a reminder, for the dual endpoint dose escalation design which uses two separate models to describe the dose-responses relationship, the gain function is used to determine the next best dose and the final recommended dose at the end of a trial. More specifically at the end of a trial, we will recommend the dose level closest below which is the minimum of final estimate of the TD30 (TDtargetEndOfTrial) and Gstar.</p>
<p>The DLT and efficacy scenario that we used for the first, <code>Sim1</code> and the second simulations, <code>Sim2</code> are the same. The real TD30 (TDtargetEndOfTrial) is given in the summary and is 152.6125 mg and the dose level at doseGrid which is closest and below this real TD30 is 150 mg. The real Gstar is 130.0097 mg and the dose level in the dose grid closest to this Gstar is 125 mg.</p>
<p>In this case, the real Gstar is less than the real TD30 and we will expect most of the recommendations to be made at a dose level close to the real Gstar. In other words, under this scenario, we will expect most of the recommendations made at 125 mg. We can see that the simulated results agrees to what we are expecting. From the summaries and the plots of the summaries, 125 mg is the dose level which is selected most often in both of these simulations.</p>
<p>For the scenario of last simulation, <code>Sim3</code>, we have the same real TD30 and the real Gstar is 125 mg. Since the real TD30 is greater than the real Gstar, we will also expect recommendations should be made close to the real Gstar under this scenario. We can see that from the simulated results in the summary or the plot of summary, the procedure also recommends 125 mg most often in the simulations, which agrees with our real scenario.</p>
<p>Now, we will also look at the fitted dose-DLT and dose-efficacy curves obtained under all these three simulations. From the plots of summaries, we can see that in all cases, the fitted dose-DLT curves (solid-red curve) do not approximate very well to the real dose-DLT curve (solid-black curve). The 95% credibility interval of the DLT curve (broken-red curves) is also given when MCMC samples are involved in the simulation. In contrast, we can see that the fitted efficacy curve (solid-blue curve) gives a very good fit to the real efficacy curve (solid-black) in all cases. The approximation to the real efficacy curve is better when the linear linear log-log model, <code>Effloglog</code> is used, compared to when the flexible form , <code>EffFlexi</code> is used. In addition, we can also see the 95% credibility interval of the efficacy curve (broken-blue line) when MCMC sampling of the efficacy responses is involved.</p>
</section>
</section>
<section id="references" class="level1">




</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-Neuenschwander2008" class="csl-entry">
Neuenschwander, Beat, Michael Branson, and Thomas Gsponer. 2008. <span>“<span class="nocase">Critical aspects of the Bayesian approach to phase I cancer trials.</span>”</span> <em>Statistics in Medicine</em> 27 (13): 2420–39. <a href="https://onlinelibrary.wiley.com/doi/10.1002/sim.3230">https://onlinelibrary.wiley.com/doi/10.1002/sim.3230</a>.
</div>
<div id="ref-WhiteheadWilliamson1998" class="csl-entry">
Whitehead, J., and D. Williamson. 1998. <span>“<span class="nocase">Bayesian decision procedures based on logistic regression models for dose-finding studies</span>.”</span> <em>Journal of Biopharmaceutical Statistics</em> 8 (3): 445–67.
</div>
<div id="ref-wy15" class="csl-entry">
Yeung, W. Y., J. Whitehead, B. Reigner, U. Beyer, C. Diack, and T. Jaki. 2015. <span>“Bayesian Adaptive Dose-Escalation Procedure for Binary and Continuous Responses Utilizing a Gain Function.”</span> <em>Pharmaceutical Statistics</em>.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Examples</category>
  <guid>https://www.crmpack.org/vignettes/examples/crmPack_example/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_02.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Time-to-event continual reassessment method (TITE-CRM) example</title>
  <dc:creator>Ziwei Liao, Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/examples/crmPack_tite/</link>
  <description><![CDATA[ 




<section id="simulation-setting" class="level2">
<h2 class="anchored" data-anchor-id="simulation-setting">Simulation setting</h2>
<p>Here the simulation study setting is defined.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb1-2">onset <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb1-3">a0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb1-4">a1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb1-5">refDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">56</span></span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># True dose-DLT relationship</span></span>
<span id="cb1-8">myTruth <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose) {</span>
<span id="cb1-9">  StandLogDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(dose <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> refDose)</span>
<span id="cb1-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plogis</span>(a0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> a1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> StandLogDose)</span>
<span id="cb1-11">}</span>
<span id="cb1-12"></span>
<span id="cb1-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># The conditional CDF of the PEM</span></span>
<span id="cb1-14"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (onset <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>) {</span>
<span id="cb1-15">  onset <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span></span>
<span id="cb1-16">  exp_cond_cdf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb1-17">    (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pexp</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> onset, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lower.tail =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pexp</span>(t_max, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> onset, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lower.tail =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pexp</span>(t_max, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> onset)</span>
<span id="cb1-18">  }</span>
<span id="cb1-19">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb1-20">  exp_cond_cdf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb1-21">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pexp</span>(x, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> onset, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lower.tail =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pexp</span>(t_max, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> onset, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lower.tail =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pexp</span>(t_max, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> onset)</span>
<span id="cb1-22">  }</span>
<span id="cb1-23">}</span></code></pre></div></div>
</div>
</section>
<section id="design-definition" class="level2">
<h2 class="anchored" data-anchor-id="design-definition">Design definition</h2>
<p>Here the the dose escalation designs are defined: in this example the TITE-CRM is used. Similarly the code can be adapted for the rolling-CRM, see the separate vignette <a href="../crmPack_rolling/rolling-crm.html">here</a>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(crmPack)</span>
<span id="cb2-2">t_max <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span></span>
<span id="cb2-3"></span>
<span id="cb2-4">model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">TITELogisticLogNormal</span>(</span>
<span id="cb2-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.33</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.49</span>),</span>
<span id="cb2-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.826</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.0209</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.0209</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.0245</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb2-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ref_dose =</span> refDose</span>
<span id="cb2-8">)</span>
<span id="cb2-9"></span>
<span id="cb2-10">myIncrements <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelative</span>(</span>
<span id="cb2-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>),</span>
<span id="cb2-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb2-13">)</span>
<span id="cb2-14"></span>
<span id="cb2-15">myNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestMTD</span>(</span>
<span id="cb2-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,</span>
<span id="cb2-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">derive =</span></span>
<span id="cb2-18">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(mtd_samples) {</span>
<span id="cb2-19">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(mtd_samples)</span>
<span id="cb2-20">    }</span>
<span id="cb2-21">)</span>
<span id="cb2-22"></span>
<span id="cb2-23">myStopping <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinPatients</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">48</span>)</span>
<span id="cb2-24"></span>
<span id="cb2-25">mySize <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb2-26"></span>
<span id="cb2-27">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataDA</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Tmax =</span> t_max)</span>
<span id="cb2-28"></span>
<span id="cb2-29">mysafetywindow <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">SafetyWindowConst</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>)</span>
<span id="cb2-30"></span>
<span id="cb2-31">design <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DADesign</span>(</span>
<span id="cb2-32">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb2-33">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements,</span>
<span id="cb2-34">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> myNextBest,</span>
<span id="cb2-35">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping,</span>
<span id="cb2-36">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize,</span>
<span id="cb2-37">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> emptydata,</span>
<span id="cb2-38">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">safetyWindow =</span> mysafetywindow,</span>
<span id="cb2-39">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span></span>
<span id="cb2-40">)</span></code></pre></div></div>
</div>
</section>
<section id="simulation-run" class="level2">
<h2 class="anchored" data-anchor-id="simulation-run">Simulation run</h2>
<p>In order to obtain stable results, increase the simulation parameters appropriately (<code>burnin</code>, <code>step</code>, <code>samples</code>, <code>nsim</code>).</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb3-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>,</span>
<span id="cb3-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span></span>
<span id="cb3-5">)</span>
<span id="cb3-6">mySims <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(design,</span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truthTox =</span> myTruth,</span>
<span id="cb3-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truthSurv =</span> exp_cond_cdf,</span>
<span id="cb3-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueTmax =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span>,</span>
<span id="cb3-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb3-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>,</span>
<span id="cb3-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> options,</span>
<span id="cb3-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb3-15">)</span></code></pre></div></div>
</div>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Examples</category>
  <guid>https://www.crmpack.org/vignettes/examples/crmPack_tite/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_05.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Analyzing an ongoing dose escalation trial</title>
  <dc:creator>John Kirkpatrick, Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/</link>
  <description><![CDATA[ 




<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>This vignette picks up where the <a href="../crmPack_design/trial_definition.html">Trial Definition</a> vignette ends. To recap, our trial defines the six fundamental elements of a CRM trial as:</p>
<section id="the-dose-grid" class="level4">
<h4 class="anchored" data-anchor-id="the-dose-grid">The dose grid</h4>
<p>The trial will use a dose grid consisting of the following doses: 1, 3, 9, 20, 30, 45, 60, 80 and 100. The units in which doses are defined is irrelevant to the operation of the CRM.</p>
</section>
<section id="the-dose-toxicity-model" class="level4">
<h4 class="anchored" data-anchor-id="the-dose-toxicity-model">The dose-toxicity model</h4>
<p>The trial uses a logistic log Normal dose toxicity model</p>
<p><img src="https://latex.codecogs.com/png.latex?%20log(%5Cfrac%7Bp_i%7D%7B1%20-%20p_i%7D)%20=%20%5Calpha%20+%20%5Cbeta%20log(d_i%20/%20d%5E*)%20"></p>
<p>where the prior joint distribution of <img src="https://latex.codecogs.com/png.latex?%5Calpha"> and <img src="https://latex.codecogs.com/png.latex?%5Cbeta"> is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Bbmatrix%7D%0A%5Calpha%20%5C%5C%0Alog(%5Cbeta)%0A%5Cend%7Bbmatrix%7D%20%20%20%5Csim%0AN%5Cbegin%7Bpmatrix%7D%0A%5Cbegin%7Bbmatrix%7D%0A-0.85%5C%5C0%0A%5Cend%7Bbmatrix%7D%20%20%20,%0A%5Cbegin%7Bbmatrix%7D%0A1%20&amp;%20-0.5%20%5C%5C%0A-0.5%20&amp;%201%0A%5Cend%7Bbmatrix%7D%20%20%20%0A%5Cend%7Bpmatrix%7D.%0A"></p>
</section>
<section id="the-increment-rule" class="level4">
<h4 class="anchored" data-anchor-id="the-increment-rule">The increment rule</h4>
<p>The maximum increment for doses greater than <code>0</code> and less than <code>20</code> is 100 x (1 + 1)%, or 200% of the highest dose used so far, whereas for <code>20</code> or more, the maximum increment is 100 x (1 + 0.5)%, or 150% of the highest dose used so far.</p>
<p>Note that a 2-fold <em>increment</em> corresponds to a 3-fold <em>escalation</em>.</p>
</section>
<section id="the-dose-selection-rule" class="level4">
<h4 class="anchored" data-anchor-id="the-dose-selection-rule">The dose selection rule</h4>
<p>Here, we choose to use Neuenschwander’s rule <span class="citation" data-cites="Neuenschwander2008">(Neuenschwander, Branson, and Gsponer 2008)</span>, in which the dose for the next cohort to be the dose (amongst those doses that are eligible for selection according to the escalation rule) that has the highest posterior chance of having a probability of toxicity in the target range - here [0.2, 0.35) - provided that the dose’s chance of having a probability in the overdose range - here [0.35, 1.0] - is less than 0.25.</p>
</section>
<section id="the-cohort-size" class="level4">
<h4 class="anchored" data-anchor-id="the-cohort-size">The cohort size</h4>
<p>Whilst the dose for the next cohort is 20 or less <em>and</em> no DLTs have been observed, the minimum cohort size is 1. Otherwise, it is 3.</p>
</section>
<section id="the-stopping-rule" class="level4">
<h4 class="anchored" data-anchor-id="the-stopping-rule">The stopping rule</h4>
<p>The trial will stop when <i>either</i></p>
<ul>
<li>Twenty patients have been recruited, or.</li>
<li>Both of the following conditions are true
<ul>
<li>At least three cohorts must have been treated AND</li>
<li>The probability that the current estimate of the MTD is in the target toxicity range must be at least 0.5.</li>
</ul></li>
</ul>
</section>
<section id="trial-definition" class="level4">
<h4 class="anchored" data-anchor-id="trial-definition">Trial definition</h4>
<p>The code to define these elements of the trial design is given in the <a href="trial_definition.Rmd">Trial Definition</a> vignette.</p>
</section>
</section>
<section id="analysing-a-trial" class="level2">
<h2 class="anchored" data-anchor-id="analysing-a-trial">Analysing a trial</h2>
<p>Given the trial design constructed above, the process of analysing a real life instance of the trial is simply a matter of providing the model with the actual toxicity status of the participants treated so far. The escalation rules we defined earlier allow the use of a single patient run-in until either the first DLT is observed or until dose 20 has been administered.</p>
<section id="the-single-patient-run-in" class="level3">
<h3 class="anchored" data-anchor-id="the-single-patient-run-in">The single patient run-in</h3>
<p>Assume that the first three patients - dosed at <code>1</code>, <code>3</code>, and <code>9</code> - completed the trial without incident, but that the fourth patient - treated at <code>20</code> - experienced a DLT.</p>
<p>We provide this information to <code>crmPack</code> via a <code>Data</code> object:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">firstFour <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb1-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>),</span>
<span id="cb1-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb1-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb1-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb1-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> doseGrid</span>
<span id="cb1-7">)</span></code></pre></div></div>
</div>
<p>Within a <code>Data</code> object, the doses at which each patient is treated are given by the <code>x</code> slot and their toxicity status (a Boolean where a toxicity is represented by a truthy value) by the <code>y</code> slot.</p>
<p>The observed data is easily visualised</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(firstFour)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/index_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A visual representation of the data from the first four participants.  The first three, treated at doses 1, 3 and 9, do not report any toxicities.  The fourth, treated at 20, does."></p>
</figure>
</div>
</div>
</div>
<p>and, since the <code>plot</code> method returns a <code>ggplot</code> object, it is easily customised.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(firstFour) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_light</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/index_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid figure-img" style="width:100.0%" alt="The same graph as above, but with a white background to the plot area rather than a grey one."></p>
</figure>
</div>
</div>
</div>
<p>We first define the MCMC options, explicitly setting a seed and the kind for the random number generator, in order to make sure that the results are reproducible:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">vignetteMcmcOptions <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb4-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb4-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb4-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb4-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rng_seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">321</span>,</span>
<span id="cb4-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rng_kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wichmann-Hill"</span></span>
<span id="cb4-7">)</span></code></pre></div></div>
</div>
<p>Note that in practice one would use larger numbers for <code>burnin</code> and <code>samples</code> than those used here for the sake of saving computation time on the CRAN checks.</p>
<p>Now, we can update the model to obtain the posterior estimate of the dose-toxicity curve:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">postSamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(</span>
<span id="cb5-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> firstFour,</span>
<span id="cb5-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb5-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> vignetteMcmcOptions</span>
<span id="cb5-5">)</span></code></pre></div></div>
</div>
<p>The posterior estimate of the dose toxicity curve is easily visualised:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(postSamples, model, firstFour)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/index_files/figure-html/unnamed-chunk-8-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A plot of the posterior after the first four participants.  The mean probability of toxicity increases smoothly, with a slight convex curve, from about zero percent at a dose of zero to about 65% at a dose of 100.  The confidence interval extends from 0% to about 25% at a dose of zero and from about 30% to  about 90% at a dose of 100."></p>
</figure>
</div>
</div>
</div>
<p>A visual representation of the model’s state is obtained with:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb7-2">  my_next_best,</span>
<span id="cb7-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb7-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> postSamples,</span>
<span id="cb7-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb7-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> empty_data</span>
<span id="cb7-7">)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plot</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/index_files/figure-html/unnamed-chunk-9-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two graphs arranged in a single column.  The upper graph shoes green lines of various heights that show the probability each dose is in the target toxicity range.  There is a big arrow pointing to the bar at a dose of 20, indicating tat this dose has the highest probability of being in the target toxicity range.  The lower graph as a similar series of red lines, indicating the probability that each dose is in the overdose range.  There is a horizontal black dashed line at 25%, indicating that this is the highest acceptable probability of being in the overdose range.  The red bars for doses of 30 and above all extend above 25%, indicating that their toxicity is unacceptable.  The toxicity for doses of 20 and below lie below 25%."></p>
</figure>
</div>
</div>
</div>
<p>The lower panel of the plot shows the posterior probability that each dose is in the overdose range. The dashed horizontal black line shows the acceptable risk of overdose: Doses with red lines which go above this line are considered toxic. The upper panel shows the probability that each dose is in the target toxicity range. Clearly, doses of <code>30</code> and <code>45</code> have the highest probability of being in the target toxicity range. However, the risk that both are in the overdose range is unacceptable. Therefore, <code>20</code> is the dose recommended for the next cohort.</p>
<p>We can produce a tabulation of the model state with</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">tabulatePosterior <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(mcmcSamples, observedData) {</span>
<span id="cb8-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as_tibble</span>(</span>
<span id="cb8-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb8-4">      my_next_best,</span>
<span id="cb8-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb8-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> mcmcSamples,</span>
<span id="cb8-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb8-8">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> observedData</span>
<span id="cb8-9">    )<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>probs</span>
<span id="cb8-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(</span>
<span id="cb8-12">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb8-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> observedData<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>x,</span>
<span id="cb8-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">WithDLT =</span> observedData<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>y</span>
<span id="cb8-15">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-16">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(dose) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-17">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb8-18">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Treated =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb8-19">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">WithDLT =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(WithDLT),</span>
<span id="cb8-20">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb8-21">        ),</span>
<span id="cb8-22">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dose"</span></span>
<span id="cb8-23">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace_na</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Treated =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">WithDLT =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(dose, Treated, WithDLT, target, overdose) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-26">    kableExtra<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(</span>
<span id="cb8-27">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dose"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treated"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"With DLT"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Target range"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Overdose range"</span>),</span>
<span id="cb8-28">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb8-29">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-30">    kableExtra<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_header_above</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Participants"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Probability that dose is in "</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb8-31">}</span>
<span id="cb8-32"></span>
<span id="cb8-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tabulatePosterior</span>(postSamples, firstFour)</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Participants
</div></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Probability that dose is in
</div></th>
</tr>
<tr class="even">
<th style="text-align: right;" data-quarto-table-cell-role="th">Dose</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Treated</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">With DLT</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Target range</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Overdose range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.027</td>
<td style="text-align: right;">0.009</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.051</td>
<td style="text-align: right;">0.021</td>
</tr>
<tr class="odd">
<td style="text-align: right;">9</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.174</td>
<td style="text-align: right;">0.061</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.266</td>
<td style="text-align: right;">0.200</td>
</tr>
<tr class="odd">
<td style="text-align: right;">30</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.378</td>
<td style="text-align: right;">0.367</td>
</tr>
<tr class="even">
<td style="text-align: right;">45</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.286</td>
<td style="text-align: right;">0.613</td>
</tr>
<tr class="odd">
<td style="text-align: right;">60</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.152</td>
<td style="text-align: right;">0.826</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.073</td>
<td style="text-align: right;">0.918</td>
</tr>
<tr class="odd">
<td style="text-align: right;">100</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.052</td>
<td style="text-align: right;">0.948</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>From these presentations, we can see that:</p>
<ol type="1">
<li>The highest dose so far administered is <code>20</code>, so the escalation rule permits doses up to and including <code>40</code> to be considered as the dose for the next cohort. However…</li>
<li>Doses of <code>30</code> and above are considered unsafe</li>
<li>Of the remaining doses, <code>20</code> has the highest posterior probability of being in the target toxicity range</li>
<li>A DLT has been reported</li>
</ol>
<p>Items 1 and 4 in the list tell us both that the size of the next cohort should be three. Items 2 and 3 together imply that the highest dose that can be used in the next cohort is <code>20</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">nextMaxDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(my_increments, firstFour)</span>
<span id="cb9-2">nextMaxDose</span>
<span id="cb9-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 40</span></span>
<span id="cb9-4"></span>
<span id="cb9-5">doseRecommendation <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb9-6">  my_next_best,</span>
<span id="cb9-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> nextMaxDose,</span>
<span id="cb9-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> postSamples,</span>
<span id="cb9-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb9-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> firstFour</span>
<span id="cb9-11">)</span>
<span id="cb9-12">doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb9-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 20</span></span></code></pre></div></div>
</div>
<p>Thus, the model’s recommendation is that the next cohort should consist of three patients, each treated at <code>20</code>.</p>
<p>However, given that the probability that <code>20</code> is in the overdose range is only just less than the threshold of 0.25 (and because the only participant so far treated at <code>20</code> experienced a DLT) it would be a perfectly reasonable clinical decision to treat the next cohort at <code>10</code> - or, indeed, at any other dose below <code>20</code>. <i>There is absolutely no obligation to follow the CRM dose recommendation without consideration of other factors that might affect the choice of the most appropriate dose for the next cohort.</i> However, for the purpose of exposition, we will treat the next cohort at <code>20</code>, as recommended by the model.</p>
<p>We can confirm that the trial’s stopping rules have not been satisfied:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb10-2">  my_stopping,</span>
<span id="cb10-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value,</span>
<span id="cb10-4">  postSamples,</span>
<span id="cb10-5">  model,</span>
<span id="cb10-6">  firstFour</span>
<span id="cb10-7">)</span>
<span id="cb10-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb10-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb10-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]]</span></span>
<span id="cb10-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]][[1]]</span></span>
<span id="cb10-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 4 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb10-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]][[2]]</span></span>
<span id="cb10-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 27 % for dose 20 and thus below the required 50 %"</span></span>
<span id="cb10-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]]</span></span>
<span id="cb10-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 4 and thus below the prespecified minimum number 20"</span></span>
<span id="cb10-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")</span></span>
<span id="cb10-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[1]]</span></span>
<span id="cb10-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb10-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb10-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]]</span></span>
<span id="cb10-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 4 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb10-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]]</span></span>
<span id="cb10-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 27 % for dose 20 and thus below the required 50 %"</span></span>
<span id="cb10-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")</span></span>
<span id="cb10-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[1]]</span></span>
<span id="cb10-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span>
<span id="cb10-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb10-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 4 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb10-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb10-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "≥ 3 cohorts dosed"</span></span>
<span id="cb10-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[2]]</span></span>
<span id="cb10-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb10-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb10-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 27 % for dose 20 and thus below the required 50 %"</span></span>
<span id="cb10-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb10-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5"</span></span>
<span id="cb10-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb10-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] NA</span></span>
<span id="cb10-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[2]]</span></span>
<span id="cb10-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb10-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb10-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 4 and thus below the prespecified minimum number 20"</span></span>
<span id="cb10-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb10-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "≥ 20 patients dosed"</span></span>
<span id="cb10-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb10-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] NA</span></span></code></pre></div></div>
</div>
</section>
<section id="the-first-full-cohort" class="level3">
<h3 class="anchored" data-anchor-id="the-first-full-cohort">The first full cohort</h3>
<p>Assume that none of the three patients in the first full cohort report a DLT:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">firstFullCohort <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb11-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>),</span>
<span id="cb11-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb11-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>,</span>
<span id="cb11-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)),</span>
<span id="cb11-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> doseGrid</span>
<span id="cb11-7">)</span></code></pre></div></div>
</div>
<p>Update the model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">postSamples1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(</span>
<span id="cb12-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> firstFullCohort,</span>
<span id="cb12-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb12-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> vignetteMcmcOptions</span>
<span id="cb12-5">)</span></code></pre></div></div>
</div>
<p>Tabulate the posterior:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tabulatePosterior</span>(postSamples1, firstFullCohort)</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Participants
</div></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Probability that dose is in
</div></th>
</tr>
<tr class="even">
<th style="text-align: right;" data-quarto-table-cell-role="th">Dose</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Treated</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">With DLT</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Target range</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Overdose range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.006</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.021</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="odd">
<td style="text-align: right;">9</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.079</td>
<td style="text-align: right;">0.016</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.196</td>
<td style="text-align: right;">0.064</td>
</tr>
<tr class="odd">
<td style="text-align: right;">30</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.371</td>
<td style="text-align: right;">0.175</td>
</tr>
<tr class="even">
<td style="text-align: right;">45</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.411</td>
<td style="text-align: right;">0.457</td>
</tr>
<tr class="odd">
<td style="text-align: right;">60</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.259</td>
<td style="text-align: right;">0.700</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.102</td>
<td style="text-align: right;">0.892</td>
</tr>
<tr class="odd">
<td style="text-align: right;">100</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.061</td>
<td style="text-align: right;">0.935</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Should the trial stop? If not, what dose should be used for the next cohort?</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">nextMaxDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(my_increments, firstFullCohort)</span>
<span id="cb14-2">nextMaxDose</span>
<span id="cb14-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 40</span></span>
<span id="cb14-4"></span>
<span id="cb14-5">doseRecommendation <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb14-6">  my_next_best,</span>
<span id="cb14-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> nextMaxDose,</span>
<span id="cb14-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> postSamples1,</span>
<span id="cb14-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb14-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> firstFullCohort</span>
<span id="cb14-11">)</span>
<span id="cb14-12">doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb14-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 30</span></span>
<span id="cb14-14"></span>
<span id="cb14-15">x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb14-16">  my_stopping,</span>
<span id="cb14-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value,</span>
<span id="cb14-18">  postSamples1,</span>
<span id="cb14-19">  model,</span>
<span id="cb14-20">  firstFullCohort</span>
<span id="cb14-21">)</span>
<span id="cb14-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attributes</span>(x) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb14-23">x</span>
<span id="cb14-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span></code></pre></div></div>
</div>
<p>So the trial should continue, treating three patients in the next cohort at <code>30</code>.</p>
</section>
<section id="the-second-full-cohort" class="level3">
<h3 class="anchored" data-anchor-id="the-second-full-cohort">The second full cohort</h3>
<p>Assume that none of the three patients in the next cohort report a DLT:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">secondFullCohort <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb15-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>),</span>
<span id="cb15-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb15-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb15-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)),</span>
<span id="cb15-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> doseGrid</span>
<span id="cb15-7">)</span></code></pre></div></div>
</div>
<p>Update the model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1">postSamples2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(</span>
<span id="cb16-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> secondFullCohort,</span>
<span id="cb16-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb16-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> vignetteMcmcOptions</span>
<span id="cb16-5">)</span></code></pre></div></div>
</div>
<p>Tabulate the posterior:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tabulatePosterior</span>(postSamples2, secondFullCohort)</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Participants
</div></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Probability that dose is in
</div></th>
</tr>
<tr class="even">
<th style="text-align: right;" data-quarto-table-cell-role="th">Dose</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Treated</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">With DLT</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Target range</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Overdose range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.003</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.008</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="odd">
<td style="text-align: right;">9</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.026</td>
<td style="text-align: right;">0.003</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.106</td>
<td style="text-align: right;">0.018</td>
</tr>
<tr class="odd">
<td style="text-align: right;">30</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.243</td>
<td style="text-align: right;">0.060</td>
</tr>
<tr class="even">
<td style="text-align: right;">45</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.434</td>
<td style="text-align: right;">0.249</td>
</tr>
<tr class="odd">
<td style="text-align: right;">60</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.374</td>
<td style="text-align: right;">0.534</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.185</td>
<td style="text-align: right;">0.784</td>
</tr>
<tr class="odd">
<td style="text-align: right;">100</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.108</td>
<td style="text-align: right;">0.877</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>The dose with the highest posterior probability of being in the target toxicity range is now <code>45</code>, but this dose almost has an unacceptably high probability of being in the overdose range. So the team decides to go for a next cohort at <code>30</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1">nextMaxDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(my_increments, secondFullCohort)</span>
<span id="cb18-2">nextMaxDose</span>
<span id="cb18-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 45</span></span>
<span id="cb18-4"></span>
<span id="cb18-5">doseRecommendation <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb18-6">  my_next_best,</span>
<span id="cb18-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> nextMaxDose,</span>
<span id="cb18-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> postSamples2,</span>
<span id="cb18-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb18-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> secondFullCohort</span>
<span id="cb18-11">)</span>
<span id="cb18-12">doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb18-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 45</span></span>
<span id="cb18-14"></span>
<span id="cb18-15">x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb18-16">  my_stopping,</span>
<span id="cb18-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># team decision.</span></span>
<span id="cb18-18">  postSamples2,</span>
<span id="cb18-19">  model,</span>
<span id="cb18-20">  secondFullCohort</span>
<span id="cb18-21">)</span>
<span id="cb18-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attributes</span>(x) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb18-23">x</span>
<span id="cb18-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span></code></pre></div></div>
</div>
</section>
<section id="the-third-full-cohort" class="level3">
<h3 class="anchored" data-anchor-id="the-third-full-cohort">The third full cohort</h3>
<p>Assume that none of the three patients in the third cohort report a DLT:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1">thirdFullCohort <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb19-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)),</span>
<span id="cb19-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>)),</span>
<span id="cb19-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>,</span>
<span id="cb19-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)),</span>
<span id="cb19-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> doseGrid</span>
<span id="cb19-7">)</span></code></pre></div></div>
</div>
<p>Update the model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1">postSamples3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(</span>
<span id="cb20-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> thirdFullCohort,</span>
<span id="cb20-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb20-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> vignetteMcmcOptions</span>
<span id="cb20-5">)</span></code></pre></div></div>
</div>
<p>Tabulate the posterior:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tabulatePosterior</span>(postSamples3, thirdFullCohort)</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Participants
</div></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Probability that dose is in
</div></th>
</tr>
<tr class="even">
<th style="text-align: right;" data-quarto-table-cell-role="th">Dose</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Treated</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">With DLT</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Target range</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Overdose range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.003</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="odd">
<td style="text-align: right;">9</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.005</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.052</td>
<td style="text-align: right;">0.005</td>
</tr>
<tr class="odd">
<td style="text-align: right;">30</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.163</td>
<td style="text-align: right;">0.018</td>
</tr>
<tr class="even">
<td style="text-align: right;">45</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.457</td>
<td style="text-align: right;">0.132</td>
</tr>
<tr class="odd">
<td style="text-align: right;">60</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.388</td>
<td style="text-align: right;">0.459</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.219</td>
<td style="text-align: right;">0.722</td>
</tr>
<tr class="odd">
<td style="text-align: right;">100</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.138</td>
<td style="text-align: right;">0.825</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><code>45</code> is still the dose with the highest posterior probability of being in the target toxicity range, and its probability of being in the overdose range is now acceptable. Therefore, the trial should continue and the next cohort should be treated at <code>45</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1">nextMaxDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(my_increments, thirdFullCohort)</span>
<span id="cb22-2">nextMaxDose</span>
<span id="cb22-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 45</span></span>
<span id="cb22-4"></span>
<span id="cb22-5">doseRecommendation <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb22-6">  my_next_best,</span>
<span id="cb22-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> nextMaxDose,</span>
<span id="cb22-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> postSamples3,</span>
<span id="cb22-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb22-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> thirdFullCohort</span>
<span id="cb22-11">)</span>
<span id="cb22-12">doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb22-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 45</span></span>
<span id="cb22-14"></span>
<span id="cb22-15">x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb22-16">  my_stopping,</span>
<span id="cb22-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value,</span>
<span id="cb22-18">  postSamples3,</span>
<span id="cb22-19">  model,</span>
<span id="cb22-20">  thirdFullCohort</span>
<span id="cb22-21">)</span>
<span id="cb22-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attributes</span>(x) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb22-23">x</span>
<span id="cb22-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span></code></pre></div></div>
</div>
</section>
<section id="the-fourth-full-cohort" class="level3">
<h3 class="anchored" data-anchor-id="the-fourth-full-cohort">The fourth full cohort</h3>
<p>Assume that none of the three patients in the fourth cohort report a DLT:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1">fourthFullCohort <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb23-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)),</span>
<span id="cb23-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>)),</span>
<span id="cb23-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>,</span>
<span id="cb23-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">each =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)),</span>
<span id="cb23-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> doseGrid</span>
<span id="cb23-7">)</span></code></pre></div></div>
</div>
<p>Update the model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1">postSamples4 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(</span>
<span id="cb24-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> fourthFullCohort,</span>
<span id="cb24-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb24-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> vignetteMcmcOptions</span>
<span id="cb24-5">)</span></code></pre></div></div>
</div>
<p>Tabulate the posterior:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tabulatePosterior</span>(postSamples4, fourthFullCohort)</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Participants
</div></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Probability that dose is in
</div></th>
</tr>
<tr class="even">
<th style="text-align: right;" data-quarto-table-cell-role="th">Dose</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Treated</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">With DLT</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Target range</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Overdose range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="odd">
<td style="text-align: right;">9</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.004</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.026</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="odd">
<td style="text-align: right;">30</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.088</td>
<td style="text-align: right;">0.013</td>
</tr>
<tr class="even">
<td style="text-align: right;">45</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.337</td>
<td style="text-align: right;">0.084</td>
</tr>
<tr class="odd">
<td style="text-align: right;">60</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.375</td>
<td style="text-align: right;">0.371</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.263</td>
<td style="text-align: right;">0.639</td>
</tr>
<tr class="odd">
<td style="text-align: right;">100</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.224</td>
<td style="text-align: right;">0.740</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><code>60</code> is now the dose with the highest posterior probability of being in the target toxicity range, but its probability of being in the overdose range is unacceptable. Therefore, the trial should continue and the next cohort should be treated at <code>45</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1">nextMaxDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(my_increments, fourthFullCohort)</span>
<span id="cb26-2">nextMaxDose</span>
<span id="cb26-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 67.5</span></span>
<span id="cb26-4"></span>
<span id="cb26-5">doseRecommendation <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb26-6">  my_next_best,</span>
<span id="cb26-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> nextMaxDose,</span>
<span id="cb26-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> postSamples4,</span>
<span id="cb26-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb26-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> fourthFullCohort</span>
<span id="cb26-11">)</span>
<span id="cb26-12">doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb26-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 45</span></span>
<span id="cb26-14"></span>
<span id="cb26-15">x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb26-16">  my_stopping,</span>
<span id="cb26-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value,</span>
<span id="cb26-18">  postSamples4,</span>
<span id="cb26-19">  model,</span>
<span id="cb26-20">  fourthFullCohort</span>
<span id="cb26-21">)</span>
<span id="cb26-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attributes</span>(x) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb26-23">x</span>
<span id="cb26-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span></code></pre></div></div>
</div>
</section>
<section id="the-fifth-full-cohort" class="level3">
<h3 class="anchored" data-anchor-id="the-fifth-full-cohort">The fifth full cohort</h3>
<p>Assume that two of the three patients in the fourth cohort report a DLT:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">fifthFullCohort <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb27-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)),</span>
<span id="cb27-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb27-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">19</span>,</span>
<span id="cb27-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">each =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)),</span>
<span id="cb27-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> doseGrid</span>
<span id="cb27-7">)</span></code></pre></div></div>
</div>
<p>Update the model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1">postSamples5 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(</span>
<span id="cb28-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> fifthFullCohort,</span>
<span id="cb28-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb28-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> vignetteMcmcOptions</span>
<span id="cb28-5">)</span></code></pre></div></div>
</div>
<p>Tabulate the posterior:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tabulatePosterior</span>(postSamples5, fifthFullCohort)</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Participants
</div></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Probability that dose is in
</div></th>
</tr>
<tr class="even">
<th style="text-align: right;" data-quarto-table-cell-role="th">Dose</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Treated</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">With DLT</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Target range</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Overdose range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="odd">
<td style="text-align: right;">9</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.012</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.079</td>
<td style="text-align: right;">0.003</td>
</tr>
<tr class="odd">
<td style="text-align: right;">30</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.212</td>
<td style="text-align: right;">0.019</td>
</tr>
<tr class="even">
<td style="text-align: right;">45</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">0.528</td>
<td style="text-align: right;">0.183</td>
</tr>
<tr class="odd">
<td style="text-align: right;">60</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.368</td>
<td style="text-align: right;">0.579</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.168</td>
<td style="text-align: right;">0.818</td>
</tr>
<tr class="odd">
<td style="text-align: right;">100</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.094</td>
<td style="text-align: right;">0.896</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><code>45</code> remains the dose with the highest posterior probability of being in the target toxicity range, and its probability of being in the overdose range is acceptable. Moreover, the probability that <code>45</code> is in the target toxicity range is above 0.5 and more than three cohorts have been treated in total. Therefore, the trial should stop and conclude that <code>45</code> is the MTD:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1">nextMaxDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(my_increments, fifthFullCohort)</span>
<span id="cb30-2">nextMaxDose</span>
<span id="cb30-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 67.5</span></span>
<span id="cb30-4"></span>
<span id="cb30-5">doseRecommendation <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb30-6">  my_next_best,</span>
<span id="cb30-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> nextMaxDose,</span>
<span id="cb30-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> postSamples5,</span>
<span id="cb30-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb30-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> fifthFullCohort</span>
<span id="cb30-11">)</span>
<span id="cb30-12">doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb30-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 45</span></span>
<span id="cb30-14"></span>
<span id="cb30-15">x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(</span>
<span id="cb30-16">  my_stopping,</span>
<span id="cb30-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value,</span>
<span id="cb30-18">  postSamples5,</span>
<span id="cb30-19">  model,</span>
<span id="cb30-20">  fifthFullCohort</span>
<span id="cb30-21">)</span>
<span id="cb30-22">x</span>
<span id="cb30-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span>
<span id="cb30-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb30-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]]</span></span>
<span id="cb30-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]][[1]]</span></span>
<span id="cb30-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 9 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb30-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb30-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]][[2]]</span></span>
<span id="cb30-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 53 % for dose 45 and thus above the required 50 %"</span></span>
<span id="cb30-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb30-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb30-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]]</span></span>
<span id="cb30-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 19 and thus below the prespecified minimum number 20"</span></span>
<span id="cb30-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb30-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")</span></span>
<span id="cb30-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[1]]</span></span>
<span id="cb30-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span>
<span id="cb30-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb30-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]]</span></span>
<span id="cb30-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 9 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb30-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb30-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]]</span></span>
<span id="cb30-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 53 % for dose 45 and thus above the required 50 %"</span></span>
<span id="cb30-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb30-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")</span></span>
<span id="cb30-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[1]]</span></span>
<span id="cb30-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span>
<span id="cb30-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb30-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 9 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb30-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb30-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "≥ 3 cohorts dosed"</span></span>
<span id="cb30-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb30-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[2]]</span></span>
<span id="cb30-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span>
<span id="cb30-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb30-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 53 % for dose 45 and thus above the required 50 %"</span></span>
<span id="cb30-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb30-59"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5"</span></span>
<span id="cb30-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb30-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb30-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] NA</span></span>
<span id="cb30-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb30-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[2]]</span></span>
<span id="cb30-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb30-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb30-67"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 19 and thus below the prespecified minimum number 20"</span></span>
<span id="cb30-68"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb30-69"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "≥ 20 patients dosed"</span></span>
<span id="cb30-70"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb30-71"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb30-72"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] NA</span></span></code></pre></div></div>
</div>
</section>
</section>
<section id="summarising-the-trial-results" class="level2">
<h2 class="anchored" data-anchor-id="summarising-the-trial-results">Summarising the trial results</h2>
<p>crmPack provides a wealth of information about the trial’s results. The following code snippets illustrate some of the many possibilities for how the trial might be summarised.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb31" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(fifthFullCohort)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/index_files/figure-html/unnamed-chunk-33-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A visual representation of the data after nineteen participants have been treated.  One each at doses 1, 3 and 9; four at a dose of 20; 6 at a dose of 30 and 6 at a dose of 45.  Toxicitiues were reported by participants 4 (at a dose of 20) and 18 and 19 (both at a dose of 45)."></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(postSamples5, model, fifthFullCohort)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/index_files/figure-html/unnamed-chunk-34-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A plot of the posterior after nineteen participants have been treated.  The mean probability of toxicity increases smoothly from about zero percent at a dose of zero to about 55% at a dose of 100.  The confidence interval extends from 0% to about 6% at a dose of zero and from about 22% to about 90% at a dose of 100."></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb33" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb33-1">doseRecommendation<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plot</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/index_files/figure-html/unnamed-chunk-35-1.png" class="img-fluid figure-img" style="width:100.0%" alt="Two graphs arranged in a single column.  The upper graph shoes green lines of various heights that show the probability each dose is in the target toxicity range.  There is a big arrow pointing to the bar at a dose of 45, indicating that this dose has the highest probability of being in the target toxicity range.  The lower graph as a similar series of red lines, indicating the probability that each dose is in the overdose range.  There is a horizontal black dashed line at 25%, indicating that this is the highest acceptable probability of being in the overdose range.  The red bars for doses of 60 and above all extend above 25%, indicating that their toxicity is unacceptable.  The toxicity for doses of 45 and below lie below 25%."></p>
</figure>
</div>
</div>
</div>
<p>With a little bit of work, we can obtain a more detailed summary and plot of the posterior probabilities of toxicity at each dose:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">slotNames</span>(model)</span>
<span id="cb34-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "params"          "ref_dose"        "datamodel"       "priormodel"     </span></span>
<span id="cb34-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [5] "modelspecs"      "init"            "datanames"       "datanames_prior"</span></span>
<span id="cb34-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [9] "sample"</span></span>
<span id="cb34-5"></span>
<span id="cb34-6">fullSamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb34-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Alpha =</span> postSamples5<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha0,</span>
<span id="cb34-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Beta =</span> postSamples5<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha1</span>
<span id="cb34-9">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nesting</span>(Alpha, Beta), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Dose =</span> doseGrid) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rowwise</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">P =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> Alpha, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> Beta)(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> Dose)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>()</span>
<span id="cb34-14"></span>
<span id="cb34-15">fullSummary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> fullSamples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(Dose) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb34-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(P),</span>
<span id="cb34-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(P),</span>
<span id="cb34-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Q =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">quantile</span>(P, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">probs =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))</span>
<span id="cb34-21">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unnest_wider</span>(</span>
<span id="cb34-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> Q,</span>
<span id="cb34-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_repair =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(.x) {</span>
<span id="cb34-25">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(</span>
<span id="cb34-26">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(.x, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">d+%"</span>),</span>
<span id="cb34-27">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Q%02.0f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove_all</span>(.x, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>))),</span>
<span id="cb34-28">        .x</span>
<span id="cb34-29">      )</span>
<span id="cb34-30">    }</span>
<span id="cb34-31">  )</span>
<span id="cb34-32"></span>
<span id="cb34-33">fullSummary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-34">  kableExtra<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(</span>
<span id="cb34-35">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dose"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Median"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"5th"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"10th"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"25th"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"75th"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"90th"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"95th"</span>),</span>
<span id="cb34-36">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>))</span>
<span id="cb34-37">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-38">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_header_above</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Quantiles"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-39">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_header_above</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P(Toxicity)"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<colgroup>
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
<th colspan="8" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
P(Toxicity)
</div></th>
</tr>
<tr class="even">
<th colspan="3" data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
<th colspan="6" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Quantiles
</div></th>
</tr>
<tr class="header">
<th style="text-align: right;" data-quarto-table-cell-role="th">Dose</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Mean</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Median</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">5th</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">10th</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">25th</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">75th</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">90th</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">95th</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.007</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.005</td>
<td style="text-align: right;">0.021</td>
<td style="text-align: right;">0.036</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.015</td>
<td style="text-align: right;">0.003</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.017</td>
<td style="text-align: right;">0.048</td>
<td style="text-align: right;">0.070</td>
</tr>
<tr class="odd">
<td style="text-align: right;">9</td>
<td style="text-align: right;">0.040</td>
<td style="text-align: right;">0.020</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.001</td>
<td style="text-align: right;">0.006</td>
<td style="text-align: right;">0.059</td>
<td style="text-align: right;">0.108</td>
<td style="text-align: right;">0.141</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">0.093</td>
<td style="text-align: right;">0.076</td>
<td style="text-align: right;">0.011</td>
<td style="text-align: right;">0.018</td>
<td style="text-align: right;">0.038</td>
<td style="text-align: right;">0.135</td>
<td style="text-align: right;">0.207</td>
<td style="text-align: right;">0.241</td>
</tr>
<tr class="odd">
<td style="text-align: right;">30</td>
<td style="text-align: right;">0.154</td>
<td style="text-align: right;">0.134</td>
<td style="text-align: right;">0.044</td>
<td style="text-align: right;">0.058</td>
<td style="text-align: right;">0.091</td>
<td style="text-align: right;">0.207</td>
<td style="text-align: right;">0.282</td>
<td style="text-align: right;">0.309</td>
</tr>
<tr class="even">
<td style="text-align: right;">45</td>
<td style="text-align: right;">0.265</td>
<td style="text-align: right;">0.250</td>
<td style="text-align: right;">0.127</td>
<td style="text-align: right;">0.147</td>
<td style="text-align: right;">0.183</td>
<td style="text-align: right;">0.332</td>
<td style="text-align: right;">0.399</td>
<td style="text-align: right;">0.459</td>
</tr>
<tr class="odd">
<td style="text-align: right;">60</td>
<td style="text-align: right;">0.379</td>
<td style="text-align: right;">0.374</td>
<td style="text-align: right;">0.184</td>
<td style="text-align: right;">0.211</td>
<td style="text-align: right;">0.271</td>
<td style="text-align: right;">0.466</td>
<td style="text-align: right;">0.573</td>
<td style="text-align: right;">0.608</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">0.502</td>
<td style="text-align: right;">0.489</td>
<td style="text-align: right;">0.237</td>
<td style="text-align: right;">0.278</td>
<td style="text-align: right;">0.364</td>
<td style="text-align: right;">0.639</td>
<td style="text-align: right;">0.743</td>
<td style="text-align: right;">0.813</td>
</tr>
<tr class="odd">
<td style="text-align: right;">100</td>
<td style="text-align: right;">0.587</td>
<td style="text-align: right;">0.581</td>
<td style="text-align: right;">0.279</td>
<td style="text-align: right;">0.327</td>
<td style="text-align: right;">0.424</td>
<td style="text-align: right;">0.753</td>
<td style="text-align: right;">0.853</td>
<td style="text-align: right;">0.906</td>
</tr>
</tbody>
</table>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb35" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1"></span>
<span id="cb35-2">fullSamples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb35-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Dose <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb35-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_density</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> P, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>(Dose))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_light</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb35-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb35-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb35-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.ticks.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>()</span>
<span id="cb35-11">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb35-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Posterior PDFs for doses &gt; 9"</span>,</span>
<span id="cb35-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dose"</span></span>
<span id="cb35-15">  )</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/index_files/figure-html/unnamed-chunk-36-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A graph showing the posterior density of of the probability of toxicity for all doses greater than nine.  The mode of each density moves to the right as dose increases.  The densities for low doses are heaviliy skewed to the left.  Densities for higher doses are more symmetric and flatter."></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">fullSummary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb36-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> Dose)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> Q05, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> Q95), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> Q10, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> Q90), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> Q25, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> Q75), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> Mean), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> Median), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_light</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb36-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Posterior Dose toxicity curve"</span>,</span>
<span id="cb36-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dose"</span>,</span>
<span id="cb36-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P(Toxicity)"</span></span>
<span id="cb36-13">  )</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/index_files/figure-html/unnamed-chunk-37-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A visual representation of the posterior dose - toxicity curve.  Very closely spaced solid lines in black and blue, representing the mean and median estimate of toxicity for each dose rise almost linearly from zero percent for a dose of zero to about 55% for a dose of 100.  Shading extends to each side of the two solid lines.  The transparency of the shading increases with distance from the solid lines.  The shading is funnel shaped, with a narrow mneck at a dose of 100 and a wider mouth at a dose of 100.  The shading represents the central 90%, 80% and 50% confidence intervals for the posterior mean estimate of toxicity at each dose."></p>
</figure>
</div>
</div>
</div>
</section>
<section id="note" class="level2">
<h2 class="anchored" data-anchor-id="note">Note</h2>
<p>The analyses presented in this vignette have used chains of a very short length. This is purely for convenience. Analyses of real trials should use considerably longer chains. As an example, an effective sample size of approximately 40,000 is required to estimate a percentage to within ±1%.</p>
</section>
<section id="references" class="level2">




</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-Neuenschwander2008" class="csl-entry">
Neuenschwander, Beat, Michael Branson, and Thomas Gsponer. 2008. <span>“<span class="nocase">Critical aspects of the Bayesian approach to phase I cancer trials.</span>”</span> <em>Statistics in Medicine</em> 27 (13): 2420–39. <a href="https://onlinelibrary.wiley.com/doi/10.1002/sim.3230">https://onlinelibrary.wiley.com/doi/10.1002/sim.3230</a>.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Getting started</category>
  <guid>https://www.crmpack.org/vignettes/getting-started/crmPack_analysis/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_06.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Backfilling cohorts simulation</title>
  <dc:creator>Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/getting-started/crmPack_backfill/</link>
  <description><![CDATA[ 




<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>Backfilling cohorts are increasingly used in dose escalation studies, see <span class="citation" data-cites="Barnett2023">Barnett et al. (2023)</span>. The idea is that once a dose level has been tested and found to be safe, then while the dose escalation continues at higher dose levels, additional patients can be enrolled at the lower dose levels to gather more data on safety and/or efficacy. This is particularly useful in trials where patient recruitment is slow or when there is a need to gather more information on lower dose levels for regulatory or clinical reasons.</p>
<p>Sometimes health authorities are asking to include the backfilling cohorts in the simulations to check the operating characteristics (especially PMDA). In addition, it is useful to get more precise operating characteristics for the overall trial by actually simulating the backfilling cohorts, when they are part of the actual clinical trial design.</p>
<p>Hence, with <code>crmPack</code> it is now possible to include backfilling cohorts in the simulations. This vignette illustrates how to do this.</p>
</section>
<section id="framework" class="level2">
<h2 class="anchored" data-anchor-id="framework">Framework</h2>
<p>Conceptually the backfilling details are part of the design of a trial. Therefore the details are included via a dedicated slot <code>backfill</code> in the <code>Design</code> class. It contains an object of class <code>Backfill</code>, which captures these details via the following slots:</p>
<ul>
<li><code>cohort_size</code>: How large are the backfilling cohorts? Here an object of class <code>CohortSize</code> is used.</li>
<li><code>max_size</code>: What is the overall maximum number of patients across all backfill cohorts?</li>
<li><code>opening</code>: When can a backfill cohort be opened or recruited into? Here an object of a new <code>Opening</code> rules class is used. These rules can be based on e.g.&nbsp;dose level, current highest/maximum safe dose, efficacy responses, etc.</li>
<li><code>recruitment</code>: How fast can patients be recruited into backfill cohorts? Here an object of a new <code>Recruitment</code> class is used. You can choose between immediate recruitment vs.&nbsp;a ratio compared to active dose escalation cohort (e.g.&nbsp;when active cohort has 3 patients recruited then here only 1/3 so 1 patient per cycle to backfill cohorts).</li>
<li><code>priority</code>: When there are multiple open backfill cohorts, which one should be recruited into first? Here a simple string is used to specify the priority rule (first “lowest” dose, first “highest” dose, or “random”).</li>
</ul>
<p>Additional parts of the backfill cohort framework comprise:</p>
<ul>
<li>The <code>Data</code> objects have a slot <code>backfilled</code> identifying whether each patient was backfilled or not, and the slot <code>response</code> identifies whether each patient had a response (1) or not (0). When these are not actively set by the user, then they default to no patients backfilled (all <code>FALSE</code>) and no response data available (all <code>NA</code>).</li>
<li>Some <code>Stopping</code> rules can optionally exclude backfill patients for assessing whether a trial can be stopped or not. This is currently the case for the <code>StoppingPatientsNearDose</code> rule.</li>
</ul>
</section>
<section id="algorithm" class="level2">
<h2 class="anchored" data-anchor-id="algorithm">Algorithm</h2>
<p>For reference, we describe the algorithm used in the <code>simulate</code> method for <code>Design</code> objects to include backfilling cohorts:</p>
<ol type="1">
<li>Backfilling is only possible if the <code>opening</code> is <em>not</em> an <code>OpeningNone</code> object. Otherwise no backfilling is done in any of the trial simulations.</li>
<li>A queue of open backfill cohorts is maintained, and it is initialized as empty at the start of the trial. Likewise, the total number of backfill patients recruited so far is initialized to zero.</li>
<li>Throughout the trial simulations, for each patient next to the toxicity outcome, in addition also the binary response is simulated according to the assumed dose-response probability function (note that placebo patients can also have a response in principle, according to the placebo dose used in the dose grid).</li>
<li>After each dose escalation cohort is completed (i.e.&nbsp;all patients in the cohort have their toxicity and response outcomes observed), the backfill queue is updated:
<ol type="a">
<li>First, for all of the previous cohorts in the trial we check whether a backfill cohort can be opened, or can stay open (in case it was already open). This is done by applying the <code>opening</code> rules to each cohort in turn, in combination with comparing the cohort’s dose with the current dose: It is a strict requirement that only cohorts with doses below the current dose can be open for backfilling (as the name suggests already).</li>
<li>If a cohort is already in the backfill queue, we first check whether it is full already (maximum number of backfill patients in this particular queue has been reached). If we can open it and it is not full, then it is opened or remains open. If it is full, it remains closed. If we cannot open it, then it is closed (if it was open before), but still remains in the queue for record keeping.</li>
<li>If a cohort is not yet in the backfill queue and we can open it, then it is added to the backfill queue. The maximum size of each backfill cohort is determined by the <code>size</code> rule.</li>
</ol></li>
<li>After updating the backfill queue, the number of patients which can be enrolled in this dose cycle into backfill cohorts is determined according to the <code>recruitment</code> rule and the <code>max_size</code> limit for the overall number of backfill patients. If there are no backfill patients which can be recruited, then we continue with the next dose escalation cohort.</li>
<li>Assuming that we can recruit backfill patients, the cohorts from the backfill queue are sorted according to the <code>priority</code> option. Then patients are recruited into the open backfill cohorts in this order (filling up as many as possible patients for each cohort), until either all possible backfill patients for this cycle have been recruited, or all open backfill cohorts are full.</li>
<li>Backfill cohorts which have reached their maximum size are closed (i.e.&nbsp;they cannot be recruited into anymore), but they remain in the backfill queue for record keeping.</li>
<li>After recruiting any backfilling patients, the trial simulation continues with determining the maximum increment, fitting the regression model, selecting the next dose, checking stopping rules, as usual. Note that toxicity outcomes from backfill patients are deliberately included in the model fitting and dose selection, to reflect the actual data situation in the trial.</li>
</ol>
</section>
<section id="examples" class="level2">
<h2 class="anchored" data-anchor-id="examples">Examples</h2>
<section id="standard-components" class="level3">
<h3 class="anchored" data-anchor-id="standard-components">Standard components</h3>
<p>We start with the standard components of a CRM design, which are not changed by the backfilling framework - except that for the <code>StoppingPatientsNearDose</code> rule we can now choose whether to include backfill patients or not.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Define the dose-grid.</span></span>
<span id="cb1-2">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb1-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb1-4">)</span>
<span id="cb1-5"></span>
<span id="cb1-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Define the dose-toxicity model.</span></span>
<span id="cb1-7">model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticLogNormal</span>(</span>
<span id="cb1-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb1-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb1-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ref_dose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">56</span></span>
<span id="cb1-11">)</span>
<span id="cb1-12"></span>
<span id="cb1-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for selecting the next dose.</span></span>
<span id="cb1-14">myNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestNCRM</span>(</span>
<span id="cb1-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>),</span>
<span id="cb1-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overdose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb1-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_overdose_prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span></span>
<span id="cb1-18">)</span>
<span id="cb1-19"></span>
<span id="cb1-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for stopping.</span></span>
<span id="cb1-21">myStopping1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinCohorts</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nCohorts =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb1-22">myStopping2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingTargetProb</span>(</span>
<span id="cb1-23">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>),</span>
<span id="cb1-24">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span></span>
<span id="cb1-25">)</span>
<span id="cb1-26">myStopping3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinPatients</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>)</span>
<span id="cb1-27">myStopping4 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingPatientsNearDose</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>L, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">percentage =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">include_backfill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb1-28">myStopping <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (myStopping1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> myStopping2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> myStopping4) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span></span>
<span id="cb1-29">  myStopping3 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span></span>
<span id="cb1-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMissingDose</span>()</span>
<span id="cb1-31"></span>
<span id="cb1-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for dose increments.</span></span>
<span id="cb1-33">myIncrements <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelative</span>(</span>
<span id="cb1-34">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>),</span>
<span id="cb1-35">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.67</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.33</span>)</span>
<span id="cb1-36">)</span></code></pre></div></div>
</div>
</section>
<section id="no-backfill-cohorts" class="level3">
<h3 class="anchored" data-anchor-id="no-backfill-cohorts">No backfill cohorts</h3>
<p>First we can define a design without backfill cohorts, which is the default behaviour when no backfill details are specified:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">design_no_backfill <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Design</span>(</span>
<span id="cb2-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb2-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> myNextBest,</span>
<span id="cb2-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping,</span>
<span id="cb2-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements,</span>
<span id="cb2-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb2-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> emptydata,</span>
<span id="cb2-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb2-9">)</span>
<span id="cb2-10">design_no_backfill<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>backfill</span></code></pre></div></div>
<div class="cell-output-display">
<p>No backfill cohorts at all will be opened.</p>
</div>
</div>
<blockquote class="blockquote">
<p><strong>Note:</strong> This concise statement is produced by dedicated <code>knit_print</code> methods for the <code>Backfill</code> class, which help with the consistent reporting of <code>crmPack</code> design details in vignettes and reports.</p>
</blockquote>
</section>
<section id="simple-backfill-cohorts" class="level3">
<h3 class="anchored" data-anchor-id="simple-backfill-cohorts">Simple backfill cohorts</h3>
<p>Let’s continue with the simplest case of backfill cohorts. Here we define backfill cohorts of size 3 patients each, with a maximum of 12 backfill patients in total. Backfill cohorts can be opened at any time (i.e.&nbsp;immediately), and recruitment into backfill cohorts is immediate (i.e.&nbsp;as fast as dose escalation cohorts). When multiple backfill cohorts are open, then the lowest dose level is recruited into first.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">backfill_simple <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Backfill</span>(</span>
<span id="cb3-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb3-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>,</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">opening =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">OpeningMinCohorts</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min_cohorts =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recruitment =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">RecruitmentUnlimited</span>(),</span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">priority =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lowest"</span></span>
<span id="cb3-7">)</span>
<span id="cb3-8">backfill_simple</span></code></pre></div></div>
<div class="cell-output-display">
<p><strong>Cohort size</strong>: A constant size of 3 participants.</p>
<p><strong>Opening rule</strong>: If 1 or more cohorts have been treated in total.</p>
<p><strong>Recruitment</strong>: Unlimited recruitment of backfill patients is allowed.</p>
<p><strong>Total number of backfill patients</strong>: 12 backfill patients.</p>
<p><strong>Priority of higher vs.&nbsp;lower dose backfill cohorts</strong>: lowest dose.</p>
</div>
</div>
<p>We can now add this backfill specification to the design:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">design_simple_backfill <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> design_no_backfill</span>
<span id="cb4-2">design_simple_backfill<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>backfill <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> backfill_simple</span></code></pre></div></div>
</div>
</section>
<section id="more-complex-backfill-cohorts" class="level3">
<h3 class="anchored" data-anchor-id="more-complex-backfill-cohorts">More complex backfill cohorts</h3>
<p>Now let’s make things a bit more complex. We define a random number of patients for each backfill cohort, with a minimum of 1 patient and a maximum of 6 patients. Backfill cohorts can only be opened once at least 3 dose escalation cohorts have been completed. Note that this will lead to a delayed opening of cohorts 1, 2, and 3 for simultaneous backfilling. In addition, at least one response must have been observed at the cohort’s dose level or a lower dose level before it could be opened for backfill. For example, if there is no response observed in cohort 1 at the lowest dose level, then it will not be opened for backfilling at all. We will be able to specify the assumed dose-response probability function in the <code>simulate</code> method call later. Recruitment into backfill cohorts is slower than dose escalation cohorts, with a ratio of 1 backfill patient for every 2 dose escalation patients. When multiple backfill cohorts are open, then the highest dose level is recruited into first. The total maximum number of backfill patients is set to 20.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">backfill_complex <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Backfill</span>(</span>
<span id="cb5-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeRandom</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>),</span>
<span id="cb5-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">opening =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">OpeningMinCohorts</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min_cohorts =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb5-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">OpeningMinResponses</span>(</span>
<span id="cb5-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min_responses =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb5-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">include_lower_doses =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb5-7">    ),</span>
<span id="cb5-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recruitment =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">RecruitmentRatio</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ratio =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb5-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">priority =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"highest"</span>,</span>
<span id="cb5-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span></span>
<span id="cb5-11">)</span>
<span id="cb5-12">backfill_complex</span></code></pre></div></div>
<div class="cell-output-display">
<p><strong>Cohort size</strong>: A random cohort size drawn uniformly between 1 and 6 participants.</p>
<p><strong>Opening rule</strong>: If both of the following rules are satisfied:</p>
<ul>
<li><p>If 3 or more cohorts have been treated in total.</p></li>
<li><p>If 1 or more responses have been observed at this dose or lower.</p></li>
</ul>
<p><strong>Recruitment</strong>: Backfill patients are recruited at a ratio of 0.5 per patient in the main trial cohort.</p>
<p><strong>Total number of backfill patients</strong>: 20 backfill patients.</p>
<p><strong>Priority of higher vs.&nbsp;lower dose backfill cohorts</strong>: highest dose.</p>
</div>
</div>
<p>Note how we can combine multiple opening rules using the <code>&amp;</code> operator. This is analogous to how stopping rules can be combined. Indeed, it is also possible to use the <code>|</code> operator to combine opening rules with an “or” logic.</p>
<p>Again we add this backfill specification to the design:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">design_complex_backfill <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> design_no_backfill</span>
<span id="cb6-2">design_complex_backfill<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>backfill <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> backfill_complex</span></code></pre></div></div>
</div>
</section>
<section id="simulations-with-backfill-cohorts" class="level3">
<h3 class="anchored" data-anchor-id="simulations-with-backfill-cohorts">Simulations with backfill cohorts</h3>
<p>Now we can run trial simulations including backfill cohorts. Here we illustrate this with both the simple and the complex backfill cohort designs defined above. For the complex backfill design we also need to specify the assumed dose-response probability function. Similarly as for the dose-toxicity function, it might be worth to consider a few different scenarios in practice.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Assumed dose-response probability function.</span></span>
<span id="cb7-2">mytruthResponse <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose) {</span>
<span id="cb7-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plogis</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> dose) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span></span>
<span id="cb7-4">}</span>
<span id="cb7-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">curve</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mytruthResponse</span>(x),</span>
<span id="cb7-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(emptydata<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid),</span>
<span id="cb7-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dose"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Probability of Response / Toxicity"</span>,</span>
<span id="cb7-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">main =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Assumed Functions"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb7-9">)</span>
<span id="cb7-10"></span>
<span id="cb7-11">myTruth <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(design_simple_backfill<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb7-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">curve</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruth</span>(x),</span>
<span id="cb7-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(emptydata<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid),</span>
<span id="cb7-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">add =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span></span>
<span id="cb7-15">)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_backfill/index_files/figure-html/unnamed-chunk-8-1.png" class="img-fluid figure-img" style="width:100.0%"></p>
</figure>
</div>
</div>
</div>
<p>Now we can run the simulations for this particular scenario:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># For real applications, use e.g. McmcOptions() with defaults.</span></span>
<span id="cb8-2">mcmcOptions <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb8-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb8-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb8-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb8-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rng_kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mersenne-Twister"</span>,</span>
<span id="cb8-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rng_seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12345</span></span>
<span id="cb8-8">)</span>
<span id="cb8-9"></span>
<span id="cb8-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Simple backfill design simulation:</span></span>
<span id="cb8-11">sims_simple <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(</span>
<span id="cb8-12">  design_simple_backfill,</span>
<span id="cb8-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth,</span>
<span id="cb8-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># For real applications, increase to 1000 e.g.</span></span>
<span id="cb8-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>,</span>
<span id="cb8-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> mcmcOptions,</span>
<span id="cb8-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb8-18">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">firstSeparate =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb8-19">)</span>
<span id="cb8-20"></span>
<span id="cb8-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Complex backfill design simulation:</span></span>
<span id="cb8-22">sims_complex <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(</span>
<span id="cb8-23">  design_complex_backfill,</span>
<span id="cb8-24">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth,</span>
<span id="cb8-25">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truthResponse =</span> mytruthResponse,</span>
<span id="cb8-26">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># For real applications, increase to 1000 e.g</span></span>
<span id="cb8-27">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>,</span>
<span id="cb8-28">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> mcmcOptions,</span>
<span id="cb8-29">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb8-30">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">firstSeparate =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb8-31">)</span></code></pre></div></div>
</div>
<p>We can see that it is still very simple and straightforward to run simulations including backfill cohorts.</p>
</section>
<section id="investigating-single-trial-data" class="level3">
<h3 class="anchored" data-anchor-id="investigating-single-trial-data">Investigating single trial data</h3>
<p>The data for each simulated trial is available in the list in the <code>data</code> slot of the returned <code>Simulations</code> object, and we can also plot it.</p>
<p>For example, the 3rd simulated trial with the simple backfill design looks like this:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(sims_simple<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mark_backfill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_backfill/index_files/figure-html/unnamed-chunk-10-1.png" class="img-fluid figure-img" style="width:100.0%"></p>
</figure>
</div>
</div>
</div>
<p>We can see from the patient IDs, which are assigned sequentially in time, when the backfill patients were recruited (those with an empty shape). For example, we see that the highest dose which was backfilled is 15, after which the maximum of 12 backfill patients was reached.</p>
<p>Similarly we can also plot the data from a simulated trial with the complex backfill design. Here we show the 5th simulated trial, and because the backfill cohort rule is also based on responses, we also mark the response data (using blue squares around the points with a response):</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(sims_complex<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mark_backfill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mark_response =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_backfill/index_files/figure-html/unnamed-chunk-11-1.png" class="img-fluid figure-img" style="width:100.0%"></p>
</figure>
</div>
</div>
</div>
<p>Here we can see that the starting dose cohort at dose 3 as well as the next one at dose 5 did not produce any responses, hence no backfill cohorts could be opened at these dose levels. Only after dose escalation reached dose 10 in cohort 3 and two responses were observed there, a backfill cohort could be started there and at the higher dose 20 (because we assumed a monotone dose-response relationship, and include lower doses in our response assessment in the backfill cohort opening rule).</p>
</section>
<section id="investigating-simulation-results" class="level3">
<h3 class="anchored" data-anchor-id="investigating-simulation-results">Investigating simulation results</h3>
<p>We can do some manual investigations of the simulation results to see how many backfill patients were recruited in each simulation:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">get_backfill_counts <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(sims) {</span>
<span id="cb11-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(sims<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data, \(d) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>backfilled))</span>
<span id="cb11-3">}</span>
<span id="cb11-4">backfill_counts_simple <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_backfill_counts</span>(sims_simple)</span>
<span id="cb11-5">backfill_counts_complex <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_backfill_counts</span>(sims_complex)</span>
<span id="cb11-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(backfill_counts_simple)</span>
<span id="cb11-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; backfill_counts_simple</span></span>
<span id="cb11-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  9 12 </span></span>
<span id="cb11-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  1  9</span></span>
<span id="cb11-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(backfill_counts_complex)</span>
<span id="cb11-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; backfill_counts_complex</span></span>
<span id="cb11-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  0  2  3  6 10 </span></span>
<span id="cb11-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  6  1  1  1  1</span></span></code></pre></div></div>
</div>
<p>So we see that for all except one simulation in the simple design, the maximum number of 12 backfill patients was recruited. For the 10 simulations of the complex design the situation is more varied: In 6 of the 10 simulations no backfill patients were recruited at all e.g., but in some including the trial no. 5 we looked at above we saw 6 or more backfill patients.</p>
<p>Let’s also look at the dose distribution of the backfill patients. We can extract the backfill doses from each simulated trial like this:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">get_backfill_doses <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(sims) {</span>
<span id="cb12-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(sims<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data, \(d) d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>x[d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>backfilled])</span>
<span id="cb12-3">}</span>
<span id="cb12-4">backfill_doses_simple <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_backfill_doses</span>(sims_simple)</span>
<span id="cb12-5">backfill_doses_complex <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_backfill_doses</span>(sims_complex)</span></code></pre></div></div>
</div>
<p>For example, the first 3 trials simulated with the simple backfill design had the following backfill doses:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>(backfill_doses_simple, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb13-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[1]]</span></span>
<span id="cb13-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1]  3  3  3  5  5  5 10 10 10 10 10 10</span></span>
<span id="cb13-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[2]]</span></span>
<span id="cb13-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1]  3  3  3  5  5  5 10 10 10 15 15 15</span></span>
<span id="cb13-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[3]]</span></span>
<span id="cb13-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1]  3  3  3  5  5  5 10 10 10 15 15 15</span></span></code></pre></div></div>
</div>
<p>We can e.g.&nbsp;create a table showing the distribution of the backfill doses across all simulations:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">all_backfill_doses_simple <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unlist</span>(backfill_doses_simple)</span>
<span id="cb14-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(all_backfill_doses_simple)</span>
<span id="cb14-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; all_backfill_doses_simple</span></span>
<span id="cb14-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  3  5 10 15 </span></span>
<span id="cb14-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 30 30 42 15</span></span>
<span id="cb14-6"></span>
<span id="cb14-7">all_backfill_doses_complex <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unlist</span>(backfill_doses_complex)</span>
<span id="cb14-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(all_backfill_doses_complex)</span>
<span id="cb14-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; all_backfill_doses_complex</span></span>
<span id="cb14-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 10 15 20 </span></span>
<span id="cb14-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 14  3  4</span></span></code></pre></div></div>
</div>
<p>So we see e.g.&nbsp;that all backfill patients in the complex design were recruited at doses 10, 15, 20.</p>
<p>We can also get basic summary statistics with the <code>summary</code> method for <code>Simulations</code> objects:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(sims_simple, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth)</span>
<span id="cb15-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 10 simulations</span></span>
<span id="cb15-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb15-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target toxicity interval was 20, 35 %</span></span>
<span id="cb15-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target dose interval corresponding to this was 13, 16.8 </span></span>
<span id="cb15-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Intervals are corresponding to 10 and 90 % quantiles</span></span>
<span id="cb15-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb15-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 37 (33, 42) </span></span>
<span id="cb15-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above target tox interval : mean 7 (3, 9) </span></span>
<span id="cb15-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of DLTs in the trials : mean 16 % (12 %, 20 %) </span></span>
<span id="cb15-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients on active : mean 19 % (16 %, 22 %) </span></span>
<span id="cb15-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as MTD : mean 18 (15, 20) </span></span>
<span id="cb15-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at doses selected : mean 40 % (28 %, 48 %) </span></span>
<span id="cb15-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting target MTD: 40 %</span></span>
<span id="cb15-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as MTD: 20 </span></span>
<span id="cb15-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 50 %</span></span>
<span id="cb15-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of backfill patients : mean 12 (12, 12) </span></span>
<span id="cb15-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses for backfill patients: 3: 25.6%, 5: 25.6%, 10: 35.9%, 15: 12.8% </span></span>
<span id="cb15-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted toxicity rate at dose most often selected : mean 31 % (25 %, 39 %) </span></span>
<span id="cb15-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb15-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 3 cohorts dosed :  100 %</span></span>
<span id="cb15-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5 :  100 %</span></span>
<span id="cb15-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 10 patients dosed in 30 % dose range around NBD :  90 %</span></span>
<span id="cb15-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 40 patients dosed :  30 %</span></span>
<span id="cb15-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Stopped because of missing dose :  0 %</span></span></code></pre></div></div>
</div>
<p>If backfill cohorts are used in the design, and there are actually backfill patients in any of the simulated trials then we see:</p>
<ul>
<li>The number of backfill patients recruited across the simulations (average, 10% and 90% quantiles in parentheses).</li>
<li>The dose levels at which backfill patients were recruited (doses with percentages across all cohorts and all simulations).</li>
</ul>
</section>
</section>
<section id="limitations" class="level2">
<h2 class="anchored" data-anchor-id="limitations">Limitations</h2>
<p>Note that the <code>examine</code> method does not include backfill cohorts, because he examination paths would get too complex to understand easily. In addition, it seems not needed to include backfill cohorts for the quick check for which the <code>examine</code> method is intended.</p>
<p>Currently the backfill cohort simulation is supported only for standard <code>Design</code> objects. It is not supported for <code>DADesign</code> or <code>DualDesign</code> objects, although these inherit from the <code>Design</code> class. This is because these more complex designs have additional complexities that need to be addressed before backfilling can be supported. We plan to implement backfill cohort simulation for these, and potentially other design classes, in future releases of <code>crmPack</code>, depending on the demand from users.</p>
</section>
<section id="backwards-compatibility" class="level2">
<h2 class="anchored" data-anchor-id="backwards-compatibility">Backwards Compatibility</h2>
<p>We have looked into the S4 class framework details and it is a known issue that when we add new slots to existing classes, and then load old saved objects of this class without this slot, then these objects will not be usable. In Bioconductor they even created a special package <code>updateObject</code> to deal with this issue (see <a href="https://bioconductor.posit.co/packages/3.22/bioc/vignettes/updateObject/inst/doc/updateObject.html">here</a> for details).</p>
<p>We think that this is not warranted in our case, because typically the code for running simulations and analyses is retained by users of <code>crmPack</code>. Therefore it is best to rerun this code with the new package version including the additional slots.</p>
</section>
<section id="references" class="level2">




</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-Barnett2023" class="csl-entry">
Barnett, H., O. Boix, D. Kontos, and T. Jaki. 2023. <span>“Backfilling Cohorts in Phase <span>I</span> Dose-Escalation Studies.”</span> <em>Clinical Trials</em> 20 (3): 261–68. <a href="https://doi.org/10.1177/17407745231160092">https://doi.org/10.1177/17407745231160092</a>.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Getting started</category>
  <guid>https://www.crmpack.org/vignettes/getting-started/crmPack_backfill/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_07.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Defining a continual reassessment method trial design in crmPack</title>
  <dc:creator>John Kirkpatrick, Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/getting-started/crmPack_design/</link>
  <description><![CDATA[ 




<section id="defining-the-design" class="level2">
<h2 class="anchored" data-anchor-id="defining-the-design">Defining the design</h2>
<p>A CRM study consists of six basic elements:</p>
<ul>
<li>The dose grid</li>
<li>The dose-toxicity model</li>
<li>The increment rule_<sup>1</sup></li>
<li>The dose recommendation rule<sup>1</sup></li>
<li>The cohort size<sup>1</sup></li>
<li>The stopping rule</li>
</ul>
<p>1: Note that in <code>crmPack</code>, the increment, dose selection and cohort size rules are collectively known as the <i>escalation rules</i>.</p>
<p>There are many, many possible choices for each element. In this introduction, we make simple choices for the value of each element.</p>
<p>We start by loading the <code>crmPack</code> package …</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(crmPack)</span></code></pre></div></div>
</div>
<p>… and defining each element in turn.</p>
<section id="the-dose-grid" class="level3">
<h3 class="anchored" data-anchor-id="the-dose-grid">The dose grid</h3>
<p>First, we list the doses that <em>might</em> be used during the trial.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Define the dose grid.</span></span>
<span id="cb2-2">empty_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>))</span></code></pre></div></div>
</div>
<p>There is no commitment to use every dose in the grid. Here we define a grid of 9 doses ranging between 1 and 100. <code>crmPack</code> is agnostic with respect to the units used to measure the doses. The only requirements are that the dose grid is ordered and one dimensional.</p>
<p>Additional doses can be added whilst the trial is running. This will not affect the validity of the results of the trial prior to the addition, but will probably affect the trial’s operating characteristics.</p>
</section>
<section id="the-dose-toxicity-model" class="level3">
<h3 class="anchored" data-anchor-id="the-dose-toxicity-model">The dose toxicity model</h3>
<p>Next, define the dose toxicity model.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Initialize the CRM model.</span></span>
<span id="cb3-2">model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticLogNormal</span>(</span>
<span id="cb3-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ref_dose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">56</span></span>
<span id="cb3-6">)</span></code></pre></div></div>
</div>
<p>In <code>crmPack</code>, the <code>LogisticLogNormal</code> class fits a model of the following form:</p>
<p><img src="https://latex.codecogs.com/png.latex?log(%5Cfrac%7Bp_i%7D%7B1%20-%20p_i%7D)%20=%20%5Calpha%20+%20%5Cbeta%20log(d_i%20/%20d%5E*)"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?d%5E*"> is a reference dose (specified by the <code>ref_dose</code> argument to the <code>LogisticLogNormal</code> function above) and the prior joint distribution of <img src="https://latex.codecogs.com/png.latex?%5Calpha"> and <img src="https://latex.codecogs.com/png.latex?%5Cbeta"> is</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bbmatrix%7D%0A%5Calpha%20%5C%5C%0Alog(%5Cbeta)%0A%5Cend%7Bbmatrix%7D%20%20%20%5Csim%0AN%5Cbegin%7Bpmatrix%7D%0A%5Cbegin%7Bbmatrix%7D%0A%5Cmu_%7B%5Calpha%7D%5C%5C%20%5Cmu_%7B%5Cbeta%7D%0A%5Cend%7Bbmatrix%7D%20%20%20,%0A%5Cbegin%7Bbmatrix%7D%0A%5Csigma_%7B%5Calpha%5Calpha%7D%20&amp;%20%5Csigma_%7B%5Calpha%5Cbeta%7D%20%5C%5C%0A%5Csigma_%7B%7B%5Cbeta%5Calpha%7D%7D%20&amp;%20%5Csigma_%7B%5Cbeta%5Cbeta%7D%0A%5Cend%7Bbmatrix%7D%20%20%20%0A%5Cend%7Bpmatrix%7D.%0A"></p>
<p>The mean and covariance matrices are defined by the <code>mean</code> and <code>cov</code> parameters to the <code>LogisticLogNormal</code> call. So the code above defines the prior joint distribution of <img src="https://latex.codecogs.com/png.latex?%5Calpha"> and <img src="https://latex.codecogs.com/png.latex?log(%5Cbeta)"> to be</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AN%5Cbegin%7Bpmatrix%7D%0A%5Cbegin%7Bbmatrix%7D%0A-0.85%5C%5C0%0A%5Cend%7Bbmatrix%7D%20%20%20,%0A%5Cbegin%7Bbmatrix%7D%0A1%20&amp;%20-0.5%20%5C%5C%0A-0.5%20&amp;%201%0A%5Cend%7Bbmatrix%7D%20%20%20%0A%5Cend%7Bpmatrix%7D.%0A"></p>
<p>It is easy to obtain a visual representation of the prior:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">vignetteMcmcOptions <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb4-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb4-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb4-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb4-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rng_kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mersenne-Twister"</span>,</span>
<span id="cb4-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rng_seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12345</span></span>
<span id="cb4-7">)</span>
<span id="cb4-8">prior_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(</span>
<span id="cb4-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> empty_data,</span>
<span id="cb4-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb4-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">options =</span> vignetteMcmcOptions</span>
<span id="cb4-12">)</span>
<span id="cb4-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(prior_samples, model, empty_data)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_design/index_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid figure-img" style="width:100.0%" alt="A visual representation of the prior.  The prior mean estimate of toxicity rises form almost zero for a dose of 0 to just under 0.75 for a dose of 100.  The confidence intervals are wide."></p>
</figure>
</div>
</div>
</div>
</section>
<section id="the-escalation-rules" class="level3">
<h3 class="anchored" data-anchor-id="the-escalation-rules">The escalation rules</h3>
<section id="the-maximum-increment" class="level4">
<h4 class="anchored" data-anchor-id="the-maximum-increment">The maximum increment</h4>
<p>Now, we define the maximum possible increment between the dose used in current cohort and the dose used in the next, regardless of likely toxicity.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for dose increments.</span></span>
<span id="cb5-2">my_increments <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelative</span>(</span>
<span id="cb5-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>),</span>
<span id="cb5-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb5-5">)</span></code></pre></div></div>
</div>
<p>The rule we have chosen here defines the maximum possible increment in terms of multiples of the highest dose so far administered: for doses greater than <code>0</code> and less than <code>20</code>, the maximum increment is 100% x 2, or 200% of the highest dose used so far (or an escalation to 100% x (1 + 2) = 300% of the highest dose used so far). For doses of <code>20</code> or more, the maximum increment is 100% x 0.5, or 50% of the highest dose used so far, to a dose no more than 100% x (1 + 0.5) = 150% of the highest dose used so far.</p>
<blockquote class="blockquote">
<p>Note that a 2-fold <em>increment</em> corresponds to a 3-fold <em>escalation</em>.</p>
</blockquote>
<p>In tabular form, based on the dose grid defined above, the maximum permitted escalation is</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: right;">Highest dose<br>administered so far</th>
<th style="text-align: right;">Maximum permitted increment</th>
<th style="text-align: right;">Maximum permitted dose</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">2.0</td>
<td style="text-align: right;">3.0</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">6.0</td>
<td style="text-align: right;">9.0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">9</td>
<td style="text-align: right;">18.0</td>
<td style="text-align: right;">27.0</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">40.0</td>
<td style="text-align: right;">60.0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">30</td>
<td style="text-align: right;">45.0</td>
<td style="text-align: right;">75.0</td>
</tr>
<tr class="even">
<td style="text-align: right;">45</td>
<td style="text-align: right;">67.5</td>
<td style="text-align: right;">112.5</td>
</tr>
<tr class="odd">
<td style="text-align: right;">60</td>
<td style="text-align: right;">90.0</td>
<td style="text-align: right;">150.0</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">120.0</td>
<td style="text-align: right;">200.0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">100</td>
<td style="text-align: right;">200.0</td>
<td style="text-align: right;">Not applicable</td>
</tr>
</tbody>
</table>
<p>So, if the highest dose used so far is <code>9</code>, the highest dose in the dose grid that can be used in the next cohort is <code>20</code>, even if <code>30</code> or higher doses are deemed safe by the <code>NextBest</code> rule.</p>
<p>Next, we define the rule for choosing the <em>best</em> dose for the <em>next</em> cohort</p>
</section>
<section id="the-nextbest-rule-for-recommending-the-best-dose-for-the-next-cohort" class="level4">
<h4 class="anchored" data-anchor-id="the-nextbest-rule-for-recommending-the-best-dose-for-the-next-cohort">The NextBest rule for recommending the best dose for the next cohort</h4>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for selecting the next dose.</span></span>
<span id="cb6-2">my_next_best <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestNCRM</span>(</span>
<span id="cb6-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>),</span>
<span id="cb6-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overdose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb6-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_overdose_prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span></span>
<span id="cb6-6">)</span></code></pre></div></div>
</div>
<p>Here, we choose to use Neuenschwander’s rule <span class="citation" data-cites="Neuenschwander2008">(Neuenschwander, Branson, and Gsponer 2008)</span>, in which the dose for the next cohort to be the dose (amongst those doses that are eligible for selection according to the escalation rule) that has the highest posterior chance of having a probability of toxicity in the target range - here [0.2, 0.35) - provided that the dose’s chance of having a probability of toxicity in the overdose range - here [0.35, 1.0] - is less than 0.25.</p>
</section>
<section id="the-cohort-size" class="level4">
<h4 class="anchored" data-anchor-id="the-cohort-size">The cohort size</h4>
<p>Now, we define the rule for choosing the size of the next cohort.</p>
<blockquote class="blockquote">
<p>Note, the term “cohort size” is somewhat anachronistic. It is a hangover from the days of the 3+3 design. In the context of CRM trials, it is best interpreted as “the largest permitted interval between CRM model updates”. In a CRM trial, the model can be updated <em>at any time</em> and there is no mathematical need to halt recruitment to allow the model to be updated.</p>
</blockquote>
<p>We elect to define the cohort size using a compound rule. Both the dose to be used and the number of DLTs so far observed contribute to the decision. The first part of the compound rule (<code>my_size_1</code>), based on the dose to be used, permits the use a single patient run-in up to and including a dose of <code>20</code>. For doses above <code>20</code>, the minimum cohort size is <code>3</code>. The second part of the compound rule (<code>my_size_2</code>) also permits a single patient run-in, so long as no DLTs have so far been observed. As soon as the first DLT is reported, the minimum cohort size is <code>3</code>. To determine the <em>actual</em> size of the next cohort, the larger number required by the two parts of the compound rule is used.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for the cohort size.</span></span>
<span id="cb7-2">my_size_1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeRange</span>(</span>
<span id="cb7-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>),</span>
<span id="cb7-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb7-5">)</span>
<span id="cb7-6">my_size_2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeDLT</span>(</span>
<span id="cb7-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb7-9">)</span>
<span id="cb7-10">my_size <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxSize</span>(my_size_1, my_size_2)</span></code></pre></div></div>
</div>
<p>In other words, provided the dose is <code>20</code> or below and no DLTs have been observed, a single patient cohort is permitted. In all other cases, the required cohort size is <code>3</code>.</p>
</section>
</section>
<section id="the-stopping-rules" class="level3">
<h3 class="anchored" data-anchor-id="the-stopping-rules">The stopping rules</h3>
<p>Now we create the rules that define when the trial’s objectives have been met (or when it should be stopped for futility).<br>
The futility rule is the easiest to explain: if twenty patients have been recruited, the study should stop (<code>my_stopping_3</code>). The success rule requires both of the following conditions to have been met:</p>
<ul>
<li>At least three cohorts must have been treated</li>
<li>The probability that the current estimate of the MTD is in the target toxicity range must be at least 0.5.</li>
</ul>
<p>The trial will stop of either the futility rule or <em>both</em> components of the success rule are satisfied.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for stopping.</span></span>
<span id="cb8-2">my_stopping_1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinCohorts</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nCohorts =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb8-3">my_stopping_2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingTargetProb</span>(</span>
<span id="cb8-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>),</span>
<span id="cb8-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span></span>
<span id="cb8-6">)</span>
<span id="cb8-7">my_stopping_3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinPatients</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>)</span>
<span id="cb8-8">my_stopping <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (my_stopping_1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> my_stopping_2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> my_stopping_3</span></code></pre></div></div>
</div>
</section>
<section id="the-overall-trial-design" class="level3">
<h3 class="anchored" data-anchor-id="the-overall-trial-design">The overall trial design</h3>
<p>Finally, we combine all six elements of the design, together with the starting dose, to define the trial.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Initialize the design.</span></span>
<span id="cb9-2">design <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Design</span>(</span>
<span id="cb9-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model,</span>
<span id="cb9-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> my_next_best,</span>
<span id="cb9-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> my_stopping,</span>
<span id="cb9-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> my_increments,</span>
<span id="cb9-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> my_size,</span>
<span id="cb9-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> empty_data,</span>
<span id="cb9-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb9-10">)</span></code></pre></div></div>
</div>
<p>We are now ready to use our trial definition, either to analyse a real trial or to simulate the long term operating characteristics of the design. These processes are described in their own vignettes <a href="trial_analysis.html">here</a> and <a href="trial_simulation.html">here</a>.</p>
</section>
</section>
<section id="references" class="level2">




</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-Neuenschwander2008" class="csl-entry">
Neuenschwander, Beat, Michael Branson, and Thomas Gsponer. 2008. <span>“<span class="nocase">Critical aspects of the Bayesian approach to phase I cancer trials.</span>”</span> <em>Statistics in Medicine</em> 27 (13): 2420–39. <a href="https://onlinelibrary.wiley.com/doi/10.1002/sim.3230">https://onlinelibrary.wiley.com/doi/10.1002/sim.3230</a>.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Getting started</category>
  <guid>https://www.crmpack.org/vignettes/getting-started/crmPack_design/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_09.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Important sanity checks for a dose escalation trial design</title>
  <dc:creator>John Kirkpatrick, Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/getting-started/crmPack_checks/</link>
  <description><![CDATA[ 




<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>This vignette contains an example of a very basic and superficial examination of the operating characteristics of a basic CRM trial. The design uses a 2-parameter logistic regression model with a log normal prior distribution, and custom rules for choosing the cohort size, deciding whether to stop or continue the trial, defining the maximum permitted increment and selecting the dose for the nest study.</p>
<p>The first step is to define the trial design in <code>crmPack</code>.</p>
</section>
<section id="study-definition" class="level2">
<h2 class="anchored" data-anchor-id="study-definition">Study definition</h2>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(crmPack)</span>
<span id="cb1-2"></span>
<span id="cb1-3"></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Define the dose grid and an empty data object</span></span>
<span id="cb1-5">dose_grid <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb1-6">empty_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> dose_grid)</span>
<span id="cb1-7"></span>
<span id="cb1-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Initialize the CRM model.</span></span>
<span id="cb1-9">initial_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticLogNormal</span>(</span>
<span id="cb1-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb1-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb1-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ref_dose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">56</span></span>
<span id="cb1-13">)</span>
<span id="cb1-14"></span>
<span id="cb1-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for selecting the next dose.</span></span>
<span id="cb1-16">next_best <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestNCRM</span>(</span>
<span id="cb1-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>),</span>
<span id="cb1-18">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overdose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb1-19">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_overdose_prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span></span>
<span id="cb1-20">)</span>
<span id="cb1-21"></span>
<span id="cb1-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for the cohort size.</span></span>
<span id="cb1-23">cohort_size1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeRange</span>(</span>
<span id="cb1-24">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>),</span>
<span id="cb1-25">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb1-26">)</span>
<span id="cb1-27">cohort_size2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeDLT</span>(</span>
<span id="cb1-28">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb1-29">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb1-30">)</span>
<span id="cb1-31">cohort_size <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxSize</span>(cohort_size1, cohort_size2)</span>
<span id="cb1-32"></span>
<span id="cb1-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for stopping.</span></span>
<span id="cb1-34">stopping_success1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinCohorts</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nCohorts =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb1-35">stopping_success2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingTargetProb</span>(</span>
<span id="cb1-36">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>),</span>
<span id="cb1-37">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span></span>
<span id="cb1-38">)</span>
<span id="cb1-39">stopping_futility <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinPatients</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>)</span>
<span id="cb1-40">stopping_trial <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (stopping_success1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> stopping_success2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> stopping_futility</span>
<span id="cb1-41"></span>
<span id="cb1-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Choose the rule for dose increments.</span></span>
<span id="cb1-43">increment_rule <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelative</span>(</span>
<span id="cb1-44">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>),</span>
<span id="cb1-45">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.33</span>)</span>
<span id="cb1-46">)</span>
<span id="cb1-47"></span>
<span id="cb1-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Initialize the design.</span></span>
<span id="cb1-49">design <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Design</span>(</span>
<span id="cb1-50">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> initial_model,</span>
<span id="cb1-51">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> next_best,</span>
<span id="cb1-52">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> stopping_trial,</span>
<span id="cb1-53">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> increment_rule,</span>
<span id="cb1-54">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> cohort_size,</span>
<span id="cb1-55">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> empty_data,</span>
<span id="cb1-56">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb1-57">)</span></code></pre></div></div>
</div>
</section>
<section id="incoherence-and-rigidity" class="level2">
<h2 class="anchored" data-anchor-id="incoherence-and-rigidity">Incoherence and rigidity</h2>
<p>The <code>examine</code> function lists the dose recommendations made by CRM design after the first DLT is reported. The output shows, for each dose and number of DLTs reported, the dose recommendation (<code>nextBest</code> dose) made by the model on the assumption that no earlier DLTs were reported at lower doses.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">examine</span>(design) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: right;">dose</th>
<th style="text-align: right;">DLTs</th>
<th style="text-align: right;">nextDose</th>
<th style="text-align: left;">stop</th>
<th style="text-align: right;">increment</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">3</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">5</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">67</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: right;">5</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">10</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">100</td>
</tr>
<tr class="even">
<td style="text-align: right;">5</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-40</td>
</tr>
<tr class="odd">
<td style="text-align: right;">10</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">20</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">100</td>
</tr>
<tr class="even">
<td style="text-align: right;">10</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">10</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">20</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">25</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">20</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: right;">0</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Cheung <span class="citation" data-cites="dfcrm2013">(Cheung 2013)</span> (p146) describes a CRM trial* as <em>rigid</em> if there exists a dose from which escalation is not possible regardless of the number of participants who do not experience when treated at that dose. He then (p164) defines a CRM trial as <em>incoherent</em> if, among other criteria, it recommends a dose escalation immediately following the first report of a DLT.</p>
<blockquote class="blockquote">
<p>*: Strictly, Cheung defines incoherence and rigidity <em>only</em> in terms of a trial’s dose-toxicity model. We extend the terms to include all of a trial’s design features, including its escalation, dose selection, increments and stopping rules.</p>
</blockquote>
<p>The output from <code>examine</code> shows that our initial design is not incoherent (because there is no recommendation to increase the dose used in the next cohort following the first report of a DLT), but it is rigid. It is rigid because, even when no toxicities are reported at 25 mg, the model is unable to recommend escalation before the trial’s futility stopping rule (defined by <code>stopping_futility</code> above) is satisfied.</p>
<p>This is clearly unsatisfactory. The problem lies with the increments rule, which allows a maximum escalation of 33% between one dose and the next for doses above 20 mg. The dose grid being used is 1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100. The ratio between 20 and 25 is 1.25, but between 25 and 40 is 1.6. We can confirm this by checking the behaviour of <code>maxDose</code> with artificial data:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">no_tox_below_25_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb3-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> dose_grid,</span>
<span id="cb3-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>),</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>),</span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>L,</span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>L</span>
<span id="cb3-7">)</span>
<span id="cb3-8"></span>
<span id="cb3-9">next_dose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(increment_rule, no_tox_below_25_data)</span>
<span id="cb3-10">next_dose</span>
<span id="cb3-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 33.25</span></span></code></pre></div></div>
</div>
<p>Thus, the initial dose rule permanently prevents escalation above 25 mg because the highest permitted dose above 25 mg is 33.25 but the lowest such dose in the dose grid is 40. The problem can be solved in at least two ways: we can either relax the increments rule or we can introduce one or more intermediate doses. (We could, of course, do both.) We choose to relax the increments rule and check that, ceteris paribus, this permits escalation from every dose:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">revised_increment_rule <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelative</span>(</span>
<span id="cb4-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>),</span>
<span id="cb4-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.67</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.33</span>)</span>
<span id="cb4-4">)</span>
<span id="cb4-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb4-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">HighestDoseUsed =</span> dose_grid,</span>
<span id="cb4-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">MaxPermittedDose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb4-8">    <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb4-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(</span>
<span id="cb4-10">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(dose_grid[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb4-11">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(n) {</span>
<span id="cb4-12">        tmp <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dose_grid[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb4-13">        d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb4-14">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> dose_grid,</span>
<span id="cb4-15">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> tmp[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n],</span>
<span id="cb4-16">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, n),</span>
<span id="cb4-17">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n),</span>
<span id="cb4-18">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n)</span>
<span id="cb4-19">        )</span>
<span id="cb4-20">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(revised_increment_rule, d)</span>
<span id="cb4-21">      }</span>
<span id="cb4-22">    )</span>
<span id="cb4-23">  )</span>
<span id="cb4-24">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">EscalationPermitted =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lead</span>(HighestDoseUsed <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> MaxPermittedDose)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: right;">HighestDoseUsed</th>
<th style="text-align: right;">MaxPermittedDose</th>
<th style="text-align: left;">EscalationPermitted</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">6.00</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: right;">5</td>
<td style="text-align: right;">10.00</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: right;">10</td>
<td style="text-align: right;">20.00</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: right;">15</td>
<td style="text-align: right;">30.00</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">33.40</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">41.75</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: right;">40</td>
<td style="text-align: right;">66.80</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">83.50</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">106.40</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: right;">100</td>
<td style="text-align: right;">133.00</td>
<td style="text-align: left;">NA</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Yes, it does. So we update the design:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">revised_design <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Design</span>(</span>
<span id="cb5-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> initial_model,</span>
<span id="cb5-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> next_best,</span>
<span id="cb5-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> stopping_trial,</span>
<span id="cb5-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> revised_increment_rule,</span>
<span id="cb5-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> cohort_size,</span>
<span id="cb5-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> empty_data,</span>
<span id="cb5-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb5-9">)</span></code></pre></div></div>
</div>
</section>
<section id="does-the-prior-make-sense" class="level2">
<h2 class="anchored" data-anchor-id="does-the-prior-make-sense">Does the prior make sense?</h2>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">examine</span>(revised_design) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: right;">dose</th>
<th style="text-align: right;">DLTs</th>
<th style="text-align: right;">nextDose</th>
<th style="text-align: left;">stop</th>
<th style="text-align: right;">increment</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">3</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">5</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">67</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-67</td>
</tr>
<tr class="odd">
<td style="text-align: right;">5</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">10</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">100</td>
</tr>
<tr class="even">
<td style="text-align: right;">5</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-40</td>
</tr>
<tr class="odd">
<td style="text-align: right;">10</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">20</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">100</td>
</tr>
<tr class="even">
<td style="text-align: right;">10</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">10</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">20</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">25</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">20</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">40</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">60</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">40</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">25</td>
</tr>
<tr class="even">
<td style="text-align: right;">40</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">40</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">40</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-38</td>
</tr>
<tr class="even">
<td style="text-align: right;">40</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">20</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-50</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">40</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-20</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">40</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-20</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">40</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-20</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: right;">0</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Hmmm. We now appear to be stuck at 50 mg. Why is this? Let’s examine the state of the model after escalation to 50 mg without toxicity…</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">no_tox_below_50_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb7-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> dose_grid,</span>
<span id="cb7-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>),</span>
<span id="cb7-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>),</span>
<span id="cb7-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>L,</span>
<span id="cb7-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>L, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>L<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>L, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">each =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb7-7">)</span>
<span id="cb7-8"></span>
<span id="cb7-9">default_mcmc_options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>)</span>
<span id="cb7-10">no_tox_50_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(no_tox_below_50_data, initial_model, default_mcmc_options)</span>
<span id="cb7-11">recommended_dose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb7-12">  next_best,</span>
<span id="cb7-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>,</span>
<span id="cb7-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> no_tox_50_samples,</span>
<span id="cb7-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> initial_model,</span>
<span id="cb7-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> no_tox_below_50_data</span>
<span id="cb7-17">)</span>
<span id="cb7-18">recommended_dose<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb7-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 50</span></span>
<span id="cb7-20">recommended_dose<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>probs</span>
<span id="cb7-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;       dose target overdose</span></span>
<span id="cb7-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1,]    1  0.000    0.000</span></span>
<span id="cb7-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [2,]    3  0.000    0.000</span></span>
<span id="cb7-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [3,]    5  0.000    0.000</span></span>
<span id="cb7-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [4,]   10  0.000    0.000</span></span>
<span id="cb7-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [5,]   15  0.000    0.000</span></span>
<span id="cb7-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [6,]   20  0.005    0.000</span></span>
<span id="cb7-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [7,]   25  0.008    0.000</span></span>
<span id="cb7-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [8,]   40  0.050    0.008</span></span>
<span id="cb7-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [9,]   50  0.154    0.028</span></span>
<span id="cb7-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [10,]   80  0.148    0.770</span></span>
<span id="cb7-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [11,]  100  0.080    0.871</span></span>
<span id="cb7-33"></span>
<span id="cb7-34"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(revised_increment_rule, no_tox_below_50_data)</span>
<span id="cb7-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 83.5</span></span></code></pre></div></div>
</div>
<p>Whilst the increments rule allows escalation to 83.5 mg, the toxicity estimates provided by the model do not: the current estimate of toxicity at 80 mg is 0.77, well above the limit of 0.25 defined in the dose recommendation rule (<code>next_best</code>).</p>
<p>Again, we have several options. We can introduce intermediate doses, thus slowing escalation and allowing the prior model more time to adapt (but probably requiring a larger trial), or we can modify the prior so that it allows faster, but still reasonable, escalation. Let’s try creating a minimally informative prior that is consistent with our first attempt.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fitting the min_inf_model is slow.</span></span>
<span id="cb8-2"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.exists</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"minInfModel.Rds"</span>)) {</span>
<span id="cb8-3">  min_inf_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readRDS</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"minInfModel.Rds"</span>)</span>
<span id="cb8-4">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb8-5">  min_inf_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">MinimalInformative</span>(</span>
<span id="cb8-6">    dose_grid,</span>
<span id="cb8-7">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">56</span>,</span>
<span id="cb8-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">threshmin =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>,</span>
<span id="cb8-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">threshmax =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>,</span>
<span id="cb8-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">probmin =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>,</span>
<span id="cb8-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">probmax =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span></span>
<span id="cb8-12">  )</span>
<span id="cb8-13"></span>
<span id="cb8-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as_tibble</span>(min_inf_model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>required) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_column</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Dose =</span> dose_grid) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_column</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Required"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb8-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as_tibble</span>(min_inf_model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>quantiles) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-19">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_column</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Dose =</span> dose_grid) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-20">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_column</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fitted"</span>)</span>
<span id="cb8-21">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> Dose, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> median, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> Type), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"solid"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> Dose, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> lower, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> Type), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> Dose, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> upper, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> Type), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>)</span>
<span id="cb8-26"></span>
<span id="cb8-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">saveRDS</span>(min_inf_model, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"minInfModel.Rds"</span>)</span>
<span id="cb8-28">}</span>
<span id="cb8-29"></span>
<span id="cb8-30">min_inf_model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>params</span></code></pre></div></div>
<div class="cell-output-display">
<p>The prior for θ is given by<img src="https://latex.codecogs.com/png.latex?%20%5Cboldsymbol%5Ctheta%20=%20%5Cbegin%7Bbmatrix%7D%5Calpha%20%5C%5C%20%5Cbeta%5Cend%7Bbmatrix%7D%5Csim%20N%20%5Cleft(%5Cbegin%7Bbmatrix%7D%200.98%20%5C%5C%20%201.35%5Cend%7Bbmatrix%7D%20,%20%5Cbegin%7Bbmatrix%7D%201.92%20&amp;%20%200.05%20%5C%5C%200.05%20&amp;%20%200.00%5Cend%7Bbmatrix%7D%20%5Cright)%20"></p>
</div>
</div>
<p>The minimally informative model has a prior distribution of</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbinom%7B%5Calpha%7D%7Blog(%5Cbeta)%7D%20%5Csim%20N%20%5Cleft(%20%5Cleft%5B%5Cbegin%7Barray%7D%7Brr%7D%200.979%20%5C%5C%20%201.348%20%5Cend%7Barray%7D%5Cright%5D,%20%5Cleft%5B%5Cbegin%7Barray%7D%7Brr%7D%20%201.923%20&amp;%20%200.045%20%5C%5C%20%200.045%20&amp;%20%200.002%5Cend%7Barray%7D%5Cright%5D%5Cright)"></p>
<p>Does this fix the rigidity problem?</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">revised_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> min_inf_model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>model</span>
<span id="cb9-2"></span>
<span id="cb9-3">revised_design1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Design</span>(</span>
<span id="cb9-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> revised_model,</span>
<span id="cb9-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> next_best,</span>
<span id="cb9-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> stopping_trial,</span>
<span id="cb9-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> revised_increment_rule,</span>
<span id="cb9-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> cohort_size,</span>
<span id="cb9-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> empty_data,</span>
<span id="cb9-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb9-11">)</span>
<span id="cb9-12"></span>
<span id="cb9-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">examine</span>(revised_design1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: right;">dose</th>
<th style="text-align: right;">DLTs</th>
<th style="text-align: right;">nextDose</th>
<th style="text-align: left;">stop</th>
<th style="text-align: right;">increment</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">3</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">5</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">67</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">5</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">10</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">100</td>
</tr>
<tr class="even">
<td style="text-align: right;">5</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-40</td>
</tr>
<tr class="odd">
<td style="text-align: right;">10</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">10</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">10</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">5</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-50</td>
</tr>
<tr class="odd">
<td style="text-align: right;">10</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">15</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">50</td>
</tr>
<tr class="even">
<td style="text-align: right;">10</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">5</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-50</td>
</tr>
<tr class="odd">
<td style="text-align: right;">15</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">20</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">33</td>
</tr>
<tr class="even">
<td style="text-align: right;">15</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">10</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-33</td>
</tr>
<tr class="odd">
<td style="text-align: right;">20</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">20</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">10</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-50</td>
</tr>
<tr class="odd">
<td style="text-align: right;">20</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">25</td>
</tr>
<tr class="even">
<td style="text-align: right;">20</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">15</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-25</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">15</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-40</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">20</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-20</td>
</tr>
<tr class="odd">
<td style="text-align: right;">25</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">40</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">60</td>
</tr>
<tr class="even">
<td style="text-align: right;">25</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">40</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">25</td>
</tr>
<tr class="even">
<td style="text-align: right;">40</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-38</td>
</tr>
<tr class="odd">
<td style="text-align: right;">40</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-38</td>
</tr>
<tr class="even">
<td style="text-align: right;">40</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">20</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-50</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">80</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">60</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">50</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">40</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-20</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-50</td>
</tr>
<tr class="odd">
<td style="text-align: right;">80</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">100</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">25</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-38</td>
</tr>
<tr class="odd">
<td style="text-align: right;">80</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-38</td>
</tr>
<tr class="even">
<td style="text-align: right;">80</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">40</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">-50</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Yes, it does. We can now escalate to dose 80, but there are few plateaux as we do so. First, two toxicity-free participants, rather than just one, are needed to escalate from 20 mg to 25 mg. Similarly, four toxicity-free participants are required to escalate from 25 mg to 40 mg. Further fine tuning of the prior would probably allow these numbers to be reduced, but for the purposes of this vignette, we do not explore this possibility.</p>
<p>Now create some data that represent a trial that escalates without any reports of toxicity, and fit the revised model …</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">no_tox_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb10-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>),</span>
<span id="cb10-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">each =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)),</span>
<span id="cb10-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span>),</span>
<span id="cb10-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">each =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))),</span>
<span id="cb10-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span>)</span>
<span id="cb10-7">)</span>
<span id="cb10-8"></span>
<span id="cb10-9">no_tox_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(no_tox_data, revised_model, default_mcmc_options)</span>
<span id="cb10-10"></span>
<span id="cb10-11">recommended_dose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb10-12">  next_best,</span>
<span id="cb10-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>,</span>
<span id="cb10-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> no_tox_samples,</span>
<span id="cb10-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> initial_model,</span>
<span id="cb10-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> no_tox_data</span>
<span id="cb10-17">)</span>
<span id="cb10-18">recommended_dose<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>probs</span>
<span id="cb10-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;       dose target overdose</span></span>
<span id="cb10-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1,]    1  0.000    0.000</span></span>
<span id="cb10-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [2,]    3  0.000    0.000</span></span>
<span id="cb10-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [3,]    5  0.000    0.000</span></span>
<span id="cb10-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [4,]   10  0.000    0.000</span></span>
<span id="cb10-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [5,]   15  0.000    0.000</span></span>
<span id="cb10-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [6,]   20  0.000    0.000</span></span>
<span id="cb10-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [7,]   25  0.000    0.000</span></span>
<span id="cb10-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [8,]   40  0.006    0.000</span></span>
<span id="cb10-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [9,]   50  0.016    0.000</span></span>
<span id="cb10-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [10,]   80  0.189    0.011</span></span>
<span id="cb10-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [11,]  100  0.354    0.033</span></span>
<span id="cb10-31"></span>
<span id="cb10-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(stopping_trial, recommended_dose<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value, no_tox_samples, initial_model, no_tox_data)</span>
<span id="cb10-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span>
<span id="cb10-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb10-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]]</span></span>
<span id="cb10-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]][[1]]</span></span>
<span id="cb10-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 11 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb10-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]][[2]]</span></span>
<span id="cb10-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 35 % for dose 100 and thus below the required 50 %"</span></span>
<span id="cb10-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]]</span></span>
<span id="cb10-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 21 and thus reached the prespecified minimum number 20"</span></span>
<span id="cb10-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")</span></span>
<span id="cb10-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[1]]</span></span>
<span id="cb10-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb10-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb10-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]]</span></span>
<span id="cb10-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 11 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb10-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]]</span></span>
<span id="cb10-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 35 % for dose 100 and thus below the required 50 %"</span></span>
<span id="cb10-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")</span></span>
<span id="cb10-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[1]]</span></span>
<span id="cb10-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span>
<span id="cb10-59"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb10-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of cohorts is 11 and thus reached the prespecified minimum number 3"</span></span>
<span id="cb10-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb10-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "≥ 3 cohorts dosed"</span></span>
<span id="cb10-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[2]]</span></span>
<span id="cb10-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb10-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb10-67"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 35 % for dose 100 and thus below the required 50 %"</span></span>
<span id="cb10-68"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb10-69"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5"</span></span>
<span id="cb10-70"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-71"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb10-72"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] NA</span></span>
<span id="cb10-73"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-74"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[2]]</span></span>
<span id="cb10-75"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span>
<span id="cb10-76"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb10-77"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 21 and thus reached the prespecified minimum number 20"</span></span>
<span id="cb10-78"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb10-79"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "≥ 20 patients dosed"</span></span>
<span id="cb10-80"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-81"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb10-82"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] NA</span></span></code></pre></div></div>
</div>
<p>More importantly, these results illustrate something that should have been obvious from the outset: expecting the trial to identify the MTD definitively in fewer than 20 participants is unrealistic (unless the MTD is very much towards the left hand - lower - end of the dose grid) because it takes almost 20 participants to travel from the lower end of the dose grid to the upper. Ignoring the plateauing mentioned in the previous paragraph, the increments rule we defined means that we need at least one participant at doses of 1, 3, 5, 10, 15 and 20 mg, and three at each of 25, 40, 50, 80 and 100 mg. That’s a total of 6 x 1 + 5 x 3 = 21 participants. So we hit the futility limit before we finish escalation over the dose grid, even if no DLTs are reported. That’s simply not realistic.</p>
<p>So our final alteration is to increase the futility rule from 20 participants to 40.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">revised_stopping_futility <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinPatients</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>)</span>
<span id="cb11-2">revised_stopping_trial <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (stopping_success1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> stopping_success2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> revised_stopping_futility</span>
<span id="cb11-3"></span>
<span id="cb11-4">revised_design2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Design</span>(</span>
<span id="cb11-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> revised_model,</span>
<span id="cb11-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> next_best,</span>
<span id="cb11-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> revised_stopping_trial,</span>
<span id="cb11-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> revised_increment_rule,</span>
<span id="cb11-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> cohort_size,</span>
<span id="cb11-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> empty_data,</span>
<span id="cb11-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb11-12">)</span></code></pre></div></div>
</div>
<p>This new design allows us to escalate over the full extent of the dose grid before the futility stopping rule kicks in. Further refinement of the prior model may remove the need for additional cohorts before escalation from 20, 25 and 50 mg. We leave that as an exercise for the reader.</p>
<p>We now have a design that is worthy of more detailed investigation of its operating characteristics. We will do this in the next vignette in the series, which is yet to be written.</p>
</section>
<section id="final-observation" class="level2">
<h2 class="anchored" data-anchor-id="final-observation">Final observation</h2>
<p>The simulations used in this vignette have used relatively short chains of 1000 samples, purely in the interests of speed. When investigating the properties of a real trial, much longer chain lengths should be used. For example, to estimate a binomial probability to an accuracy of ±1%, an effective sample size (ESS) of around 40,000 is required.</p>
</section>
<section id="references" class="level2">




</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-dfcrm2013" class="csl-entry">
Cheung, Ken. 2013. <em>: Dose-Finding by the Continual Reassessment Method</em>. <a href="https://www.routledge.com/Dose-Finding-by-the-Continual-Reassessment-Method/Cheung/p/book/9781420091519">https://www.routledge.com/Dose-Finding-by-the-Continual-Reassessment-Method/Cheung/p/book/9781420091519</a>.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Getting started</category>
  <guid>https://www.crmpack.org/vignettes/getting-started/crmPack_checks/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_08.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Model-based dose escalation designs with crmPack (JSS paper)</title>
  <dc:creator>Daniel Sabanés Bové, Wai Yin Yeung, Giuseppe Palermo, Thomas Jaki</dc:creator>
  <link>https://www.crmpack.org/vignettes/getting-started/crmPack_paper/</link>
  <description><![CDATA[ 




<section id="abstract" class="level1">
<h1>Abstract</h1>
<p>Model-based dose escalation designs have gained increasing interest due to the need for more efficient and informative Phase I trials. The wide-spread implementation of such designs has been hindered by the need for either licensing specialized commercial software or programming the design and simulations from scratch for each project. The <code>R</code>-package <code>crmPack</code> provides a simple and unified object-oriented framework for model-based dose escalation designs. This enables the standard use of such designs, while being able to flexibly adapt and extend them. The framework comprises classes and methods for the data structure including the dose grid, statistical models including prior specification, rules for maximum increments, next best dose, and adaptive stopping and cohort sizes. In addition to multiple modified classic continual reassessment method and escalation with overdose control designs with possibly advanced prior specifications (e.g., minimal informative and mixture priors), <code>crmPack</code> currently features dual-endpoint (safety and biomarker) designs and two-part designs. Optional assignment of a small number of patients in each cohort to placebo instead of treatment enables the use in trials outside Oncology.</p>
<p><em>Keywords</em>: continual reassessment method, model based dose escalation, dual-endpoint design, R, object oriented.</p>
</section>
<section id="introduction" class="level1">
<h1>Introduction</h1>
<p>Phase I trials that are testing new investigational agents in humans for the first time escalate from low to high doses in a sequential fashion. This dose escalation design is necessary in order to reduce the risk of too high and therefore too toxic doses for the probands. These can either be healthy volunteers (e.g., in neurology) or patients (e.g., in oncology), and we will henceforth use only the latter for ease of presentation. While higher doses of agents are usually expected to deliver stronger pharmacodynamic effects and hence improved efficacy, higher doses also usually cause more severe adverse events in the patients. In order to simplify the decision making usually binary dose-limiting toxicities (DLTs) are defined (e.g., adverse events reaching specific severity levels) before starting the trial. The maximum tolerated dose (MTD) is then defined as the dose with a certain probability of DLTs (either using a single value, e.g., 33%, or a range, e.g., 20 to 35%). Historically, patients were treated at the same dose in cohorts of three, with the dose for the next cohort then being determined from the number of DLTs having been observed in the current cohort.</p>
<p>Algorithmic designs like the simple 3+3 design <span class="citation" data-cites="carter1973">(Carter 1973)</span> have disadvantages that have been recognized in the statistics community, see e.g., <span class="citation" data-cites="Paoletti2015">(Paoletti, Ezzalfani, and Le Tourneau 2015)</span>. Fundamentally, the escalation rules of the 3+3 design do not have any statistical justification <span class="citation" data-cites="Storer1989">(Storer 1989)</span> in terms of estimating an MTD. Moreover, they cannot be extended to address today’s Phase I trials, with extension cohorts, dose escalation of drug combinations and optimal biological dose determination, naming just a few prominent challenges. Hence model-based dose escalation designs like the continual reassessment method (CRM) <span class="citation" data-cites="oquigley1990">(O’Quigley, Pepe, and Fisher 1990)</span> have gained increasing interest due to the need for more efficient and informative Phase I trials. These designs are based in statistical inference, with dose-toxicity regression models as the backbone, and are therefore flexible for adaptation to various complex trial designs. Importantly, they avoid fixing only a few dose levels in advance. For a wider comparison of algorithmic and model based designs see e.g., <span class="citation" data-cites="jaki2013">(Jaki, Clive, and Weir 2013)</span>.</p>
<p>However, the wide-spread implementation of such designs has been hindered by the need for either licensing specialized commercial software (thus losing flexibility) or programming the design and simulations from scratch for each project (thus losing efficiency). While the models underlying most model-based dose escalation procedures can easily be fit in standard software with the capability to fit generalized linear models, e.g., <code>PROC MIXED</code> in <code>SAS</code> <span class="citation" data-cites="SAS2003">( Institute Inc. 2003)</span>, <code>glm</code> in <code>Stata</code> <span class="citation" data-cites="Stata2015">(StataCorp 2015)</span> or <code>R</code> <span class="citation" data-cites="R2016">( Core Team 2016)</span>, there are still only few software solutions available dedicated to dose escalation studies.</p>
<p>The commercial packages <code>East</code> <span class="citation" data-cites="East2016">(Cytel Inc. 2016)</span> and <code>ADDPLAN</code> <span class="citation" data-cites="Addplan2025">(Consultants 2025)</span> both offer extensions to their basic design software for dose escalation studies (<code>ESCALATE</code> in <code>East</code> and <code>df</code> in <code>ADDPLAN</code>) implementing the algorithmic 3+3 design and various versions of the CRM. Similarly <code>FACTS</code> <span class="citation" data-cites="FACTS">(Team 2015)</span> also offers different common dose escalation methods. Due to the commercial nature of these implementations there is, however, a limitation on how much the designs can be tailored towards the individual needs of the study. Similarly static implementations of methods for dose escalation are available in the <code>Stata</code> module <code>crm</code> <span class="citation" data-cites="StataCRM">(Mander 2013)</span> which implements the CRM and the <code>dfcrm</code> package <span class="citation" data-cites="dfcrm2013">(K. Cheung 2013)</span> in <code>R</code> which additionally implements the time-to-event CRM (TITE-CRM) <span class="citation" data-cites="cheung2000">(Y. K. Cheung and Chappell 2000)</span>. Several <code>R</code>-packages with extensions are available. The <code>bcrm</code> package <span class="citation" data-cites="sweeting2013">(M. Sweeting, Mander, and Sabin 2013)</span> implements a variety of one and two parameter models, and facilitates different ways to specify prior distributions, escalation and stopping rules. The <code>ordcrm</code> package <span class="citation" data-cites="ordcrm">(Dressler and Huang 2016)</span> implements ordinal proportional odds and continuation ratio models for CRMs. The <code>dfpk</code> package <span class="citation" data-cites="dfpk">(Toumazi, Ursino, and Zohar 2017)</span> uses pharmacokinetic data in the dose escalation.</p>
<p>In this paper we introduce the <code>R</code>-package <code>crmPack</code> <span class="citation" data-cites="crmPack">(Sabanés Bové et al. 2018)</span> for dose escalation studies, which is publicly available on CRAN. While the package’s name pays tribute to the original CRM as the first model-based dose escalation design, the package’s functionality differs from the above existing implementations in three fundamental ways. Firstly, it is written using <code>S4</code> classes and methods <span class="citation" data-cites="Chambers2008">(Chambers 2008)</span>, which allows customized methodology to be added to the package while still being able to use the existing backbone functionalities. Secondly, methods for studies with a placebo group (e.g., for healthy volunteer studies) are readily implemented. Thirdly, dual endpoint dose escalation methods that incorporate both safety and efficacy and allow determination of an optimal biological dose are already available.</p>
</section>
<section id="framework" class="level1">
<h1>Framework</h1>
<p>For describing the framework of the package we will adapt the general notation for early phase trials from <span class="citation" data-cites="Thall2010">(Thall 2010)</span>. Figure @ref(fig:schematic) summarizes the framework in a schematic.</p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_paper/schematic.png" alt="Schematic showing the general framework of an early phase dose escalation design." width="700" height="540" class="figure-img"></p>
<figcaption>Schematic of the framework</figcaption>
</figure>
</div>
</div>
</div>
<p>Separate design features are implemented as classes (shown as gray boxes) and bundled together in the overarching <code>Design</code> object. They can be processed with various methods (blue text) to run the dose escalation trial and produce results (blue boxes). For example, the <code>Data</code> and <code>GeneralModel</code> objects can be processed by the <code>mcmc</code> method in order to obtain posterior samples of the model parameters, and given the sample size and the dose for the next cohort, the updated <code>Data</code> closes the dose escalation loop. On the higher level, designs can be investigated with the <code>examine</code> and <code>simulate</code> methods to obtain hypothetical trial courses and operating characteristics, respectively. Note that individual model classes and methods are not shown here for clarity, please refer to the package documentation for details, e.g., by calling <code>crmPackHelp()</code>.’</p>
<p><strong>Data</strong> Let <img src="https://latex.codecogs.com/png.latex?x"> denote one specific treatment, chosen from the set of possible treatments <img src="https://latex.codecogs.com/png.latex?%7B%5Ccal%20X%7D">. This could be one specific dose, but also more generally a vector, containing for example doses of multiple drugs in a combination trial. After giving treatment <img src="https://latex.codecogs.com/png.latex?x"> to a patient, the outcome <img src="https://latex.codecogs.com/png.latex?y"> is observed, typically a safety endpoint as e.g., the binary DLT <img src="https://latex.codecogs.com/png.latex?y%20%5Cin%20%5C%7B0,%0A1%5C%7D">. Grouping together <img src="https://latex.codecogs.com/png.latex?n_%7Bj%7D"> patients in cohort <img src="https://latex.codecogs.com/png.latex?j">, generating the cohort <img src="https://latex.codecogs.com/png.latex?j"> data <img src="https://latex.codecogs.com/png.latex?%7B%5Ccal%20C%7D_%7Bj%7D%20=%20%5C%7B(x_%7Bj%7D,%20y_%7Bj,1%7D),%20%5Cdotsc,%20(x_%7Bj%7D,%0Ay_%7Bj,n_%7Bj%7D%7D)%5C%7D">, we can denote the data generated from the first <img src="https://latex.codecogs.com/png.latex?N"> cohorts as <img src="https://latex.codecogs.com/png.latex?%7B%5Ccal%20D%7D_%7BN%7D=%20%7B%5Ccal%20C%7D_%7B1%7D%20%5Ccup%20%5Cdotsb%20%5Ccup%20%7B%5Ccal%20C%7D_%7BN%7D">.</p>
<p>In <code>crmPack</code> the <code>S4</code> class <code>GeneralData</code> encapsulates this notion and subclasses implement concrete data structures.</p>
<p><strong>Model</strong> The core of model-based dose escalation designs is the underlying statistical model. Taking a Bayesian approach to inference, the model in <code>crmPack</code> consists of firstly the likelihood, which is either a probability density function <img src="https://latex.codecogs.com/png.latex?%20f(y%20%7C%20x,%0A%5Ctheta)"> or a probability mass function <img src="https://latex.codecogs.com/png.latex?%20Prob(Y=y%20%7C%20x,%20%5Ctheta)"> of <img src="https://latex.codecogs.com/png.latex?y"> for a patient who receives treatment <img src="https://latex.codecogs.com/png.latex?x"> assuming the parameter (vector) <img src="https://latex.codecogs.com/png.latex?%5Ctheta">, (this is the likelihood of <img src="https://latex.codecogs.com/png.latex?%5Ctheta">) and secondly the prior <img src="https://latex.codecogs.com/png.latex?%20p(%5Ctheta%20%7C%20%5Cxi)"> for <img src="https://latex.codecogs.com/png.latex?%5Ctheta"> given fixed hyperparameters <img src="https://latex.codecogs.com/png.latex?%5Cxi">.</p>
<p>In <code>crmPack</code> the virtual <code>S4</code> class <code>GeneralModel</code> encapsulates this notion and subclasses implement concrete models.</p>
<p>For example, the class <code>LogisticLogNormal</code> implements the logistic regression model <span class="citation" data-cites="Neuenschwander2008">(Neuenschwander, Branson, and Gsponer 2008)</span> with <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Clabel%7Beq:LogisticLogNormal%7D%0A%5Cmathrm%7Blogit%7D(Prob(Y=1%20%7C%20x,%5Ctheta))%0A%5Cequiv%20%5Cmathrm%7Blogit%7D(%5Cpi(x,%5Ctheta))%0A=%20%5Calpha_%7B0%7D%20+%20%5Calpha_%7B1%7D%20%5Clog%5Cleft(%5Cfrac%7Bx%7D%7Bx%5E*%7D%5Cright),%0A%5Cend%7Bequation%7D"> parameter vector <img src="https://latex.codecogs.com/png.latex?%5Ctheta%20=%20(%5Calpha_%7B0%7D,%5Calpha_%7B1%7D)">, dose <img src="https://latex.codecogs.com/png.latex?x%20%3E%200"> and specified reference dose <img src="https://latex.codecogs.com/png.latex?x%5E%7B*%7D">. The prior <img src="https://latex.codecogs.com/png.latex?p(%5Ctheta%20%7C%20%5Cxi)"> is specified via a bivariate normal distribution on a transformation of <img src="https://latex.codecogs.com/png.latex?%5Ctheta"> to ensure <img src="https://latex.codecogs.com/png.latex?%5Calpha_%7B1%7D%20%3E%200">: <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%20%20%5Clabel%7Beq:bivariateNormal%7D%0A%20%20(%5Calpha_%7B0%7D,%20%5Clog(%5Calpha_%7B1%7D))%20%7C%20%5Cxi%20%5Csim%20%5Cmathcal%7BN%7D_%7B2%7D%20(%5Cmu,%20%5CSigma)%0A%5Cend%7Bequation%7D"> with hyperparameters <img src="https://latex.codecogs.com/png.latex?%5Cxi%20=%20(%5Cmu,%20%5CSigma)"> consisting of the prior mean vector <img src="https://latex.codecogs.com/png.latex?%5Cmu"> and the prior covariance matrix <img src="https://latex.codecogs.com/png.latex?%5CSigma">.</p>
<p><strong>Decision making for the next dose</strong> Another core element of a dose escalation design concerns the decision making for the next dose <img src="https://latex.codecogs.com/png.latex?x_%7BN+1%7D"> to be tested in the next cohort <img src="https://latex.codecogs.com/png.latex?N+1">. In the <span class="citation" data-cites="Thall2010">(Thall 2010)</span> notation, the function <img src="https://latex.codecogs.com/png.latex?%5Calpha"> is mapping the currently accumulated data <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7BD%7D_%7BN%7D"> to the dose space <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7BX%7D"> (or to dose <img src="https://latex.codecogs.com/png.latex?0">, meaning to stop the trial because all doses are too toxic): <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Calpha:%20%7B%5Ccal%20D%7D_%7BN%7D%20%5Crightarrow%20%5Cmathcal%7BX%7D%20%5Ccup%20%5C%7B0%5C%7D%0A%5Cend%7Bequation%7D"> This mapping is commonly specified via the combination of two elements: The first element is a function <img src="https://latex.codecogs.com/png.latex?%5Ctau"> for the maximum increments between dose levels, which can calculate from the current data <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7BD%7D_%7BN%7D"> (including the current dose <img src="https://latex.codecogs.com/png.latex?x_%7BN%7D">) the maximum possible next dose <img src="https://latex.codecogs.com/png.latex?t_%7BN+1%7D=%5Ctau(%5Cmathcal%7BD%7D_%7BN%7D)"> for the next cohort. The second element is a rule <img src="https://latex.codecogs.com/png.latex?%5Cnu"> indirectly acting on the current data through the posterior distribution <img src="https://latex.codecogs.com/png.latex?p(%5Ctheta%20%7C%0A%5Cmathcal%7BD%7D_%7BN%7D)"> and the maximum possible dose <img src="https://latex.codecogs.com/png.latex?t_%7BN+1%7D"> to finally give the next dose <img src="https://latex.codecogs.com/png.latex?x_%7BN+1%7D%20=%20%5Cnu(p(%5Ctheta%20%7C%20%5Cmathcal%7BD%7D_%7BN%7D),%20t_%7BN+1%7D)">.</p>
<p>In <code>crmPack</code> maximum increments are specified by subclasses of <code>Increments</code>, and the next best dose rule by subclasses of <code>NextBest</code>.</p>
<p><strong>The design class</strong> Additional features of a design concern the adaptive sizing of the next cohort and the adaptive stopping of the trial. Those are implemented in subclasses of <code>CohortSize</code> and <code>Stopping</code>, respectively. Moreover, the starting dose <img src="https://latex.codecogs.com/png.latex?x_%7B1%7D"> is also a feature of the design.</p>
<p>Finally, the overall dose escalation design is bundling all the described features together in a dedicated class typically inheriting from <code>Design</code>.</p>
<p>As noted in <span class="citation" data-cites="Thall2010">(Thall 2010)</span>, the operating characteristics of such a complex dose escalation design can only be evaluated by simulations. This can be done using the <code>simulate</code> methods for the design classes, and is recommended to be performed for a multitude of different scenarios in order to stress-test the design and to convince oneself of its properties.</p>
<p>In particular, the operating characteristics reveal whether the MTD can be estimated well by the designs.</p>
<p>In addition, the <code>examine</code> method evaluates hypothetical trial outcomes and lists the resulting trial decisions (dose for the next cohort and trial end).</p>
<p>In order to illustrate the use of this object-oriented framework, the next section contains practical examples on use of the existing functionality as well as an example for creating new extensions.</p>
</section>
<section id="using-crmpack" class="level1">
<h1>Using crmPack</h1>
<p>We consider a trial in Type II diabetes carried out by Hoffmann-La Roche Ltd. in order to illustrate the functionality in the package. For each patient, we observed a binary safety (DLT) and a continuous efficacy outcome. In Implementing a CRM trial we will show how to implement a CRM design for dose escalation based on the safety endpoint only, while in Dose escalation with safety and efficacy also the efficacy endpoint will be considered. Extending crmPack functionality gives an example on extending the <code>crmPack</code> functionality.</p>
<p>Before we start, we have to install and subsequently load our package in <code>R</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"crmPack"</span>)</span></code></pre></div></div>
</div>
<blockquote class="blockquote">
<p>As indicated in the startup message, try <code>crmPackHelp()</code> and <code>crmPackExample()</code> to open the help page and the package vignette.</p>
</blockquote>
<section id="implementing-a-crm-trial" class="level2">
<h2 class="anchored" data-anchor-id="implementing-a-crm-trial">Implementing a CRM trial</h2>
<p>Suppose that 12 dose levels ranging from 25 to 300 mg in 25 mg increments of a novel agent are available in addition to placebo, defining our dose grid <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7BX%7D%20=%20%5C%7B0.001,25,%2050,%5Cdotsc,%20300%5C%7D">, with <img src="https://latex.codecogs.com/png.latex?x_%7B1%7D%20=%200.001"> mg representing placebo and <img src="https://latex.codecogs.com/png.latex?x_%7B2%7D%20=%2025"> being our starting dose. Note that here we used a very small dose instead of zero for <img src="https://latex.codecogs.com/png.latex?x_%7B1%7D">, since we consider here the regression model @eqref(eq:LogisticLogNormal) with a log transformation of the dose <img src="https://latex.codecogs.com/png.latex?x"> (with <img src="https://latex.codecogs.com/png.latex?x%5E%7B*%7D%20=%20100"> chosen as reference dose).</p>
<p><strong>Minimally informative prior</strong> Here we assume that limited prior information is available on the dose-toxicity relationship, and hence would like to use a minimally informative prior <span class="citation" data-cites="Neuenschwander2008">(Neuenschwander, Branson, and Gsponer 2008)</span> which can be easily obtained with the function <code>MinimalInformative</code>. Since stochastic optimization is used internally, setting of a seed is required for reproducibility. Furthermore, it is recommended to specify a coarse dose grid across the original dose range (excluding the placebo dose) to avoid long computation time:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">coarseGrid <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb2-2">model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">MinimalInformative</span>(</span>
<span id="cb2-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dosegrid =</span> coarseGrid, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">refDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb2-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">logNormal =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">threshmin =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>,</span>
<span id="cb2-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">threshmax =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">432</span>,</span>
<span id="cb2-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">control =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max.time =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>)</span>
<span id="cb2-7">)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>model</span></code></pre></div></div>
</div>
<p>The resulting <code>model</code> (which is an object of class <code>LogisticLogNormal</code>) has prior parameters</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cmu%20=%20(0.0720313,%202)"></p>
<p>and</p>
<p><img src="https://latex.codecogs.com/png.latex?%5CSigma=%0A%5Cleft(%5Cbegin%7Bsmallmatrix%7D%0A%20%20%201.51%20&amp;%200.18%20%5C%5C%0A%20%20%200.18%20&amp;%200.21%0A%5Cend%7Bsmallmatrix%7D%5Cright)"> and will approximately have 5% probability each for the DLT rate to exceed 10% (<code>threshmin</code> argument) at the 25&nbsp;mg dose and to be below 20% (<code>threshmax</code>) at the 300&nbsp;mg dose.</p>
<p><strong>Data object definition and visualization</strong> In this simple case of a univariate dose <img src="https://latex.codecogs.com/png.latex?x"> resulting in binary DLT observations <img src="https://latex.codecogs.com/png.latex?y">, the <code>S4</code> class <code>Data</code> can be used. Objects of this class can be created by calling the accompanying initialization function of the same name (which is a general convention in <code>crmPack</code>):</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">PL <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span></span>
<span id="cb3-2">data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb3-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(PL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, PL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, PL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>),</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(PL, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>)),</span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>,</span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placebo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb3-9">)</span></code></pre></div></div>
</div>
<p>The argument <code>x</code> takes the doses <img src="https://latex.codecogs.com/png.latex?x_%7B1%7D=0.001,%20x_%7B2%7D=25,%20x_%7B3%7D%20=%2050,%20x_%7B4%7D%20=%20100"> (note the repetition to match the outcome variables <img src="https://latex.codecogs.com/png.latex?y_%7Bj,k%7D">) where <code>doseGrid</code> captures the set <img src="https://latex.codecogs.com/png.latex?%7B%5Ccal%20X%7D"> of all possible doses, <code>y</code> takes the binary DLTs (here <img src="https://latex.codecogs.com/png.latex?y_%7B3,%203%7D%20=%201"> denotes the only DLT having been observed in the 3rd patient in the 3rd cohort), while <code>cohort</code> groups the patients together in cohorts (here <img src="https://latex.codecogs.com/png.latex?N=3">). The option <code>placebo</code> is used to specify that this is a placebo controlled study, with placebo patients included in each cohort. The lowest dose <img src="https://latex.codecogs.com/png.latex?x_%7B1%7D"> is then interpreted internally as the placebo dose. Patient IDs can be given optionally in the <code>ID</code> argument. The data can then be visualized by simply applying the <code>plot</code> function to the object, which also allows to produce a blinded plot (hiding patient IDs and placebo/treatment assignment) with the option <code>blind</code>, see Figure @ref(fig:plot-data):</p>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(data)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_paper/index_files/figure-html/plot-data-1.png" class="img-fluid figure-img" style="width:35.0%" alt="An unblinded graph with patient id on the x axis and dose administered on the y axis.  Red triangles indicate patients who reported DLTs, black circles those who did not.  Symbols are annotated with patient IDs.  Vertical dashed green lines delineate cohorts."></p>
<figcaption>Open and blinded data plots</figcaption>
</figure>
</div>
</div>
</div>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">blind =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_paper/index_files/figure-html/plot-data-blind-1.png" class="img-fluid figure-img" style="width:35.0%" alt="A blinded graph with patient id on the x axis and dose administered on the y axis.  Red triangles indicate reports of DLTs, black circles indicate an absense of DLTs.  However, within each cohort, patients with DLTs appear before those without.  Symbols are not annotated with patient IDs.  Vertical dashed green lines delineate cohorts."></p>
<figcaption>Open and blinded data plots</figcaption>
</figure>
</div>
</div>
</div>
<p><strong>Sampling from the prior and posterior</strong> Now that we have the model and the data in place, we can use MCMC sampling for obtaining the posterior distribution of the model parameters <img src="https://latex.codecogs.com/png.latex?%5Ctheta">, and hence the DLT rates <img src="https://latex.codecogs.com/png.latex?Prob(Y=1%20%7C%20x,%5Ctheta)">, at various doses <img src="https://latex.codecogs.com/png.latex?x">. The MCMC sampling can be controlled with an object of class <code>McmcOptions</code>, which is then provided to the <code>mcmc</code> function, together with the <code>data</code> and the <code>model</code> objects:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10000</span>)</span>
<span id="cb6-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">94</span>)</span>
<span id="cb6-3">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(data, model, options)</span></code></pre></div></div>
</div>
<p>The posterior mean curve and 95% equi-tailed credible interval curves for the DLT rates can be obtained by supplying the samples, model and data to the generic <code>plot</code> function. Similarly we can also produce a similar plot without any data, which is then giving the prior, see Figure @ref(fig:plot-model-fit):</p>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(samples, model, data) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggtitle</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Posterior"</span>)</span>
<span id="cb7-2"></span>
<span id="cb7-3">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placebo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb7-4">priorsamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(emptydata, model, options)</span>
<span id="cb7-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(priorsamples, model, emptydata) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggtitle</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Prior"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_paper/index_files/figure-html/plot-model-fit-1.png" class="img-fluid figure-img" style="width:35.0%" alt="Prior and posterior dose-toxicity curves."></p>
<figcaption>Posterior and prior regression model fits</figcaption>
</figure>
</div>
</div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_paper/index_files/figure-html/plot-model-fit-2.png" class="img-fluid figure-img" style="width:35.0%" alt="Prior and posterior dose-toxicity curves."></p>
<figcaption>Posterior and prior regression model fits</figcaption>
</figure>
</div>
</div>
</div>
<p>As illustrated here, the plots can be customized by using the <code>ggplot2</code><span class="citation" data-cites="ggplot2">(Wickham 2009)</span> functionality. We can see that while the posterior mean estimate (left panel, continuous line) is only slightly steeper than the prior mean estimate curve (right panel, continuous line), the posterior uncertainty is reduced due to the data (smaller credible intervals, dashed lines).</p>
<p><strong>Decision making for the next dose</strong> To determine which dose to administer to the next (cohort of) patients we begin by specifying the maximum increments function <img src="https://latex.codecogs.com/png.latex?%5Ctau">. In the example below a maximum increase of 100% for doses below 100 mg, 50% for doses in the range from 100 mg to 200 mg, and 33% for doses equal or above 200 mg is specified using the class <code>IncrementsRelative</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">myIncrements <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelative</span>(</span>
<span id="cb8-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>),</span>
<span id="cb8-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.33</span>)</span>
<span id="cb8-4">)</span></code></pre></div></div>
</div>
<p>This specific rule <img src="https://latex.codecogs.com/png.latex?%5Ctau"> can then be evaluated on the current dataset <img src="https://latex.codecogs.com/png.latex?%7B%5Ccal%20D%7D_%7BN%7D"> by the <code>maxDose</code> function to obtain the maximum next dose <img src="https://latex.codecogs.com/png.latex?t_%7BN+1%7D%20=%20%5Ctau(%7B%5Ccal%20D%7D_%7BN%7D)">:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">(nextMaxDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(myIncrements, data))</span>
<span id="cb9-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 150</span></span></code></pre></div></div>
</div>
<p>We then define the function <img src="https://latex.codecogs.com/png.latex?%5Cnu"> for selecting a dose for the next cohort. In this case we would like to select the dose which maximizes the probability of the DLT rate being in the target toxicity range from 20% to 35%, but with the probability of overdosing not exceeding 25% <span class="citation" data-cites="Neuenschwander2008">(Neuenschwander, Branson, and Gsponer 2008)</span>, using the <code>NextBestNCRM</code> class:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">myNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestNCRM</span>(</span>
<span id="cb10-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overdose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb10-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_overdose_prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span></span>
<span id="cb10-4">)</span></code></pre></div></div>
</div>
<p>This rule can then be evaluated with the function <code>NextBest</code> to obtain the next dose <img src="https://latex.codecogs.com/png.latex?x_%7BN+1%7D=%5Cnu(%7B%5Ccal%20D%7D_%7BN%7D,%20t_%7BN+1%7D)">:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">nextDoseRes <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(myNextBest, nextMaxDose, samples, model, data)</span>
<span id="cb11-2">(nextDoseVal <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> nextDoseRes<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value)</span>
<span id="cb11-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 100</span></span></code></pre></div></div>
</div>
<p>The returned list also contains an accompanying plot (<code>nextDoseRes$plot</code>), see Figure @ref(fig:nextBest-ncrm).</p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_paper/index_files/figure-html/nextBest-ncrm-1.png" class="img-fluid figure-img" style="width:50.0%" alt="A graphical description of the logic between the recommendation of the nextBestRes object."></p>
<figcaption>Dose recommendation plot from NCRM design</figcaption>
</figure>
</div>
</div>
</div>
<p><strong>Adaptive stopping of the trial</strong> We would like to stop the dose escalation adaptively if the maximum sample size of <img src="https://latex.codecogs.com/png.latex?n=30"> patients has been reached already, or if we have sufficient precision for the MTD estimate. We can specify the latter condition as follows: The probability that the next dose <img src="https://latex.codecogs.com/png.latex?x_%7BN+1%7D"> is in the target toxicity range is above 50%, and at least 9 patients were already dosed within +/- 20% range of <img src="https://latex.codecogs.com/png.latex?x_%7BN+1%7D">. The corresponding <code>Stopping</code> class object is constructed by combining the atomic rules with logical operators as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">myStopping1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMinPatients</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>)</span>
<span id="cb12-2">myStopping2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingTargetProb</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb12-3">myStopping3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingPatientsNearDose</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">percentage =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>)</span>
<span id="cb12-4">myStopping <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> myStopping1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> (myStopping2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> myStopping3)</span></code></pre></div></div>
</div>
<p>Again, this specific rule can be evaluated by a function, here called <code>stopTrial</code>, for a specific situation:</p>
<div class="cell" wrap="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(myStopping, nextDoseVal, samples, model, data)</span>
<span id="cb13-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb13-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb13-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]]</span></span>
<span id="cb13-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 12 and thus below the prespecified minimum number 30"</span></span>
<span id="cb13-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]]</span></span>
<span id="cb13-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]][[1]]</span></span>
<span id="cb13-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 33 % for dose 100 and thus below the required 50 %"</span></span>
<span id="cb13-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]][[2]]</span></span>
<span id="cb13-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "3 patients lie within 20% of the next best dose 100. This is below the required 9 patients"</span></span>
<span id="cb13-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")</span></span>
<span id="cb13-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[1]]</span></span>
<span id="cb13-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb13-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb13-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Number of patients is 12 and thus below the prespecified minimum number 30"</span></span>
<span id="cb13-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb13-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "≥ 30 patients dosed"</span></span>
<span id="cb13-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[2]]</span></span>
<span id="cb13-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb13-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb13-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[1]]</span></span>
<span id="cb13-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 33 % for dose 100 and thus below the required 50 %"</span></span>
<span id="cb13-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")[[2]]</span></span>
<span id="cb13-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "3 patients lie within 20% of the next best dose 100. This is below the required 9 patients"</span></span>
<span id="cb13-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")</span></span>
<span id="cb13-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[1]]</span></span>
<span id="cb13-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb13-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb13-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "Probability for target toxicity is 33 % for dose 100 and thus below the required 50 %"</span></span>
<span id="cb13-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb13-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5"</span></span>
<span id="cb13-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"individual")[[2]]</span></span>
<span id="cb13-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] FALSE</span></span>
<span id="cb13-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"message")</span></span>
<span id="cb13-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "3 patients lie within 20% of the next best dose 100. This is below the required 9 patients"</span></span>
<span id="cb13-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb13-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "≥ 9 patients dosed in 20 % dose range around NBD"</span></span>
<span id="cb13-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb13-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] NA</span></span>
<span id="cb13-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb13-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"report_label")</span></span>
<span id="cb13-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] NA</span></span></code></pre></div></div>
</div>
<p>The result <code>FALSE</code> means that we cannot yet stop the trial, with the attribute <code>message</code> giving the results from the atomic stopping rules.</p>
<p><strong>Examine the dose escalation design</strong> In the last topic of this section, we want to show how to assess the performance of a given CRM design. We first need to specify our design by creating an object of class <code>Design</code>. It contains our model, our rules for dose escalation (<code>Increments</code>, <code>NextBest</code>, <code>Stopping</code> and <code>CohortSize</code>), the dose grid (in the example below through the object <code>emptydata</code>) and our starting dose (see also Figure @ref(fig:schematic). In this case we will use a fixed cohort size of 3 patients on active and 1 patient on placebo (``3+1’’) throughout the study:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">mySize <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb14-2">mySizePL <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb14-3"></span>
<span id="cb14-4">design <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Design</span>(</span>
<span id="cb14-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> myNextBest,</span>
<span id="cb14-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStopping, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements,</span>
<span id="cb14-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pl_cohort_size =</span> mySizePL,</span>
<span id="cb14-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> emptydata, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span></span>
<span id="cb14-9">)</span></code></pre></div></div>
</div>
<p>We can then start by looking at the single trial operating characteristics of the dose escalation design with the function <code>examine</code>, which generates a data frame showing the beginning of several hypothetical trial courses under the design. Assuming no DLTs have been seen until a certain dose, then the consequences of different number of DLTs being observed at this dose are shown. For example, if we observe 3 DLTs at the starting dose of 25&nbsp;mg, we would need to stop the trial, while we would enroll another cohort at the same dose level in case of 2 DLTs. In the last rows of the output we see that if no DLTs were observed before the 250&nbsp;mg cohort, the maximum considered dose of 300&nbsp;mg dose can be reached in the next cohort if also no DLTs are observed at 250&nbsp;mg. If 1, 2 or 3 DLTs are observed, the next dose is recommended as 225, 175 and 150&nbsp;mg, respectively.</p>
<div class="cell" data-abbreviate="5">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">23</span>)</span>
<span id="cb15-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">examine</span>(design, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> options)</span>
<span id="cb15-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    dose DLTs nextDose  stop increment</span></span>
<span id="cb15-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1    25    0       50 FALSE       100</span></span>
<span id="cb15-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 2    25    1       50 FALSE       100</span></span>
<span id="cb15-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 3    25    2       25 FALSE         0</span></span>
<span id="cb15-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 4    25    3       NA FALSE        NA</span></span>
<span id="cb15-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 5    50    0      100 FALSE       100</span></span>
<span id="cb15-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 6    50    1       75 FALSE        50</span></span>
<span id="cb15-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 7    50    2       50 FALSE         0</span></span>
<span id="cb15-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 8    50    3       25 FALSE       -50</span></span>
<span id="cb15-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 9   100    0      125 FALSE        25</span></span>
<span id="cb15-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 10  100    1      100 FALSE         0</span></span>
<span id="cb15-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 11  100    2       75 FALSE       -25</span></span>
<span id="cb15-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 12  100    3       50 FALSE       -50</span></span>
<span id="cb15-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 13  125    0      175 FALSE        40</span></span>
<span id="cb15-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 14  125    1      125 FALSE         0</span></span>
<span id="cb15-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 15  125    2      100 FALSE       -20</span></span>
<span id="cb15-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 16  125    3       75 FALSE       -40</span></span>
<span id="cb15-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 17  175    0      250 FALSE        43</span></span>
<span id="cb15-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 18  175    1      150 FALSE       -14</span></span>
<span id="cb15-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 19  175    2      125 FALSE       -29</span></span>
<span id="cb15-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 20  175    3      100 FALSE       -43</span></span>
<span id="cb15-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 21  250    0      300 FALSE        20</span></span>
<span id="cb15-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 22  250    1      225 FALSE       -10</span></span>
<span id="cb15-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 23  250    2      175 FALSE       -30</span></span>
<span id="cb15-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 24  250    3      150 FALSE       -40</span></span></code></pre></div></div>
</div>
<p><strong>Simulating operating characteristics</strong> For the many trials operating characteristics, we first have to define true scenarios, from which the data should arise. In this case, this only requires a function that computes the probability of DLT given a dose. As an example we use here the function contained in the slot <code>prob</code> of the object <code>model</code>: %, for which the dose-toxicity curve is shown below.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1">myTruth <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)</span></code></pre></div></div>
</div>
<p>Note that any possible R-function returning a vector of probabilities upon input of the dose vector can be used. In particular, it is trivially possible to directly specify the probability of DLT for each dose in order to examine operating characteristics not based on any statistical model. For example, assume 5 doses 1–5 with probabilities of DLT of 0.01, 0.02, 0.04, 0.06, 0.09, then the following code could be used:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">doseProbMatrix <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cbind</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.04</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.06</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.09</span>))</span>
<span id="cb17-2">myTruthMatrix <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span></span>
<span id="cb17-3">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose) {</span>
<span id="cb17-4">    doseProbMatrix[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">match</span>(dose, doseProbMatrix[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]</span>
<span id="cb17-5">  }</span></code></pre></div></div>
</div>
<p>Now we can proceed to the simulations using the function <code>simulate</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1">mySimsTime <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span></span>
<span id="cb18-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">system.time</span>(mySims <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(design,</span>
<span id="cb18-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb18-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> options,</span>
<span id="cb18-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb18-6">  ))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]</span></code></pre></div></div>
</div>
<p>The number of simulated trials depends on the required accuracy of the results. The argument <code>parallel</code> can be set to <code>TRUE</code> if one wishes to run the iterations in parallel on all processors of the computer, which can yield a meaningful speedup. Here we needed 217 seconds for 100 simulated trials on an Intel Core i5-6300U CPU with 2.4 GHz.</p>
<p>The result is an object of class <code>Simulations</code> containing multiple slots, with e.g., the <code>data</code> slot containing the list of simulated trials. The slots <code>doses</code> and <code>stopReasons</code> contain information about the final MTD and the stopping reason for each trial. We can e.g., investigate the number of patients and the MTD at the end of the third simulated trial:</p>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1">mySims<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>nObs</span>
<span id="cb19-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 28</span></span>
<span id="cb19-3">mySims<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doses[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]</span>
<span id="cb19-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 50</span></span></code></pre></div></div>
</div>
<p>Furthermore, we can plot the <code>Simulations</code> object by calling the <code>plot</code> method on it, see Figure @ref(fig:sim-plot). You can select the plots by changing the <code>type</code> argument of <code>plot</code>, which by default is <code>type = c("trajectory", "dosesTried")</code>.</p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_paper/index_files/figure-html/sim-plot-1.png" class="img-fluid figure-img" style="width:50.0%" alt="A graphical representation of the simulation results."></p>
<figcaption>Simulation plot</figcaption>
</figure>
</div>
</div>
</div>
<p>Second, we can summarize the simulation results, and obtain a textual description of the results:</p>
<div class="cell" data-abbreviate="3">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1">simSum <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(mySims, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> myTruth)</span>
<span id="cb20-2">simSum</span>
<span id="cb20-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Summary of 100 simulations</span></span>
<span id="cb20-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb20-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target toxicity interval was 20, 35 %</span></span>
<span id="cb20-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Target dose interval corresponding to this was 47.9, 52.7 </span></span>
<span id="cb20-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Intervals are corresponding to 10 and 90 % quantiles</span></span>
<span id="cb20-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb20-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients on placebo : mean 7 (6, 8) </span></span>
<span id="cb20-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients on active : mean 22 (18, 24) </span></span>
<span id="cb20-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients overall : mean 30 (24, 32) </span></span>
<span id="cb20-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of patients treated above target tox interval : mean 3 (3, 3) </span></span>
<span id="cb20-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of DLTs in the trials for patients on placebo : mean 0 % (0 %, 0 %) </span></span>
<span id="cb20-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportions of DLTs in the trials for patients on active : mean 28 % (21 %, 33 %) </span></span>
<span id="cb20-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Mean toxicity risks for the patients on active : mean 29 % (21 %, 34 %) </span></span>
<span id="cb20-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Doses selected as MTD : mean 47.5 (47.5, 50) </span></span>
<span id="cb20-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; True toxicity at doses selected : mean 23 % (23 %, 26 %) </span></span>
<span id="cb20-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion of trials selecting target MTD: 90 %</span></span>
<span id="cb20-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Dose most often selected as MTD: 50 </span></span>
<span id="cb20-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Observed toxicity rate at dose most often selected: 25 %</span></span>
<span id="cb20-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fitted toxicity rate at dose most often selected : mean 23 % (15 %, 29 %) </span></span>
<span id="cb20-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Stop reason triggered:</span></span>
<span id="cb20-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 30 patients dosed :  58 %</span></span>
<span id="cb20-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5 :  52 %</span></span>
<span id="cb20-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ≥ 9 patients dosed in 20 % dose range around NBD :  99 %</span></span></code></pre></div></div>
</div>
<p>A plot of the summary results can also be produced, see Figure @ref(fig:sim-summary-plot).</p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_paper/index_files/figure-html/sim-summary-plot-1.png" class="img-fluid figure-img" style="width:60.0%" alt="A graphical representation of the information in the simulation summary."></p>
<figcaption>Simulation summary plot</figcaption>
</figure>
</div>
</div>
</div>
</section>
<section id="dose-escalation-with-safety-and-efficacy" class="level2">
<h2 class="anchored" data-anchor-id="dose-escalation-with-safety-and-efficacy">Dose escalation with safety and efficacy</h2>
<p>In this section, dose escalation designs incorporating both safety (as binary DLT) and efficacy endpoints (continuous response) will be introduced. Dual endpoint datasets are implemented with the <code>DualData</code> class, where here we illustrate the addition of the efficacy data <code>w</code> to the previous dataset:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1">data2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataDual</span>(</span>
<span id="cb21-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placebo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb21-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">w =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb21-4">    <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.42</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.59</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.45</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.03</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.52</span>,</span>
<span id="cb21-5">    <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.71</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.54</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.45</span></span>
<span id="cb21-6">  ), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>cohort,</span>
<span id="cb21-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>ID</span>
<span id="cb21-8">)</span></code></pre></div></div>
</div>
<p>The endpoints can be modelled jointly or separately. For joint modelling derived from <span class="citation" data-cites="bekele2005">(Bekele and Shen 2005)</span>, please see the package vignette and the <code>DualEndpoint</code> class. In the following section we will describe separate modelling, as proposed in <span class="citation" data-cites="yeung2015">(Yeung et al. 2015)</span>. We will show how the dual endpoint design can help to estimate an optimal dose level which represents the best trade-off between safety and efficacy.</p>
<p><strong>Methodology</strong> Briefly introducing the methodology in current notation, assume that the dose grid <img src="https://latex.codecogs.com/png.latex?%5Ccal%7BX%7D"> contains <img src="https://latex.codecogs.com/png.latex?k"> dose levels, and the logistic regression model @<img src="https://latex.codecogs.com/png.latex?%5Ceqref%7Beq:LogisticLogNormal%7D"> with <img src="https://latex.codecogs.com/png.latex?x%5E%7B*%7D=1"> is used for the safety endpoint <img src="https://latex.codecogs.com/png.latex?y">. For the continuous efficacy endpoint <img src="https://latex.codecogs.com/png.latex?w">, a linear log-log model can be used, conditional on <img src="https://latex.codecogs.com/png.latex?y=0"> (no DLT): <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%5Clabel%7Beq:loglog%7D%0AE(w(x))%20=%20%5Cgamma%20+%20%5Cdelta%20%5Clog%5C%7B%5Clog(x%20+%20c)%5C%7D%0A%5Cend%7Bequation%7D"> such that <img src="https://latex.codecogs.com/png.latex?w(x)%20%5Csim%20N(E(w(x)),%20%5Csigma%5E2)"> with <img src="https://latex.codecogs.com/png.latex?c%20%5Cgeq%200"> as a constant. Usually the default value <img src="https://latex.codecogs.com/png.latex?c=0"> can be used, but in our case we choose <img src="https://latex.codecogs.com/png.latex?c=2"> to allow for the placebo dose <img src="https://latex.codecogs.com/png.latex?x=0.001"> which is close to 0.</p>
<p>For both the safety and efficacy models, the prior will be expressed in form of imaginary pseudo data see <span class="citation" data-cites="yeung2015">(Yeung et al. 2015)</span> for details. Prior and posterior modal estimates of the model parameters can then be obtained as the maximum likelihood estimates from the data set combining pseudo data with observed data <span class="citation" data-cites="w06">(Whitehead 2006)</span>. The variance <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E%7B2%7D"> can be fixed or assigned an inverse gamma prior distribution.</p>
<p><strong>Model classes</strong> The <code>ModelPseudo</code> class contains all model classes where the priors are specified in terms of pseudo data, with subclasses for safety (<code>ModelTox</code>) and efficacy (<code>ModelEff</code>).</p>
<p>Coming back to our example study, the pseudo data for the safety prior assumes that 3 subjects each are treated at the lowest (25&nbsp;mg) and the highest (300&nbsp;mg) dose level, with 1.05 and 1.8 DLTs being observed at these two dose levels, respectively. This corresponds to prior means of 0.35 and 0.6 for the DLT probabilities. We implement model @<img src="https://latex.codecogs.com/png.latex?%5Ceqref%7Beq:LogisticLogNormal%7D"> with this pseudo data prior as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1">DLTmodel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticIndepBeta</span>(</span>
<span id="cb22-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">binDLE =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">DLEweights =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb22-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">DLEdose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> emptydata</span>
<span id="cb22-4">)</span></code></pre></div></div>
</div>
<p>The efficacy model can similarly be specified as</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1">emptydata2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataDual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> emptydata<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placebo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb23-2">Effmodel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Effloglog</span>(</span>
<span id="cb23-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eff =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.223</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.513</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eff_dose =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>),</span>
<span id="cb23-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nu =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.025</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> emptydata2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">c =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb23-5">)</span></code></pre></div></div>
</div>
<p>Here the argument <code>Eff</code> takes the vector of pseudo efficacy responses at the two fixed dose levels, assuming one subject is treated at each of these dose levels. The argument <code>nu</code> specifies a Gamma prior distribution with shape 1 and rate 0.025 for the precision parameter of the pseudo efficacy responses.</p>
<p><strong>Decision making for the next dose</strong> A gain function is used to quantify the trade-off between efficacy and safety, and the next dose should maximize the estimated gain modulo safety constraints. Here we will define the gain as the expected efficacy response, with the convention that a DLT will automatically lead to a zero efficacy response: <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Clabel%7Beq:gainfunction%7D%0AG(x)=Prob(Y=0%20%7C%20x,%20%5Ctheta)E(w(x))%0A%5Cend%7Bequation%7D"> Note that the gain function depends on the safety parameter vector <img src="https://latex.codecogs.com/png.latex?%5Ctheta"> and the efficacy parameters <img src="https://latex.codecogs.com/png.latex?%5Cgamma"> and <img src="https://latex.codecogs.com/png.latex?%5Cdelta">, which will be estimated by their posterior modal estimates using the <code>update</code> method:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1">newDLTmodel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">object =</span> DLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2)</span>
<span id="cb24-2">newEffmodel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">object =</span> Effmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2)</span></code></pre></div></div>
</div>
<p>With <code>crmPack</code> we can implement the next best dose recommendation based on maximizing the gain function as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1">GainNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestMaxGain</span>(</span>
<span id="cb25-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target_drt =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>,</span>
<span id="cb25-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target_eot =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span></span>
<span id="cb25-4">)</span></code></pre></div></div>
</div>
<p>where <code>prob_target_drt</code> specifies the maximum estimated DLT rate tolerated during the study and <code>prob_target_eot</code> the maximum estimated DLT rate tolerated at the end of the study. As in Implementing a CRM trial this rule <img src="https://latex.codecogs.com/png.latex?%5Cnu"> can be evaluated using <code>NextBest</code> to obtain <img src="https://latex.codecogs.com/png.latex?x_%7BN+1%7D">, after evaluating the maximum increments rule <img src="https://latex.codecogs.com/png.latex?%5Ctau"> using <code>maxDose</code> to obtain <img src="https://latex.codecogs.com/png.latex?t_%7BN+1%7D">:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1">(nextMaxDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(myIncrements, data2))</span>
<span id="cb26-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 150</span></span>
<span id="cb26-3">doseRecGain <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(GainNextBest,</span>
<span id="cb26-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> nextMaxDose,</span>
<span id="cb26-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> newDLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model_eff =</span> newEffmodel,</span>
<span id="cb26-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> data2</span>
<span id="cb26-7">)</span>
<span id="cb26-8">(nextDoseVal <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> doseRecGain<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>next_dose)</span>
<span id="cb26-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 25</span></span></code></pre></div></div>
</div>
<p>The plot for the next dose allocation is contained in <code>doseRecGain$plot</code> and shown in Figure @ref(fig:doseRecommendation). \begin{figure}</p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_paper/index_files/figure-html/doseRecommendation-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" style="width:60.0%" alt="A graphical representation of the logic behind the recommendation of the doseResgen object."></p>
</figure>
</div>
</div>
</div>
<p>Dose recommendation plot from dual endpoint design. The red, blue and green curves correspond to the (posterior modal) estimated curves for safety, efficacy and gain, respectively. The vertical red line in the plot shows the maximum possible dose <img src="https://latex.codecogs.com/png.latex?t_%7BN+1%7D%20=%20150"> mg and the vertical violet line shows the next dose <img src="https://latex.codecogs.com/png.latex?x_%7BN+1%7D%20=%2025"> mg. The circle, square and triangle symbols mark the estimated doses with target toxicity (100 mg for 35% DLT probability during the trial and 75 mg for 30% DLT probability at the end of trial) and the estimated dose with maximum gain, 25 mg. The numbers can be obtained from the <code>doseRecGain</code> list.</p>
<p><strong>Stopping rules</strong> In addition to the simple stopping rule based on the maximum number of patients in our trial, we can use another one relating to the precision of the dose with optimum gain:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">myStopping4 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingMaxGainCIRatio</span>(</span>
<span id="cb27-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target_ratio =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,</span>
<span id="cb27-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_target =</span> GainNextBest<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>prob_target_eot</span>
<span id="cb27-4">)</span>
<span id="cb27-5">myStoppingDual <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> myStopping1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> myStopping4</span></code></pre></div></div>
</div>
<p>This stops the trial when 30 patients are reached, or when the ratio of the upper and lower confidence interval bounds around the dose recommendation is less than&nbsp;5.</p>
<p><strong>Simulations</strong> To simulate the operating characteristics, first a design has to be built:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1">design2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DualResponsesDesign</span>(</span>
<span id="cb28-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> GainNextBest, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> DLTmodel,</span>
<span id="cb28-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eff_model =</span> Effmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> emptydata2,</span>
<span id="cb28-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> myStoppingDual,</span>
<span id="cb28-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> myIncrements,</span>
<span id="cb28-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> mySize, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span></span>
<span id="cb28-7">)</span></code></pre></div></div>
</div>
<p>Note that an additional slot for the efficacy model is included in this design class. We can then specify the scenario for the simulation, by defining the true DLT and efficacy curves that we will be using:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">myTruthDLT <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(DLTmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phi1 =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">53</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phi2 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>)</span>
<span id="cb29-2">myTruthEff <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">efficacyFunction</span>(Effmodel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">theta1 =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">theta2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.7</span>)</span>
<span id="cb29-3">myTruthGain <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose) {</span>
<span id="cb29-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruthEff</span>(dose) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">myTruthDLT</span>(dose))</span>
<span id="cb29-5">}</span></code></pre></div></div>
</div>
<p>Please note that the parameter names <code>phi1</code>, <code>phi2</code>, <code>theta1</code> and <code>theta2</code> correspond to <img src="https://latex.codecogs.com/png.latex?%5Calpha_0,%20%5Calpha_1,%20%5Cgamma"> and <img src="https://latex.codecogs.com/png.latex?%5Cdelta">, respectively. Simulations are again produced by the <code>simulate</code> function:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1">Sim1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(</span>
<span id="cb30-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">object =</span> design2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueDLE =</span> myTruthDLT,</span>
<span id="cb30-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueEff =</span> myTruthEff, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trueNu =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.025</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>,</span>
<span id="cb30-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">819</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb30-5">)</span></code></pre></div></div>
</div>
<p>Note that the fixed precision <code>nu</code> <img src="https://latex.codecogs.com/png.latex?1/%5Csigma%5E%7B2%7D"> is specified instead of the variance <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E%7B2%7D">. % The results of the simulation can then be plotted and summarized as shown before.</p>
</section>
<section id="extending-crmpack-functionality" class="level2">
<h2 class="anchored" data-anchor-id="extending-crmpack-functionality">Extending crmPack functionality</h2>
<p>One of the big advantages of <code>crmPack</code> over existing <code>R</code> implementations is its flexible framework based on the <code>S4</code> classes and methods system <span class="citation" data-cites="Chambers2008">(Chambers 2008)</span> and <code>JAGS</code> <span class="citation" data-cites="JAGS">(Plummer 2003)</span> for Bayesian computations. Here we will therefore illustrate how users can extend the existing functionality easily to the specific needs of the study.</p>
<p><strong>Objective</strong> The example will implement a version of the one-parameter CRM <span class="citation" data-cites="oquigley1990">(O’Quigley, Pepe, and Fisher 1990)</span>, which is currently not (yet) included in the package. It is based on a one-parameter power model to describe the relationship between the binary DLT responses <img src="https://latex.codecogs.com/png.latex?Y"> and their corresponding dose levels <img src="https://latex.codecogs.com/png.latex?x">: <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Clabel%7Beq:oneparameter%7D%0A%5Cpi(x,%20%5Ctheta)%20=%20Prob(Y=1%20%7C%20x,%20%5Ctheta)%20=%20f(x)%5E%7B%5Ctheta%7D%0A%5Cend%7Bequation%7D"> Here <img src="https://latex.codecogs.com/png.latex?0%20%3C%20f(x)%20%3C%201"> is monotonically increasing in <img src="https://latex.codecogs.com/png.latex?x"> and is specified by the investigator upfront. The sequence <img src="https://latex.codecogs.com/png.latex?f(x_%7B1%7D),%20%5Cdotsc,%20f(x_%7Bk%7D)"> along the dose grid is often called ``skeleton’’ of the CRM. An exponential distribution with parameter <img src="https://latex.codecogs.com/png.latex?%5Clambda"> is imposed as the prior distribution for the unknown parameter <img src="https://latex.codecogs.com/png.latex?%5Ctheta">. The next dose should then be chosen such that the distance of the posterior mean estimated DLT probability to a predefined target toxicity level is minimized.</p>
<p><strong>Creating a new model</strong> To implement the one-parameter model @<img src="https://latex.codecogs.com/png.latex?%5Ceqref%7Beq:oneparameter%7D"> in <code>crmPack</code> we first need to define an appropriate <code>S4</code> class inheriting from the general model class <code>GeneralModel</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb31" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1">.OneParExp <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setClass</span>(</span>
<span id="cb31-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Class =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OneParExp"</span>,</span>
<span id="cb31-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">contains =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GeneralModel"</span>,</span>
<span id="cb31-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slots =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb31-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">skeleton_probs =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>,</span>
<span id="cb31-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose_grid =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>,</span>
<span id="cb31-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lambda =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span></span>
<span id="cb31-8">  )</span>
<span id="cb31-9">)</span></code></pre></div></div>
</div>
<p>Here we specify that the new class is called <code>OneParExp</code> and contains three additional slots containing the resulting skeleton prior probabilities, the dose grid, and the prior parameter <img src="https://latex.codecogs.com/png.latex?%5Clambda">.</p>
<p>Second we have to create a convenient initialization function, which specifies the likelihood and prior distributions in the underlying <code>GeneralModel</code> in <code>JAGS</code>. We choose to let the user supply just the skeleton probabilities along with the intended dose grid to use. The likelihood with the power model is specified in <code>datamodel</code> and uses the <code>Data</code> slots which are specified in <code>datanames</code>. The prior is defined in <code>priormodel</code>. Model parameters are passed to <code>JAGS</code> via <code>modelspecs</code>. The <code>init</code> slot contains a function giving the starting values for the MCMC sampler, and <code>sample</code> defines which parameter samples will be returned:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1">OneParExp <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(skeleton_probs, dose_grid, lambda) {</span>
<span id="cb32-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.OneParExp</span>(</span>
<span id="cb32-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">skeleton_probs =</span> skeleton_probs,</span>
<span id="cb32-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose_grid =</span> dose_grid,</span>
<span id="cb32-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lambda =</span> lambda,</span>
<span id="cb32-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">datamodel =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb32-7">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>nObs) {</span>
<span id="cb32-8">        y[i] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dbern</span>(p[i])</span>
<span id="cb32-9">        p[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> skeleton_probs[xLevel[i]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>theta</span>
<span id="cb32-10">      }</span>
<span id="cb32-11">    },</span>
<span id="cb32-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">priormodel =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb32-13">      theta <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dexp</span>(lambda)</span>
<span id="cb32-14">    },</span>
<span id="cb32-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">modelspecs =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb32-16">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">skeleton_probs =</span> skeleton_probs, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lambda =</span> lambda)</span>
<span id="cb32-17">    },</span>
<span id="cb32-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">init =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb32-19">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">theta =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb32-20">    }, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"theta"</span>,</span>
<span id="cb32-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">datanames =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nObs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"xLevel"</span>)</span>
<span id="cb32-22">  )</span>
<span id="cb32-23">}</span></code></pre></div></div>
</div>
<p>Finally, we will create the <code>dose</code> and <code>prob</code> methods. The <code>prob</code> method is based on the (a skeleton) function which does the interpolation between the dose grid points in order to obtain the probability of a DLT. The <code>dose</code>, on the other hand, uses an inverse of (the skeleton) function <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Clabel%7Beq:oneparameterInverse%7D%0A%5Cpi%5E%7B-1%7D(p,%20%5Ctheta)%20=%20f%5E%7B-1%7D(p%5E%7B1/%5Ctheta%7D)%0A%5Cend%7Bequation%7D"> which maps the probability <img src="https://latex.codecogs.com/png.latex?p"> to a dose <img src="https://latex.codecogs.com/png.latex?x">.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb33" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb33-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setMethod</span>(</span>
<span id="cb33-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">f =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dose"</span>,</span>
<span id="cb33-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">signature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">signature</span>(</span>
<span id="cb33-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>,</span>
<span id="cb33-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OneParExp"</span>,</span>
<span id="cb33-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples"</span></span>
<span id="cb33-7">  ),</span>
<span id="cb33-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">definition =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x, model, samples) {</span>
<span id="cb33-9">    theta <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>theta</span>
<span id="cb33-10">    invSkeletonFun <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">approxfun</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>skeleton_probs, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>dose_grid, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rule =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb33-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">invSkeletonFun</span>(x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> theta))</span>
<span id="cb33-12">  }</span>
<span id="cb33-13">)</span>
<span id="cb33-14"></span>
<span id="cb33-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setMethod</span>(</span>
<span id="cb33-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">f =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"prob"</span>,</span>
<span id="cb33-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">signature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">signature</span>(</span>
<span id="cb33-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>,</span>
<span id="cb33-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OneParExp"</span>,</span>
<span id="cb33-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples"</span></span>
<span id="cb33-21">  ),</span>
<span id="cb33-22">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">definition =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose, model, samples) {</span>
<span id="cb33-23">    theta <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>theta</span>
<span id="cb33-24">    skeletonFun <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">approxfun</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>dose_grid, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>skeleton_probs, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rule =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb33-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">skeletonFun</span>(dose)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>theta</span>
<span id="cb33-26">  }</span>
<span id="cb33-27">)</span></code></pre></div></div>
</div>
<p>Now we can already use the model, for example in the following we specify the skeleton probabilities via the dose grid and use a standard exponential prior for <img src="https://latex.codecogs.com/png.latex?%5Ctheta">. The resulting posterior fit can be plotted as usual, see Figure @ref(fig:OneParExp-model-example).</p>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1">(skeleton_probs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb34-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1] 0.00 0.04 0.08 0.12 0.17 0.21 0.25 0.29 0.33 0.38 0.42 0.46 0.50</span></span>
<span id="cb34-3">newModel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">OneParExp</span>(</span>
<span id="cb34-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">skeleton_probs =</span> skeleton_probs,</span>
<span id="cb34-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose_grid =</span> data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid,</span>
<span id="cb34-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lambda =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb34-7">)</span>
<span id="cb34-8">newSamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(data, newModel, options)</span>
<span id="cb34-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(newSamples, newModel, data)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/getting-started/crmPack_paper/index_files/figure-html/OneParExp-model-example-1.png" class="img-fluid figure-img" style="width:50.0%" alt="The posterior dose-toxicity curve from the one parameter power model."></p>
<figcaption>Model fit of the one parameter power model</figcaption>
</figure>
</div>
</div>
</div>
<p><strong>Creating a new dose recommendation rule</strong> In a second step we would like to create a new dose recommendation rule, which proposes the dose with estimated DLT probability closest to the target. Again we start with the class, now inheriting from <code>NextBest</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb35" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1">.NextBestMinDist <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setClass</span>(</span>
<span id="cb35-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Class =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NextBestMinDist"</span>,</span>
<span id="cb35-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">contains =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NextBest"</span>,</span>
<span id="cb35-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">representation</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>)</span>
<span id="cb35-5">)</span>
<span id="cb35-6">NextBestMinDist <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(target) {</span>
<span id="cb35-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.NextBestMinDist</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> target)</span>
<span id="cb35-8">}</span></code></pre></div></div>
</div>
<p>Note that here we keep to the convention of separate class definition and initialization function, although there is no technical need in this case. In order to make it usable we need to define the <code>NextBest</code> method for this new rule. Note that we do only specialize the method for the first argument, such that this rule could also be used with other models.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setMethod</span>(</span>
<span id="cb36-2">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nextBest"</span>,</span>
<span id="cb36-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">signature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">signature</span>(</span>
<span id="cb36-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NextBestMinDist"</span>,</span>
<span id="cb36-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doselimit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>,</span>
<span id="cb36-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples"</span>,</span>
<span id="cb36-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OneParExp"</span>,</span>
<span id="cb36-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Data"</span></span>
<span id="cb36-9">  ),</span>
<span id="cb36-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">def =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(nextBest, doselimit, samples, model, data, ...) {</span>
<span id="cb36-11">    dosesOK <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span></span>
<span id="cb36-12">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(doselimit)) {</span>
<span id="cb36-13">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> doselimit)</span>
<span id="cb36-14">      } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb36-15">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid)</span>
<span id="cb36-16">      }</span>
<span id="cb36-17">    modelfit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit</span>(samples, model, data)</span>
<span id="cb36-18">    probDLT <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> modelfit<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>middle[dosesOK]</span>
<span id="cb36-19">    doses <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> modelfit<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dose[dosesOK]</span>
<span id="cb36-20">    bestIndex <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.min</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(probDLT <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> nextBest<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>target))</span>
<span id="cb36-21">    bestDose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> doses[bestIndex]</span>
<span id="cb36-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> bestDose)</span>
<span id="cb36-23">  }</span>
<span id="cb36-24">)</span></code></pre></div></div>
</div>
<p>In the method definition, we can use the <code>fit</code> function in order to obtain the estimated DLT rates. We need to return a <code>list</code> from this method, since this is required by the generic function definition. The advantage is that we could also include a plot or other supporting information in the return value. Immediately we can now use this rule in order to obtain the next dose recommendation, e.g., after specifying a target dose of 30%:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb37" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1">newMyNextBest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestMinDist</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)</span>
<span id="cb37-2">newNextDoseVal <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(newMyNextBest, nextMaxDose, newSamples, newModel, data)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb37-3">newNextDoseVal</span>
<span id="cb37-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 150</span></span></code></pre></div></div>
</div>
<p>So using this CRM, we could escalate to 150&nbsp;mg, instead of just 100&nbsp;mg above.</p>
<p><strong>Using the new functionality</strong> These were the only necessary additions of code that we needed to implement the one-parameter CRM with a greedy next best dose rule - from now on we can use the new classes in the same way as classes already contained in <code>crmPack</code>! For example, we can create a corresponding new <code>Design</code> object, examine its hypothetical trial course and run simulations. In particular, the placebo convention automatically carries over.</p>
</section>
</section>
<section id="summary" class="level1">
<h1>Summary</h1>
<p>In this paper we have introduced the <code>R</code> package <code>crmPack</code> for analyzing and evaluating dose escalation trials. Unlike existing software the package is written to make full use of a class structure enabling easy extensions to user-specific dose-response models, prior distributions, escalation and stopping rules. The example in Extending crmPack functionality demonstrated that:</p>
<ol type="1">
<li>New functionality can be added - without changing the package.</li>
<li>Only the new functionality needs to be coded in one place - no side effects need to be considered.</li>
<li>Templates for new designs can be found by looking at the existing code in the package - only minimal <code>S4</code> and <code>JAGS</code> knowledge is required.</li>
</ol>
<p>Therefore, <code>crmPack</code> allows the user to easily extend the package by keeping modifications local and limited to what needs to be changed, which in our experience has been a key success factor for the wider use of model-based dose escalation designs. The package does, however, already include a wide range of model-based and algorithmic dose escalation procedures, which are described in the package’s documentation available through <code>crmPackHelp()</code> and provide end-users easy access to these approaches without the need for further coding. Another unique feature of the package is the inclusion of approaches that allow placebo data, which are routinely collected in healthy volunteer studies, to be utilized. Finally some methods [e.g.,]<span class="citation" data-cites="bekele2005">(Bekele and Shen 2005)</span><span class="citation" data-cites="yeung2015">(Yeung et al. 2015)</span> for dose-finding incorporating safety and efficacy are implemented already in the package. As for all designs, the underlying structure to extend to novel dual endpoint methods is provided. Simulation facilities for all approaches and relevant graphical displays are also available.</p>
<p>The package is actively developed further and new methods will be added. Future extensions of <code>crmPack</code> will include model-based combination dose escalation designs, see for example <span class="citation" data-cites="Sweeting2012">(M. J. Sweeting and Mander 2012)</span> and [<span class="citation" data-cites="Riviere2014">Riviere et al. (2014)</span> for recent reviews. Furthermore, data-augmentation CRM designs [see]<span class="citation" data-cites="Liu2013">(Liu and Ning 2013)</span> that allow for a decoupling of inter-cohort waiting times and DLT time windows, hence speeding up dose escalation trials, will be included.</p>
</section>
<section id="acknowledgments" class="level1">
<h1>Acknowledgments</h1>
<p>We would like to thank Francesca Michielin and Peter Dutton for their valuable comments on an earlier draft of the manuscript. This report is funded by the Roche Postdoctoral Fellowship programme (RPF-234) and research arising from Prof Jaki’s Senior Research Fellowship (NIHR-SRF-2015-08-001) supported by the National Institute for Health Research. The views expressed in this publication are those of the authors and not necessarily those of the NHS, the National Institute for Health Research or the Department of Health. This manuscript was prepared using <code>knitr</code> <span class="citation" data-cites="knitr2018">(Xie 2018)</span>.</p>
</section>
<section id="references" class="level1">




</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-bekele2005" class="csl-entry">
Bekele, NB, and Yu Shen. 2005. <span>“A Bayesian Approach to Jointly Modeling Toxicity and Biomarker Expression in a Phase i/II Dose-Finding Trial.”</span> <em>Biometrics</em> 61 (2): 343–54.
</div>
<div id="ref-carter1973" class="csl-entry">
Carter, STEPHEN K. 1973. <span>“Study Design Principles for the Clinical Evaluation of New Drugs as Developed by the Chemotherapy Programme of the National Cancer Institute.”</span> <em>The Design of Clinical Trials in Cancer Therapy</em> 1: 242–89.
</div>
<div id="ref-Chambers2008" class="csl-entry">
Chambers, John. 2008. <em>Software for Data Analysis</em>. Statistics and Computing. Springer-Verlag.
</div>
<div id="ref-dfcrm2013" class="csl-entry">
Cheung, Ken. 2013. <em>: Dose-Finding by the Continual Reassessment Method</em>. <a href="https://www.routledge.com/Dose-Finding-by-the-Continual-Reassessment-Method/Cheung/p/book/9781420091519">https://www.routledge.com/Dose-Finding-by-the-Continual-Reassessment-Method/Cheung/p/book/9781420091519</a>.
</div>
<div id="ref-cheung2000" class="csl-entry">
Cheung, Ying Kuen, and Rick Chappell. 2000. <span>“Sequential Designs for Phase i Clinical Trials with Late-Onset Toxicities.”</span> <em>Biometrics</em> 56 (4): 1177–82.
</div>
<div id="ref-Addplan2025" class="csl-entry">
Consultants, Berry. 2025.<em> (<span>AD</span>aptive <span>D</span>esign <span>PLAN</span>ner)</em>. Austin, Texas, US. <a href="https://www.berryconsultants.com/software/addplan">https://www.berryconsultants.com/software/addplan</a>.
</div>
<div id="ref-R2016" class="csl-entry">
Core Team. 2016. <em>: A Language and Environment for Statistical Computing</em>. Vienna, Austria: Foundation for Statistical Computing. <a href="https://www.R-project.org/">https://www.R-project.org/</a>.
</div>
<div id="ref-East2016" class="csl-entry">
Cytel Inc. 2016.<em> 6: Statistical Software for the Design, Simulation and Monitoring of Clinical Trials</em>. Cambridge, MA. <a href="https://www.cytel.com/software/east/">https://www.cytel.com/software/east/</a>.
</div>
<div id="ref-ordcrm" class="csl-entry">
Dressler, Emily V., and Zhengyan Huang. 2016. <em>: Likelihood-Based Continual Reassessment Method (CRM) Dose Finding Designs</em>. <a href="https://CRAN.R-project.org/package=ordcrm">https://CRAN.R-project.org/package=ordcrm</a>.
</div>
<div id="ref-SAS2003" class="csl-entry">
Institute Inc. 2003.<em> Software, Version&nbsp;9.1</em>. Cary, NC. <a href="https://www.sas.com/">https://www.sas.com/</a>.
</div>
<div id="ref-jaki2013" class="csl-entry">
Jaki, Thomas, Sally Clive, and Christopher J Weir. 2013. <span>“Principles of Dose Finding Studies in Cancer: A Comparison of Trial Designs.”</span> <em><span>Cancer Chemotherapy and Pharmacology</span></em> 71 (5): 1107–14.
</div>
<div id="ref-Liu2013" class="csl-entry">
Liu, Suyu, and Jing Ning. 2013. <span>“A Bayesian Dose-Finding Design for Drug Combination Trials with Delayed Toxicities.”</span> <em>Bayesian Analysis</em> 8 (3): 703–22.
</div>
<div id="ref-StataCRM" class="csl-entry">
Mander, Adrian. 2013. <em>: Stata Module to Implement the Continual Reassessment Model</em>. <a href="https://ideas.repec.org/c/boc/bocode/s457625a.html">https://ideas.repec.org/c/boc/bocode/s457625a.html</a>.
</div>
<div id="ref-Neuenschwander2008" class="csl-entry">
Neuenschwander, Beat, Michael Branson, and Thomas Gsponer. 2008. <span>“<span class="nocase">Critical aspects of the Bayesian approach to phase I cancer trials.</span>”</span> <em>Statistics in Medicine</em> 27 (13): 2420–39. <a href="https://onlinelibrary.wiley.com/doi/10.1002/sim.3230">https://onlinelibrary.wiley.com/doi/10.1002/sim.3230</a>.
</div>
<div id="ref-oquigley1990" class="csl-entry">
O’Quigley, John, Margaret Pepe, and Lloyd Fisher. 1990. <span>“Continual Reassessment Method: A Practical Design for Phase 1 Clinical Trials in Cancer.”</span> <em>Biometrics</em> 46 (1): 33–48.
</div>
<div id="ref-Paoletti2015" class="csl-entry">
Paoletti, X., M. Ezzalfani, and C. Le Tourneau. 2015. <span>“Statistical Controversies in Clinical Research: Requiem for the 3 + 3 Design for Phase i Trials.”</span> <em>Annals of Oncology</em> 26 (9): 1808–12.
</div>
<div id="ref-JAGS" class="csl-entry">
Plummer, Martyn. 2003. <em>: A Program for Analysis of Bayesian Graphical Models Using Gibbs Sampling</em>. <a href="https://mcmc-jags.sourceforge.io/">https://mcmc-jags.sourceforge.io/</a>.
</div>
<div id="ref-Riviere2014" class="csl-entry">
Riviere, M.- K., C. Le Tourneau, X. Paoletti, F. Dubois, and S. Zohar. 2014. <span>“Designs of Drug-Combination Phase i Trials in Oncology: A Systematic Review of the Literature.”</span> <em>Annals of Oncology</em> 26 (4): 669–74.
</div>
<div id="ref-crmPack" class="csl-entry">
Sabanés Bové, Daniel, Wai Yin Yeung, Giuseppe Palermo, and Thomas Jaki. 2018. <em>: Object-Oriented Implementation of CRM Designs</em>. <a href="https://CRAN.R-project.org/package=crmPack">https://CRAN.R-project.org/package=crmPack</a>.
</div>
<div id="ref-Stata2015" class="csl-entry">
StataCorp. 2015.<em> Statistical Software: Release 14</em>. College Station, TX: StataCorp LP. <a href="https://www.stata.com/">https://www.stata.com/</a>.
</div>
<div id="ref-Storer1989" class="csl-entry">
Storer, Barry E. 1989. <span>“Design and Analysis of Phase i Clinical Trials.”</span> <em>Biometrics</em> 45 (3): 925–37. <a href="https://doi.org/10.2307/2531693">https://doi.org/10.2307/2531693</a>.
</div>
<div id="ref-Sweeting2012" class="csl-entry">
Sweeting, Michael J, and Adrian P Mander. 2012. <span>“Escalation Strategies for Combination Therapy Phase i Trials.”</span> <em>Pharmaceutical Statistics</em> 11 (3).
</div>
<div id="ref-sweeting2013" class="csl-entry">
Sweeting, Michael, Adrian Mander, and Tony Sabin. 2013. <span>“: Bayesian Continual Reassessment Method Designs for Phase i Dose-Finding Trials.”</span> <em>Journal of Statistical Software</em> 54 (13): 1–26.
</div>
<div id="ref-FACTS" class="csl-entry">
Team, FACTS Development. 2015. <span>“Fixed and Adaptive Clinical Trial Simulator.”</span> <a href="https://www.berryconsultants.com/software">https://www.berryconsultants.com/software</a>.
</div>
<div id="ref-Thall2010" class="csl-entry">
Thall, Peter F. 2010. <span>“Bayesian Models and Decision Algorithms for Complex Early Phase Clinical Trials.”</span> <em>Statistical Science</em> 25 (2): 227–44. <a href="https://pubmed.ncbi.nlm.nih.gov/21318084/">https://pubmed.ncbi.nlm.nih.gov/21318084/</a>.
</div>
<div id="ref-dfpk" class="csl-entry">
Toumazi, Artemis, Moreno Ursino, and Sarah Zohar. 2017. <em>: A Bayesian Dose-Finding Design Using Pharmacokinetics (PK) for Phase i Clinical Trials</em>. <a href="https://CRAN.R-project.org/package=dfpk">https://CRAN.R-project.org/package=dfpk</a>.
</div>
<div id="ref-w06" class="csl-entry">
Whitehead, J. 2006. <span>“Statistical Methods for Dose-Finding Experiments.”</span> In, edited by Sylvie Chevret. John Wiley &amp; Sons.
</div>
<div id="ref-ggplot2" class="csl-entry">
Wickham, Hadley. 2009. <em>: Elegant Graphics for Data Analysis</em>. Springer-Verlag. <a href="https://ggplot2.tidyverse.org/">https://ggplot2.tidyverse.org/</a>.
</div>
<div id="ref-knitr2018" class="csl-entry">
Xie, Yihui. 2018. <em>: A General-Purpose Package for Dynamic Report Generation in r</em>. <a href="https://yihui.org/knitr/">https://yihui.org/knitr/</a>.
</div>
<div id="ref-yeung2015" class="csl-entry">
Yeung, Wai Yin, John Whitehead, Bruno Reigner, Ulrich Beyer, Cheikh Diack, and Thomas Jaki. 2015. <span>“Bayesian Adaptive Dose-Escalation Procedures for Binary and Continuous Responses Utilizing a Gain Function.”</span> <em><span>Pharmaceutical Statistics</span></em> 14 (6): 479–87.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Getting started</category>
  <guid>https://www.crmpack.org/vignettes/getting-started/crmPack_paper/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_10.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Upgrading from crmPack version 1.0</title>
  <dc:creator>Wojciech Wójciak, Oliver Boix</dc:creator>
  <link>https://www.crmpack.org/vignettes/upgrading/crmPack_upgrading/</link>
  <description><![CDATA[ 




<p>Please note that the changes described below are not exhaustive. Always check the relevant class documentation for details, too.</p>
<section id="class-and-slot-changes" class="level2">
<h2 class="anchored" data-anchor-id="class-and-slot-changes">Class and slot changes</h2>
<section id="naming-convention-motivation" class="level3">
<h3 class="anchored" data-anchor-id="naming-convention-motivation">Naming convention motivation</h3>
<p>To be close to common R style guidelines <span class="citation" data-cites="advancedR">(Wickham 2019)</span> and use consistent naming conventions within the <code>crmPack</code> package, <code>CamelCase</code> notation is used for <code>class</code> names, <code>method</code> names and constructor function names, and <code>snake_case</code> notation is used for <code>slot</code> names throughout the package.</p>
</section>
<section id="new-classes" class="level3">
<h3 class="anchored" data-anchor-id="new-classes">New classes</h3>
<div class="cell">
<div class="cell-output-display">
<table class="table caption-top table-sm table-striped small">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Category
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Comment
</div></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Data</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">DataDA</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Time-to-DLT augmented data.</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Design</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">DADesign</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Design for data augmentation.</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Increments</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">IncrementsHSRBeta</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Limiting further increments using a Hard Safety Rule</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Increments</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">IncrementsRelativeDLTCurrent</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Increments control based on relative differences in terms of DLTs.</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Model</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">DALogisticLogNormal</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Logistic model with bivariate (log) normal prior and data augmentation.</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Model</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">FractionalCRM</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Fractional CRM model.</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Model</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">OneParExpPrior</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Standard CRM with an exponential prior on the power parameter.</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Model</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">OneParLogNormalPrior</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">standard CRM with a normal prior on the log power parameter for the skeleton prior probabilities</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Model</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">ProbitLogNormalRel</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Probit regression model with a bivariate normal prior on the intercept and log slope.</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">nextBest</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">NextBestEWOC</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Next best dose is the highest possible dose subject to overdose control.</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">nextBest</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">NextBestInfTheory</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Next best dose that is based on information theory.</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">nextBest</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">NextBestMinDist</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Next best dose that is based on minimum distance to target probability.</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">nextBest</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">NextBestNCRMLoss</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Next best dose based on NCRM rule and loss function.</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">nextBest</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">NextBestProbMTDLTE</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Next best dose that selects the dose with the highest probability of having a toxicity rate less or equal to the toxicity target.</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">nextBest</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">NextBestProbMTDMinDist</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Next best dose that selects the dose with the highest probability of having a toxicity rate with the smallest distance to the toxicity target.</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Parent model class</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">ModelParamsNormal</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Represents parameters of bivariate normal distribution.</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">SafetyWindow</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">SafetyWindowConst</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Safety window length used when the `gap` should be kept constant.</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">SafetyWindow</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">SafetyWindowSize</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Safety window length based on cohort size.</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Stopping</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">StoppingLowestDoseHSRBeta</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Stopping based on a Hard Safety Rule using the Beta posterior distribution.</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Stopping</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">StoppingMissingDose</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Stopping based on NA returned by next best dose.</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Stopping</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">StoppingMTDCV</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Stopping rule based on precision of MTD which is calculated as the coefficient of variation (CV) of the MTD.</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Stopping</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">StoppingSpecificDose</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Testing a stopping rule at specific dose of the dose grid and not at the next best dose.</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section id="renamed-classes" class="level3">
<h3 class="anchored" data-anchor-id="renamed-classes">Renamed classes</h3>
<div class="cell">
<div class="cell-output-display">
<table class="table caption-top table-sm table-striped small">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Category
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
New Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Old Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Reason
</div></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Increments</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">IncrementsDoseLevels</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">IncrementsNumDoseLevels</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Harmonization</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Increments</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">IncrementsMin</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">IncrementMin</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Harmonization</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Stopping</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">StoppingMaxGainCIRatio</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">StoppingGstarCIRatio</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">Clarification</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section id="renamed-slots" class="level3">
<h3 class="anchored" data-anchor-id="renamed-slots">Renamed slots</h3>
<p>Please note that this list might not be exhaustive. Please always check the relevant class documentation for details.</p>
<div class="cell">
<div class="cell-output-display">
<table class="table caption-top table-sm table-striped small">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Class/Constructor<sup>*</sup>
</div></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Slot/Arg<sup>†</sup>
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Comment
</div></th>
</tr>
<tr class="even">
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
New Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: left; empty-cells: hide; border-bottom: hidden;"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">CohortSizeDLT</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">cohortSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">cohort_size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLTintervals</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">dlt_intervals</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">CohortSizeMax</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">cohortSizeList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">cohort_size_list</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">CohortSizeMin</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">cohortSizeList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">cohort_size_list</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">CohortSizeRange</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">cohortSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">cohort_size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">DALogisticLogNormal</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">C_par</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">c_par</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">conditionalPEM</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">cond_pem</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Design</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">PLcohortSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">pl_cohort_size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DualEndpointBeta</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">refDoseBeta</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">ref_dose_beta</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DualEndpointEmax</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">refDoseEmax</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">ref_dose_emax</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DualEndpointRW</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">useRW1</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">rw1</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">DualEndpointRW()</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">rw1</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaces `smooth` string</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">smooth</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `rw1` flag</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">EffFlexi</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">several slots</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">several slots</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">several slot changed, see man page</td>
</tr>
<tr class="odd">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">EffFlexi()</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">rw1</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaces `smooth` string</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">smooth</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `rw1` flag</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Effloglog</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">several slots</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">several slots</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">several slot changed, see man page</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">IncrementsDoseLevels (IncrementsNumDoseLevels)</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">basis_level</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">IncrementsDoseLevels (IncrementsNumDoseLevels)</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">maxLevels</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">levels</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">change applied also to other dependent classes</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">IncrementsMin (IncrementMin)</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">IncrementsList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">increments_list</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">change applied also to other dependent classes</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">IncrementsRelativeDLT</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLTintervals</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">dlt_intervals</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">change applied also to other dependent classes</td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">IncrementsRelativeParts</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">cleanStart</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">clean_start</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">change applied also to other dependent classes</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">dltStart</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">dlt_start</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">McmcOptions</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">rng_kind</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">to be used by Random Number Generator in rJAGS</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">rng_seed</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">to be used by Random Number Generator in rJAGS</td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">ModelEff</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">dose</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">moved to model class method</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">ExpEff</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">moved to model class method and renamed to `efficacy`</td>
</tr>
<tr class="even">
<td rowspan="4" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">NextBestDualEndpoint</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">target_relative</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaces `scale` string</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">maxOverdoseProb</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">max_overdose_prob</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">scale</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `target_relative` flag</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetThresh</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">target_thresh</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">NextBestMaxGain</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLEDuringTrialtarget</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_drt</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLEEndOfTrialtarget</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_eot</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="4" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">NextBestMaxGainSamples</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLEDuringTrialtarget</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_drt</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLEEndOfTrialtarget</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_eot</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Gstarderive</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">mg_derive</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">TDderive</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">derive</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">NextBestNCRM</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">maxOverdoseProb</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">max_overdose_prob</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">NextBestTD</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetDuringTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_drt</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetEndOfTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_eot</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">NextBestTDsamples</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetDuringTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_drt</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetEndOfTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_eot</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">StoppingAll</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">stopList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">stop_list</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">StoppingAny</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">stopList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">stop_list</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">StoppingList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">stopList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">stop_list</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">StoppingMaxGainCIRatio (StoppingGstarCIRatio)</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetEndOfTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetRatio</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">target_ratio</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">StoppingTargetBiomarker</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">is_relative</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaces `scale` string</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">scale</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `is_relative` flag</td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">StoppingTDCIRatio</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetEndOfTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetRatio</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">target_ratio</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">TDDesign</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">PLcohortSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">pl_cohort_size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">TDsamplesDesign</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">PLcohortSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">pl_cohort_size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">TITELogisticLogNormal</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">weightMethod</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">weight_method</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
</tbody><tfoot>
<tr class="odd">
<td style="text-align: left; padding: 0; border: 0;"><sup>*</sup> Class or class' user constructor. In the later case the Name/New Name is followed by ().</td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left; padding: 0; border: 0;"><sup>†</sup> Slot in case of the class or argument in case of the class' user constructor</td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
</tr>
</tfoot>

</table>
</div>
</div>
<p>Strikeout indicates that the class/slot was removed.</p>
</section>
</section>
<section id="moved-dose-and-prob-functions-from-slots-to-methods" class="level2">
<h2 class="anchored" data-anchor-id="moved-dose-and-prob-functions-from-slots-to-methods">Moved <code>dose</code> and <code>prob</code> Functions from Slots to Methods</h2>
<p>Moved <code>dose</code> and <code>prob</code> functions from model class slots to model class methods. Example of usage: <code>dose</code>/<code>prob</code> function as a true dose-DLT/DLT-dose relationship.</p>
<section id="generate-data-define-a-model-and-get-samples" class="level3">
<h3 class="anchored" data-anchor-id="generate-data-define-a-model-and-get-samples">Generate data, define a model and get samples</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(crmPack)</span>
<span id="cb1-2"></span>
<span id="cb1-3">empty_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>))</span>
<span id="cb1-4">my_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticNormal</span>(</span>
<span id="cb1-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb1-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb1-7">)</span>
<span id="cb1-8">my_options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>)</span>
<span id="cb1-9">my_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(empty_data, my_model, my_options)</span></code></pre></div></div>
</div>
</section>
<section id="dose" class="level3">
<h3 class="anchored" data-anchor-id="dose">Dose</h3>
<p>Here is the example on how the <code>dose</code> function can be used in case of different inputs, i.e.&nbsp;model’s parameters samples or in case of a fixed model’s parameters values.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Doses reaching a specific target probability of the occurrence of a DLT (equal to 0.3),</span></span>
<span id="cb2-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># given a particular models and samples.</span></span>
<span id="cb2-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Every single dose corresponds to one particular sample in `my_samples`.</span></span>
<span id="cb2-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dose</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, my_model, my_samples)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code> [1]  1.97041802  2.96984159  0.00611966  1.41631224  0.76533912  0.90546991
 [7]  0.61748665  1.88799307  1.25030182 49.08183880  1.18148651  2.02614396
[13]  6.79219796  1.61394892  0.42670535  0.05579120  0.67824893  1.43437105
[19]  1.18203270  0.03417445</code></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># True dose-DLT relationship.</span></span>
<span id="cb4-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Say that -0.8 and 1 are the true values for models parameters alpha0 and alpha1 respectively.</span></span>
<span id="cb4-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># The `true_dose_fun` takes one argument (target probability of the occurrence of a DLT)</span></span>
<span id="cb4-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># and computes the corresponding dose, according to the model chosen and given a fixed values</span></span>
<span id="cb4-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># of the model's parameters.</span></span>
<span id="cb4-6">true_dose_fun <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">doseFunction</span>(my_model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb4-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">true_dose_fun</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 0.9538033</code></pre>
</div>
</div>
</section>
<section id="prob" class="level3">
<h3 class="anchored" data-anchor-id="prob">Prob</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Toxicity probabilities for a given dose (equal to 10), model and samples.</span></span>
<span id="cb6-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Every single probability value corresponds to one particular sample in `my_samples`.</span></span>
<span id="cb6-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">prob</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, my_model, my_samples)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code> [1] 0.62466348 0.09136546 0.82163283 0.91227079 0.95935155 0.07634476
 [7] 0.99807509 0.99347203 0.98867792 0.18206712 0.96282160 0.89851465
[13] 0.27449189 0.96211064 0.99115881 0.79712658 0.87968283 0.85887467
[19] 0.68215724 0.75745908</code></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># True DLT-dose relationship.</span></span>
<span id="cb8-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Say that -0.8 and 1 are the true values for models parameters alpha0 and alpha1 respectively.</span></span>
<span id="cb8-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># The `true_prob_fun` takes one argument (the dose) and computes the corresponding</span></span>
<span id="cb8-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># toxicity probability, according to the model chosen and given a fixed values</span></span>
<span id="cb8-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># of the model's parameters.</span></span>
<span id="cb8-6">true_prob_fun <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(my_model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb8-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">true_prob_fun</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 0.8179597</code></pre>
</div>
</div>
</section>
</section>
<section id="new-random-number-generator-settings-for-the-mcmc" class="level2">
<h2 class="anchored" data-anchor-id="new-random-number-generator-settings-for-the-mcmc">New Random Number Generator settings for the MCMC</h2>
<p>The Random Number Generator (RNG) settings used by the JAGS for the MCMC are now configured solely through the <code>McmcOptions</code> class. The RNG settings are: <code>RNG type</code> and the <code>RNG seed</code> that corresponds to a given <code>RNG type</code>. Find out details in the help page for the <code>McmcOptions</code> class. Any RNG-related user settings at the R session level (such us those with <code>set.seed()</code>) are ignored by the MCMC sampler.</p>
</section>
<section id="new-no-argument-constructors" class="level2">
<h2 class="anchored" data-anchor-id="new-no-argument-constructors">New no-argument constructors</h2>
<p>To aid software development, new no-argument constructs for all sub-classes of <code>GeneralModel</code>, <code>Increments</code>, <code>NextBest</code> and <code>Stopping</code> have been introduced. The names of these constructors take the form <code>.Default&lt;classname&gt;</code>, where <code>&lt;classname&gt;</code> is the name of the class being created.</p>
<p>These constructors return valid, but not necessarily contextually sensible, objects of the required class. One reason the objects returned may not be contextually sensible is that the constructors take no account of any associated <code>doseGrid</code>.</p>
<p>Here are some examples of their use:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.DefaultStoppingAll</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<p>If all of the following rules are <code>TRUE</code>:</p>
<ul>
<li><p>≥ 3 cohorts dosed: If 3 or more cohorts have been treated.</p></li>
<li><p>P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5: If the probability of toxicity at the next best dose is in the range [0.20, 0.35] is at least 0.50.</p></li>
<li><p>≥ 20 patients dosed: If 20 or more participants have been treated.</p></li>
</ul>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">class_name <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LogisticNormal"</span></span>
<span id="cb11-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">eval</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".Default"</span>, class_name, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"()"</span>)))</span></code></pre></div></div>
<div class="cell-output-display">
<p>A logistic log normal model will describe the relationship between dose and toxicity: <img src="https://latex.codecogs.com/png.latex?%20p(Tox%20%7C%20d)%20=%20f(X%20=%201%20%7C%20%5Ctheta,%20d)%20=%20%5Cfrac%7Be%5E%7B%5Calpha%20+%20%5Cbeta%20%5Ccdot%20d/d%5E*%7D%7D%7B1%20+%20e%5E%7B%5Calpha%20+%20%5Cbeta%20%5Ccdot%20d/d%5E*%7D%7D%20">where d* denotes a reference dose.</p>
<p>The prior for θ is given by<img src="https://latex.codecogs.com/png.latex?%20%5Cboldsymbol%5Ctheta%20=%20%5Cbegin%7Bbmatrix%7D%5Calpha%20%5C%5C%20%5Cbeta%5Cend%7Bbmatrix%7D%5Csim%20N%20%5Cleft(%5Cbegin%7Bbmatrix%7D-0.85%20%5C%5C%20%201.00%5Cend%7Bbmatrix%7D%20,%20%5Cbegin%7Bbmatrix%7D%201.00%20&amp;%20-0.50%20%5C%5C%20-0.50%20&amp;%20%201.00%5Cend%7Bbmatrix%7D%20%5Cright)%20"></p>
<p>The reference dose will be 1.00.</p>
</div>
</div>
</section>
<section id="handling-of-na-or-placebo-returned-as-next-dose" class="level2">
<h2 class="anchored" data-anchor-id="handling-of-na-or-placebo-returned-as-next-dose">Handling of <code>NA</code> or placebo returned as next dose</h2>
<p>For consistent handling how the study is stopped and to facilitate analysis of stop reasons in the operation characteristics, the handling of <code>NA</code> and placebo returned by <code>nextBest</code> methods is changed. In the previous version of <code>crmPack</code> stopping for placebo or <code>NA</code> returned by a <code>nextBest</code> method was handled automatically in the generic <code>Stopping</code> method. This is now moved into a new stopping rule <code>StoppingMissingDose</code>. As a consequence, the stopping rule <code>StoppingMissingDose</code> must be specified for those <code>nextBest</code> methods that can return NA, or when placebo is used. Otherwise the simulation may run into an error if the study is not stopped when <code>NA</code> is returned as the next dose. <code>nextBest</code> methods that can return <code>NA</code> are <code>NextBestNCRM</code>, <code>NextBestNCRMLoss</code> and <code>NextBestDualEndpoint</code>.</p>
</section>
<section id="evaluation-of-stopping-rules-at-a-specific-dose" class="level2">
<h2 class="anchored" data-anchor-id="evaluation-of-stopping-rules-at-a-specific-dose">Evaluation of stopping rules at a specific dose</h2>
<p>Without further specification, stopping rules are evaluated at the dose returned by the used <code>nextBest</code> method. With the new stopping rule <code>StoppingSpecificDose</code> it is possible to evaluate stopping rules at any dose. For usage see documentation of <code>StoppingSpecificDose</code>.</p>
</section>
<section id="further-details-in-class-and-methods-name-changes" class="level2">
<h2 class="anchored" data-anchor-id="further-details-in-class-and-methods-name-changes">Further details in class and methods name changes</h2>
<section id="classes" class="level3">
<h3 class="anchored" data-anchor-id="classes">Classes</h3>
<div class="cell">
<div class="cell-output-display">
<table class="table caption-top table-sm table-striped small">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Class/Constructor<sup>*</sup>
</div></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Slot/Arg<sup>†</sup>
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Comment
</div></th>
</tr>
<tr class="even">
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
New Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
New Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: left; empty-cells: hide; border-bottom: hidden;"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td rowspan="3" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">ModelLogNormal</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">new parent class for all the models with reference dose and bivariate (log) normal prior on the model parameters</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">ModelParamsNormal</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">represents parameters of bivariate normal distribution</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">positive_number</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">to handle strictly positive valued slots (e.g. `ref_dose` in many model classes)</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">AllModels</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">CohortSizeDLT</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">cohortSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">cohort_size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLTintervals</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">intervals</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">CohortSizeMax</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">cohortSizeList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">cohort_sizes</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">CohortSizeMin</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">cohortSizeList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">cohort_sizes</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">CohortSizeRange</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">cohortSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">cohort_size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">DALogisticLogNormal</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">C_par</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">c_par</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">conditionalPEM</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">cond_pem</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Design</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">PLcohortSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">pl_cohort_size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DualEndpointBeta</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">refDoseBeta</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">ref_dose_beta</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DualEndpointEmax</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">refDoseEmax</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">ref_dose_emax</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DualEndpointRW</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">useRW1</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">rw1</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">DualEndpointRW()</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">rw1</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaces `smooth` string</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">smooth</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `rw1` flag</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">EffFlexi</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">several slots</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">several slots</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">several slot changed, see man page</td>
</tr>
<tr class="odd">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">EffFlexi()</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">rw1</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaces `smooth` string</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">smooth</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `rw1` flag</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Effloglog</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">several slots</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">several slots</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">several slot changed, see man page</td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">GeneralModel</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">datanames</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">moved from `AllModels`</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">datanames_prior</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">IncrementMin</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">IncrementsMin</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">IncrementsDoseLevels</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">basis_level</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">maxLevels</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">levels</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">change applied also to other dependent classes</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">IncrementsMin</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">IncrementsList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">increments_list</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">change applied also to other dependent classes</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">IncrementsNumDoseLevels</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">IncrementsDoseLevels</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">IncrementsRelativeDLT</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLTintervals</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">intervals</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">change applied also to other dependent classes</td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">IncrementsRelativeParts</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">cleanStart</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">clean_start</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">change applied also to other dependent classes</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">dltStart</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">dlt_start</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">McmcOptions</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">rng_kind</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">to be used by Random Number Generator in rJAGS</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">rng_seed</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">to be used by Random Number Generator in rJAGS</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">Model</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">ModelEff</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">dose</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">moved to model class method</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">ExpEff</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">moved to model class method and renamed to `efficacy`</td>
</tr>
<tr class="odd">
<td rowspan="4" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">NextBestDualEndpoint</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">target_relative</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaces `scale` string</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">maxOverdoseProb</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">max_overdose_prob</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">scale</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `target_relative` flag</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetThresh</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">target_thresh</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">NextBestMaxGain</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLEDuringTrialtarget</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_drt</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLEEndOfTrialtarget</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_eot</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="4" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">NextBestMaxGainSamples</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLEDuringTrialtarget</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_drt</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">DLEEndOfTrialtarget</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_eot</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Gstarderive</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">mg_derive</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">TDderive</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">derive</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">NextBestNCRM</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">maxOverdoseProb</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">max_overdose_prob</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">NextBestTD</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetDuringTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_drt</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetEndOfTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_eot</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">NextBestTDsamples</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetDuringTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_drt</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetEndOfTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target_eot</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">OneParExpNormalPrior</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">OneParLogNormalPrior</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="3" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">OneParLogNormalPrior</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">skel_fun_inv</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">skeletonFun</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">skel_fun</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">skeletonProbs</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">skel_probs</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">OneParLogNormalPrior()</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">doseGrid</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">dose_grid</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="3" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">SafetyWindowConst</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">patientFollow</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">follow</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">patientFollowMin</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">follow_min</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">patientGap</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">gap</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="4" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">SafetyWindowSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">patientFollow</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">follow</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">patientFollowMin</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">follow_min</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">patientGap</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">gap</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">sizeIntervals</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">StoppingAll</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">stopList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">stop_list</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">StoppingAny</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">stopList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">stop_list</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="3" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">StoppingGstarCIRatio</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetEndOfTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetRatio</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">target_ratio</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">StoppingMaxGainCIRatio</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">StoppingList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">stopList</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">stop_list</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">StoppingTargetBiomarker</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">is_relative</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaces `scale` string</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">scale</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `is_relative` flag</td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">StoppingTDCIRatio</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetEndOfTrial</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">prob_target</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">targetRatio</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">target_ratio</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">TDDesign</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">PLcohortSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">pl_cohort_size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">TDsamplesDesign</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">PLcohortSize</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">pl_cohort_size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">TITELogisticLogNormal</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">weightMethod</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">weight_method</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
</tbody><tfoot>
<tr class="odd">
<td style="text-align: left; padding: 0; border: 0;"><sup>*</sup> Class or class' user constructor. In the later case the Name/New Name is followed by ().</td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left; padding: 0; border: 0;"><sup>†</sup> Slot in case of the class or argument in case of the class' user constructor</td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
</tr>
</tfoot>

</table>
</div>
</div>
<p>Strikeout indicates that the class/slot was removed.</p>
</section>
<section id="methods" class="level3">
<h3 class="anchored" data-anchor-id="methods">Methods</h3>
<div class="cell">
<div class="cell-output-display">
<table class="table caption-top table-sm table-striped small">
<colgroup>
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Method
</div></th>
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Argument
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Output Changes
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Comment
</div></th>
</tr>
<tr class="even">
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
New Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
New Name
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: left; empty-cells: hide; border-bottom: hidden;"></th>
<th data-quarto-table-cell-role="th" style="text-align: left; empty-cells: hide; border-bottom: hidden;"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td rowspan="4" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">doseFunction</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">returns dose computing function for a given model</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">efficacy</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">new generic function</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">probFunction</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">returns probability computing function for a given model</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">update-ModelPseudo</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="3" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">biomLevel</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">xLevel</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">added only for generic, reordered arguments for generic and methods</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">dose</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">changed generic and methods</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">biomarker</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">changed generic and methods</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">biomLevel-DualEndpoint</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">dose</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">dose</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">prob</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">x</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">gain</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">several arguments</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">several arguments</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">several arguments (generic and methods) changed, see man page</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">getEff</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">renamed elements in the list returned</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="3" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">mcmc</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">fromPrior</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">from_prior</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">program</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">verbose</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="4" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">nextBest-NextBestMaxGain</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">renamed elements in the list returned</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Effmodel</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">model_eff</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Effsamples</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">samples_eff</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">SIM</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">in_sim</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="4" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">nextBest-NextBestMaxGainSamples</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">renamed elements in the list returned</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Effmodel</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">model_eff</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Effsamples</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">samples_eff</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">SIM</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">in_sim</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="3" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">nextBest-NextBestTD</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Effmodel</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">model_eff</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Effsamples</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">samples_eff</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">SIM</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">in_sim</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">nextBest-NextBestTDsamples</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Effmodel</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">model_eff</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">Effsamples</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">samples_eff</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">size</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">size</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">check</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td rowspan="2" style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid; vertical-align: top !important;"><span style="     ">update-Data</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">check</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">newCohort</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">new_cohort</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">update-DataDA</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">check</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">update-DataDual</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">check</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     ">update-DataParts</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">check</td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">update-EffFlexi</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `update-ModelPseudo`</td>
</tr>
<tr class="odd">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">update-Effloglog</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `update-ModelPseudo`</td>
</tr>
<tr class="even">
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     text-decoration: line-through;">update-LogisticIndepBeta</span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"><span style="     "></span></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;"></td>
<td style="text-align: left; width: 6cm; border-left: 1px solid; border-right: 1px solid;">replaced by `update-ModelPseudo`</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Strikeout indicates that the method/argument was removed.</p>
</section>
</section>
<section id="references" class="level2">




</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-advancedR" class="csl-entry">
Wickham, Hadley. 2019. <em>Advanced r, Second Edition</em>. Chapman &amp; Hall/CRC: R Series. <a href="https://adv-r.hadley.nz">https://adv-r.hadley.nz</a>.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Getting started</category>
  <guid>https://www.crmpack.org/vignettes/upgrading/crmPack_upgrading/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_11.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Describing crmPack objects with knit_print in Rmd/qmd documents</title>
  <dc:creator>John Kirkpatrick, Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/utilities/crmPack_knit_print/</link>
  <description><![CDATA[ 




<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>Objects created by <code>crmPack</code> are almost always S4 objects. Like all S4 objects, by default they do not render in a particularly user-friendly way.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">cs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeDLT</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>))</span>
<span id="cb1-2">cs</span></code></pre></div></div>
</div>
<div class="cell">
<pre><code>#&gt; An object of class "CohortSizeDLT"
#&gt; Slot "intervals":
#&gt; [1] 0 1 2
#&gt; 
#&gt; Slot "cohort_size":
#&gt; [1] 1 3 5</code></pre>
</div>
<p>Fortunately, a little known feature of <code>knitr</code> can put this right at little or no cost to the end user: in the simplest case, demonstrated below, all that needs to be done is to reference the object in a markdown or Quarto chunk.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">cs</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<caption>Defined by the number of toxicities so far observed</caption>
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
No of toxicities
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
</tr>
<tr class="even">
<th style="text-align: right;" data-quarto-table-cell-role="th">Lower</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Upper</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Cohort size</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="even">
<td style="text-align: right;">1</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: right;">2</td>
<td style="text-align: right;">Inf</td>
<td style="text-align: right;">5</td>
</tr>
</tbody>
</table>
</div>
</div>
<blockquote class="blockquote">
<p>The <code>knit_print</code>methods provided by <code>crmPack</code> are not intended to be fully customisable or comprehensive. We do believe, however, that they cover the vast majority of use-cases and are easily extended using the techniques described later in this vignette.</p>
</blockquote>
<blockquote class="blockquote">
<p>Formatting of these objects currently only works for HMTL output. If another format - such as PDF or Microsoft Word - is required, our suggested workaround is to create the HTML output and then print or save the document to the required format.</p>
</blockquote>
</section>
<section id="how-is-this-done" class="level2">
<h2 class="anchored" data-anchor-id="how-is-this-done">How is this done?</h2>
<p>When running code at the console, the result of an R function or statement that is not assigned to an object is <code>print</code>ed.&nbsp;(Unless, of course, it is returned <code>invisible</code>ly.) The same process appears to happen when the chunks of a markdown or Quarto document are evaluated. But that is not quite the case. Instead, the result is passed to an S3 function called <code>knit_print</code> <span class="citation" data-cites="Xie2024">(Xie 2024)</span>. It is the results of running <code>knit_print</code> on the returned expression that appear in the rendered document.</p>
<p>As a simple demonstration of the concept, consider:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">knit_print.DustySpringfield <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x, ...) {</span>
<span id="cb4-2">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"I just don't know what to do with myself"</span></span>
<span id="cb4-3">}</span>
<span id="cb4-4"></span>
<span id="cb4-5">lyric <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span></span>
<span id="cb4-6"></span>
<span id="cb4-7">lyric</span>
<span id="cb4-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 10</span></span>
<span id="cb4-9"></span>
<span id="cb4-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">class</span>(lyric) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DustySpringfield"</span></span>
<span id="cb4-11"></span>
<span id="cb4-12">lyric</span>
<span id="cb4-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; I just don't know what to do with myself</span></span></code></pre></div></div>
</div>
<p>The actions of <code>knit_print</code> are entirely arbitrary, but this mechanism provides developers with an easy way to provide nicely-rendered versions of any objects that are rendered by <code>knitr</code>. We have provided such methods for (almost) all <code>crmPack</code> classes.</p>
</section>
<section id="using-knit_print-in-crmpack" class="level2">
<h2 class="anchored" data-anchor-id="using-knit_print-in-crmpack">Using <code>knit_print</code> in <code>crmPack</code></h2>
<p>By default, all that needs to be done is to reference the object to be printed in a markdown or quarto chunk. This is equivalent to <code>knit_print(object)</code>. However, the <code>knit_print</code> methods for most <code>crmPack</code> classes have optional arguments that can be used to customise the way in which the object is rendered. To change the default value of any parameter to <code>knit_print</code> the function must be called explicitly: <code>knit_print(cs, tox_label = "DLAE")</code>.</p>
<section id="common-customisations" class="level3">
<h3 class="anchored" data-anchor-id="common-customisations">Common customisations</h3>
<p>The most commonly needed customisations are to alter the way in which participants and toxicities are described. These are handled by the <code>label</code> and <code>tox_label</code> arguments to <code>knit_print</code>.</p>
<p>These arguments can be provided either as a scalar or a vector of length 2. If a vector, the first element is taken to describe a single instance and the second any other number of instances. If a scalar, it is converted to a vector, whose first element is the scalar value provided and the second the scalar with <code>"s"</code> appended<sup>1</sup>.</p>
<p>So, for example:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<p>A constant size of 3 participants.</p>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">knit_print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"subject"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<p>A constant size of 3 subjects.</p>
</div>
</div>
<p>Dose units are defined by the <code>units</code> parameter. By default, no units are printed.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>))</span>
<span id="cb7-2">d</span></code></pre></div></div>
<div class="cell-output-display">
<p>No participants are yet evaluable.</p>
<p>The dose grid is 0.1, 0.3, 0.9, 2.5, 5, 10 and 15.</p>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">knit_print</span>(d, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">units =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mg/dL"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<p>No participants are yet evaluable.</p>
<p>The dose grid is 0.1 mg/dL, 0.3 mg/dL, 0.9 mg/dL, 2.5 mg/dL, 5 mg/dL, 10 mg/dL and 15 mg/dL.</p>
</div>
</div>
<p>The format used to display dose levels (and other information in other classes) can be changed with the <code>fmt</code> parameter:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">knit_print</span>(d, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">units =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mg/dL"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fmt =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<p>No participants are yet evaluable.</p>
<p>The dose grid is 0.10 mg/dL, 0.30 mg/dL, 0.90 mg/dL, 2.50 mg/dL, 5.00 mg/dL, 10.00 mg/dL and 15.00 mg/dL.</p>
</div>
</div>
<p><code>biomarker_label</code> and <code>biomarker_units</code> allow the representation of a biomarker to be customised.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.DefaultDualEndpointRW</span>()</span>
<span id="cb10-2">x</span></code></pre></div></div>
<div class="cell-output-display">
<p>The relationships between dose and toxicity and between dose and PD biomarker will be modelled simultaneously.</p>
<p>A probit log normal model will describe the relationship between dose and toxicity: <img src="https://latex.codecogs.com/png.latex?%20%5CPhi%5E%7B-1%7D(Tox%20%7C%20d)%20=%20f(X%20=%201%20%7C%20%5Ctheta,%20d)%20=%20%5Calpha%20+%20%5Cbeta%20%5Ccdot%20log(d/d%5E*)%20">where d* denotes a reference dose.</p>
<p>The prior for θ is given by<img src="https://latex.codecogs.com/png.latex?%20%5Cboldsymbol%5Ctheta%20=%20%5Cbegin%7Bbmatrix%7D%5Calpha%20%5C%5C%20%5Cbeta%5Cend%7Bbmatrix%7D%5Csim%20N%20%5Cleft(%5Cbegin%7Bbmatrix%7D%200.00%20%5C%5C%20%201.00%5Cend%7Bbmatrix%7D%20,%20%5Cbegin%7Bbmatrix%7D%201.00%20&amp;%20%200.00%20%5C%5C%200.00%20&amp;%20%201.00%5Cend%7Bbmatrix%7D%20%5Cright)%20"></p>
<p>The reference dose will be 1.00.</p>
<p>The PD biomarker response <code>w</code> at dose <code>d</code> is modelled as <img src="https://latex.codecogs.com/png.latex?%20w(d)%20%5Csim%20N(f(d),%20%5Csigma_w%5E2)%20"></p>
<p>where f(d) is a first order random walk such that</p>
<p><img src="https://latex.codecogs.com/png.latex?%20f(d)%20=%20%5Cbeta_%7BW_i%7D%20-%20%5Cbeta_%7BW_%7Bi%20-%201%7D%7D%5Csim%20N(0,%200.01%20%5Ctimes%20(d_i%20-%20d_%7Bi%20-%201%7D))%20"></p>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"></span>
<span id="cb11-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">knit_print</span>(x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">biomarker_name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CRP"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">biomarker_units =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mg/dL"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<p>The relationships between dose and toxicity and between dose and PD biomarker will be modelled simultaneously.</p>
<p>A probit log normal model will describe the relationship between dose and toxicity: <img src="https://latex.codecogs.com/png.latex?%20%5CPhi%5E%7B-1%7D(Tox%20%7C%20d)%20=%20f(X%20=%201%20%7C%20%5Ctheta,%20d)%20=%20%5Calpha%20+%20%5Cbeta%20%5Ccdot%20log(d/d%5E*)%20">where d* denotes a reference dose.</p>
<p>The prior for θ is given by<img src="https://latex.codecogs.com/png.latex?%20%5Cboldsymbol%5Ctheta%20=%20%5Cbegin%7Bbmatrix%7D%5Calpha%20%5C%5C%20%5Cbeta%5Cend%7Bbmatrix%7D%5Csim%20N%20%5Cleft(%5Cbegin%7Bbmatrix%7D%200.00%20%5C%5C%20%201.00%5Cend%7Bbmatrix%7D%20,%20%5Cbegin%7Bbmatrix%7D%201.00%20&amp;%20%200.00%20%5C%5C%200.00%20&amp;%20%201.00%5Cend%7Bbmatrix%7D%20%5Cright)%20"></p>
<p>The reference dose will be 1.00.</p>
<p>The PD biomarker response <code>w</code> at dose <code>d</code> is modelled as <img src="https://latex.codecogs.com/png.latex?%20w(d)%20%5Csim%20N(f(d),%20%5Csigma_w%5E2)%20"></p>
<p>where f(d) is a first order random walk such that</p>
<p><img src="https://latex.codecogs.com/png.latex?%20f(d)%20=%20%5Cbeta_%7BW_i%7D%20-%20%5Cbeta_%7BW_%7Bi%20-%201%7D%7D%5Csim%20N(0,%200.01%20%5Ctimes%20(d_i%20-%20d_%7Bi%20-%201%7D))%20"></p>
</div>
</div>
</section>
</section>
<section id="rendering-complex-classes" class="level2">
<h2 class="anchored" data-anchor-id="rendering-complex-classes">Rendering complex classes</h2>
<p>Some <code>crmPack</code> classes have slots whose values are themselves <code>crmPack</code> classes. <code>CohortSizeMax</code> is a simple example. In these cases, the slot values are each passed to <code>knit_print</code> in turn.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.DefaultCohortSizeMax</span>()</span></code></pre></div></div>
<div class="cell-output-display">
The maximum of the cohort sizes defined in the following rules:
<table>
<caption>
Defined by the dose to be used in the next cohort
</caption>
<thead>
<tr>
<th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Dose
</div>
</th>
<th style="empty-cells: hide;border-bottom:hidden;" colspan="1">
</th>
</tr>
<tr>
<th style="text-align:right;">
Lower
</th>
<th style="text-align:right;">
Upper
</th>
<th style="text-align:right;">
Cohort size
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;">
0
</td>
<td style="text-align:right;">
10
</td>
<td style="text-align:right;">
1
</td>
</tr>
<tr>
<td style="text-align:right;">
10
</td>
<td style="text-align:right;">
Inf
</td>
<td style="text-align:right;">
3
</td>
</tr>
</tbody>
</table>
<table>
<caption>
Defined by the number of toxicities so far observed
</caption>
<thead>
<tr>
<th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
No of toxicities
</div>
</th>
<th style="empty-cells: hide;border-bottom:hidden;" colspan="1">
</th>
</tr>
<tr>
<th style="text-align:right;">
Lower
</th>
<th style="text-align:right;">
Upper
</th>
<th style="text-align:right;">
Cohort size
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;">
0
</td>
<td style="text-align:right;">
1
</td>
<td style="text-align:right;">
1
</td>
</tr>
<tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:right;">
Inf
</td>
<td style="text-align:right;">
3
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><code>knit_print</code> methods for sub-classes of <code>RuleDesign</code> (and related classes) offer slightly more control. Here, an overall header for the rendition of the object is provided by the <code>title</code> parameter (whose value defaults to “Design” and the slot values are separated by sub-headers. The styling of the overall header and sub-headers is controlled by the <code>level</code> parameter. The default value of <code>level</code> is <code>2L</code>, and the level of slots is defined recursively to be one more than the level of the parent slot<sup>2</sup>. Class-specific parameters are passed to slot-specific <code>knit_print</code> methods using <code>...</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">knit_print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.DefaultDesign</span>())</span></code></pre></div></div>
<section id="design" class="level2 cell-output-display">
<h2 class="anchored" data-anchor-id="design">Design</h2>
<section id="dose-toxicity-model" class="level3">
<h3 class="anchored" data-anchor-id="dose-toxicity-model">Dose toxicity model</h3>
<p>A logistic log normal model will describe the relationship between dose and toxicity: <img src="https://latex.codecogs.com/png.latex?%20p(Tox%20%7C%20d)%20=%20f(X%20=%201%20%7C%20%5Ctheta,%20d)%20=%20%5Cfrac%7Be%5E%7B%5Calpha%20+%20%5Cbeta%20%5Ccdot%20log(d/d_%7Bref%7D)%7D%7D%7B1%20+%20e%5E%7B%5Calpha%20+%20%5Cbeta%20%5Ccdot%20log(d/d_%7Bref%7D)%7D%7D%20">where d<sub>ref</sub> denotes a reference dose.</p>
<p>The prior for θ is given by<img src="https://latex.codecogs.com/png.latex?%20%5Cboldsymbol%5Ctheta%20=%20%5Cbegin%7Bbmatrix%7D%5Calpha%20%5C%5C%20log(%5Cbeta)%5Cend%7Bbmatrix%7D%5Csim%20N%20%5Cleft(%5Cbegin%7Bbmatrix%7D-0.85%20%5C%5C%20%201.00%5Cend%7Bbmatrix%7D%20,%20%5Cbegin%7Bbmatrix%7D%201.00%20&amp;%20-0.50%20%5C%5C%20-0.50%20&amp;%20%201.00%5Cend%7Bbmatrix%7D%20%5Cright)%20"></p>
<p>The reference dose will be 56.00.</p>
</section>
<section id="stopping-rule" class="level3">
<h3 class="anchored" data-anchor-id="stopping-rule">Stopping rule</h3>
<p>If either of the following rules are <code>TRUE</code>:</p>
<ul>
<li><p>If both of the following rules are <code>TRUE</code>:</p>
<ul>
<li><p>≥ 3 cohorts dosed: If 3 or more cohorts have been treated.</p></li>
<li><p>P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5: If the probability of toxicity at the next best dose is in the range [0.20, 0.35] is at least 0.50.</p></li>
</ul></li>
<li><p>≥ 20 patients dosed: If 20 or more participants have been treated.</p></li>
</ul>
</section>
<section id="escalation-rule" class="level3">
<h3 class="anchored" data-anchor-id="escalation-rule">Escalation rule</h3>
<table>
<caption>
Defined by highest dose administered so far
</caption>
<thead>
<tr>
<th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Dose
</div>
</th>
<th style="empty-cells: hide;border-bottom:hidden;" colspan="1">
</th>
</tr>
<tr>
<th style="text-align:right;">
Min
</th>
<th style="text-align:right;">
Max
</th>
<th style="text-align:right;">
Increment
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;">
0
</td>
<td style="text-align:right;">
20
</td>
<td style="text-align:right;">
1.00
</td>
</tr>
<tr>
<td style="text-align:right;">
20
</td>
<td style="text-align:right;">
Inf
</td>
<td style="text-align:right;">
0.33
</td>
</tr>
</tbody>
</table>
</section>
<section id="use-of-placebo" class="level3">
<h3 class="anchored" data-anchor-id="use-of-placebo">Use of placebo</h3>
<p>Placebo will not be administered in the trial.</p>
</section>
<section id="backfill-cohorts" class="level3">
<h3 class="anchored" data-anchor-id="backfill-cohorts">Backfill cohorts</h3>
<p>No backfill cohorts at all will be opened.</p>
</section>
<section id="dose-recommendation" class="level3">
<h3 class="anchored" data-anchor-id="dose-recommendation">Dose recommendation</h3>
<p>The dose recommended for the next cohort will be chosen in the following way. First, doses that are ineligible according to the increments rule will be discarded. Next, any dose for which the mean posterior probability of toxicity being in the overdose range - (0.35, 1] - is 0.25 or more will also be discarded. Finally, the dose amongst those remaining which has the highest chance that the mean posterior probability of toxicity is in the target toxicity range of 0.2 to 0.35 (inclusive) will be selected.</p>
</section>
<section id="cohort-size" class="level3">
<h3 class="anchored" data-anchor-id="cohort-size">Cohort size</h3>
The maximum of the cohort sizes defined in the following rules:
<table>
<caption>
Defined by the dose to be used in the next cohort
</caption>
<thead>
<tr>
<th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Dose
</div>
</th>
<th style="empty-cells: hide;border-bottom:hidden;" colspan="1">
</th>
</tr>
<tr>
<th style="text-align:right;">
Lower
</th>
<th style="text-align:right;">
Upper
</th>
<th style="text-align:right;">
Cohort size
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;">
0
</td>
<td style="text-align:right;">
30
</td>
<td style="text-align:right;">
1
</td>
</tr>
<tr>
<td style="text-align:right;">
30
</td>
<td style="text-align:right;">
Inf
</td>
<td style="text-align:right;">
3
</td>
</tr>
</tbody>
</table>
<table>
<caption>
Defined by the number of toxicities so far observed
</caption>
<thead>
<tr>
<th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
No of toxicities
</div>
</th>
<th style="empty-cells: hide;border-bottom:hidden;" colspan="1">
</th>
</tr>
<tr>
<th style="text-align:right;">
Lower
</th>
<th style="text-align:right;">
Upper
</th>
<th style="text-align:right;">
Cohort size
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;">
0
</td>
<td style="text-align:right;">
1
</td>
<td style="text-align:right;">
1
</td>
</tr>
<tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:right;">
Inf
</td>
<td style="text-align:right;">
3
</td>
</tr>
</tbody>
</table>
</section>
<section id="observed-data" class="level3">
<h3 class="anchored" data-anchor-id="observed-data">Observed data</h3>
<p>No participants are yet evaluable.</p>
<p>The dose grid is 1, 3, 5, 10, 15, 20, 25, 40, 50, 80 and 100.</p>
</section>
<section id="starting-dose" class="level3">
<h3 class="anchored" data-anchor-id="starting-dose">Starting dose</h3>
<p>The starting dose is 3.</p>
</section>
</section>
</div>
<p>Slot headers can be customised using the <code>sections</code> parameter. <code>sections</code> should be a named vector. Names should be valid slot names for the object being rendered and values the requested slot headers.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">knit_print</span>(</span>
<span id="cb14-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.DefaultDesign</span>(),</span>
<span id="cb14-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">level =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb14-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sections =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb14-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nextBest"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Selection of the dose for the following cohort"</span>,</span>
<span id="cb14-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"startingDose"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Initial dose"</span></span>
<span id="cb14-7">  )</span>
<span id="cb14-8">)</span></code></pre></div></div>
</div>
<p>We omit here the output for brevity.</p>
<blockquote class="blockquote">
<p>It is not possible to omit slots from the rendition of a <code>crmPack</code> object. If you need to do this, you can either render the required slots individually, or override the definition of <code>knit_print</code> for the super class as demonstrated below.</p>
</blockquote>
</section>
<section id="restoring-console-like-behaviour" class="level2">
<h2 class="anchored" data-anchor-id="restoring-console-like-behaviour">Restoring console-like behaviour</h2>
<p>To restore the default behaviour for <code>crmPack</code> objects, simply wrap the object in a call to <code>normal_print()</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normal_print</span>(cs)</span>
<span id="cb15-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; An object of class "CohortSizeDLT"</span></span>
<span id="cb15-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Slot "intervals":</span></span>
<span id="cb15-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 0 1 2</span></span>
<span id="cb15-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb15-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Slot "cohort_size":</span></span>
<span id="cb15-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 1 3 5</span></span></code></pre></div></div>
</div>
</section>
<section id="accessing-the-output-of-knit_print" class="level2">
<h2 class="anchored" data-anchor-id="accessing-the-output-of-knit_print">Accessing the output of <code>knit_print</code></h2>
<p>One of the parameters of <code>knitr::knit_print</code> is <code>asis</code>, with a default value of <code>TRUE</code>. <code>asis</code> has the same effect as setting the chunk option <code>output</code> to <code>asis</code>. This is achieved by returning an object of class <code>knit-asis</code>.</p>
<p>Setting <code>asis</code> to <code>FALSE</code> will display the raw HTML code generated by <code>knit_print</code> to be displayed. Alternatively, it may allow easier manipulation of the return value.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1">csOutput1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">knit_print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeDLT</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)))</span>
<span id="cb16-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">class</span>(csOutput1)</span>
<span id="cb16-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "knit_asis"</span></span>
<span id="cb16-4">csOutput1</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<caption>Defined by the number of toxicities so far observed</caption>
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
No of toxicities
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
</tr>
<tr class="even">
<th style="text-align: right;" data-quarto-table-cell-role="th">Lower</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Upper</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Cohort size</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="even">
<td style="text-align: right;">1</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: right;">2</td>
<td style="text-align: right;">Inf</td>
<td style="text-align: right;">5</td>
</tr>
</tbody>
</table>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">csOutput2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">knit_print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeDLT</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">asis =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb17-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">class</span>(csOutput2)</span>
<span id="cb17-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "character"</span></span>
<span id="cb17-4">csOutput2</span>
<span id="cb17-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "&lt;table&gt;\n&lt;caption&gt;Defined by the number of toxicities so far observed&lt;/caption&gt;\n &lt;thead&gt;\n&lt;tr&gt;\n&lt;th style=\"border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; \" colspan=\"2\"&gt;&lt;div style=\"border-bottom: 1px solid #ddd; padding-bottom: 5px; \"&gt;No of toxicities&lt;/div&gt;&lt;/th&gt;\n&lt;th style=\"empty-cells: hide;border-bottom:hidden;\" colspan=\"1\"&gt;&lt;/th&gt;\n&lt;/tr&gt;\n  &lt;tr&gt;\n   &lt;th style=\"text-align:right;\"&gt; Lower &lt;/th&gt;\n   &lt;th style=\"text-align:right;\"&gt; Upper &lt;/th&gt;\n   &lt;th style=\"text-align:right;\"&gt; Cohort size &lt;/th&gt;\n  &lt;/tr&gt;\n &lt;/thead&gt;\n&lt;tbody&gt;\n  &lt;tr&gt;\n   &lt;td style=\"text-align:right;\"&gt; 0 &lt;/td&gt;\n   &lt;td style=\"text-align:right;\"&gt; 1 &lt;/td&gt;\n   &lt;td style=\"text-align:right;\"&gt; 1 &lt;/td&gt;\n  &lt;/tr&gt;\n  &lt;tr&gt;\n   &lt;td style=\"text-align:right;\"&gt; 1 &lt;/td&gt;\n   &lt;td style=\"text-align:right;\"&gt; 2 &lt;/td&gt;\n   &lt;td style=\"text-align:right;\"&gt; 3 &lt;/td&gt;\n  &lt;/tr&gt;\n  &lt;tr&gt;\n   &lt;td style=\"text-align:right;\"&gt; 2 &lt;/td&gt;\n   &lt;td style=\"text-align:right;\"&gt; Inf &lt;/td&gt;\n   &lt;td style=\"text-align:right;\"&gt; 5 &lt;/td&gt;\n  &lt;/tr&gt;\n&lt;/tbody&gt;\n&lt;/table&gt;\n\n"</span></span></code></pre></div></div>
</div>
<p>But with the chunk option <code>output</code> set to <code>asis</code>…</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(csOutput2)</span></code></pre></div></div>
<table>
<caption>
Defined by the number of toxicities so far observed
</caption>
<thead>
<tr>
<th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2">
<div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
No of toxicities
</div>
</th>
<th style="empty-cells: hide;border-bottom:hidden;" colspan="1">
</th>
</tr>
<tr>
<th style="text-align:right;">
Lower
</th>
<th style="text-align:right;">
Upper
</th>
<th style="text-align:right;">
Cohort size
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;">
0
</td>
<td style="text-align:right;">
1
</td>
<td style="text-align:right;">
1
</td>
</tr>
<tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:right;">
2
</td>
<td style="text-align:right;">
3
</td>
</tr>
<tr>
<td style="text-align:right;">
2
</td>
<td style="text-align:right;">
Inf
</td>
<td style="text-align:right;">
5
</td>
</tr>
</tbody>
</table>
</section>
<section id="sec-override" class="level2">
<h2 class="anchored" data-anchor-id="sec-override">Providing your own <code>knit_print</code> method</h2>
<p>If the methods provided in <code>crmPack</code> don’t do what you want, it’s easy to roll your own, using standard S3 techniques.</p>
<p>The formal arguments to <code>knitr::knit_print</code> are <code>x</code> and <code>...</code>. Additional arguments can be added after <code>...</code>.</p>
<p>As an example, consider <code>knit_print.NextBestNCRM</code>, which currently returns a paragraph of text:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.DefaultNextBestNCRM</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<p>The dose recommended for the next cohort will be chosen in the following way. First, doses that are ineligible according to the increments rule will be discarded. Next, any dose for which the mean posterior probability of toxicity being in the overdose range - (0.35, 1] - is 0.25 or more will also be discarded. Finally, the dose amongst those remaining which has the highest chance that the mean posterior probability of toxicity is in the target toxicity range of 0.2 to 0.35 (inclusive) will be selected.</p>
</div>
</div>
<p>You might feel this is better presented as a bulleted list. You can achieve this as follows<sup>3</sup>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1">knit_print.NextBestNCRM <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x, ...) {</span>
<span id="cb20-2">  knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">asis_output</span>(</span>
<span id="cb20-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(</span>
<span id="cb20-4">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"The dose recommended for the next cohort will be chosen in the following "</span>,</span>
<span id="cb20-5">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"way.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-  First, doses that are ineligible according to the increments rule "</span>,</span>
<span id="cb20-6">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"will be discarded.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-  Next, any dose for which the mean posterior probability of "</span>,</span>
<span id="cb20-7">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" toxicity being in the overdose range - ("</span>,</span>
<span id="cb20-8">      x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>overdose[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>, x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>overdose[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],</span>
<span id="cb20-9">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"] - is "</span>,</span>
<span id="cb20-10">      x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>max_overdose_prob,</span>
<span id="cb20-11">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" or more will also be discarded.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-  Finally, the dose amongst those remaining "</span>,</span>
<span id="cb20-12">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"which has the highest chance that the mean posterior probability of toxicity "</span>,</span>
<span id="cb20-13">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"is in the target toxicity range of "</span>,</span>
<span id="cb20-14">      x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>target[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb20-15">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" to "</span>,</span>
<span id="cb20-16">      x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>target[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],</span>
<span id="cb20-17">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" (inclusive) will be selected.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb20-18">    )</span>
<span id="cb20-19">  )</span>
<span id="cb20-20">}</span>
<span id="cb20-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">registerS3method</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"knit_print"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NextBestNCRM"</span>, knit_print.NextBestNCRM)</span>
<span id="cb20-22"></span>
<span id="cb20-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.DefaultNextBestNCRM</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<p>The dose recommended for the next cohort will be chosen in the following way.</p>
<ul>
<li>First, doses that are ineligible according to the increments rule will be discarded.</li>
<li>Next, any dose for which the mean posterior probability of toxicity being in the overdose range - (0.35, 1] - is 0.25 or more will also be discarded.</li>
<li>Finally, the dose amongst those remaining which has the highest chance that the mean posterior probability of toxicity is in the target toxicity range of 0.2 to 0.35 (inclusive) will be selected.</li>
</ul>
</div>
</div>
</section>
<section id="class-coverage" class="level2">
<h2 class="anchored" data-anchor-id="class-coverage">Class coverage</h2>
<p><code>crmPack</code> defines 138 classes. Custom <code>knit_print</code> methods exist for 102 of them. Of the remaining 36 classes, 25 are virtual classes that will never be directly instantiated by end users. That leaves 11 classes for which <code>knit_print</code> methods may be useful. These classes are listed below.</p>
<div class="cell">
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">Class</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">DualSimulationsSummary</td>
</tr>
<tr class="even">
<td style="text-align: left;">NextBestEWOC</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Simulations</td>
</tr>
<tr class="even">
<td style="text-align: left;">StoppingExternal</td>
</tr>
<tr class="odd">
<td style="text-align: left;">DualSimulations</td>
</tr>
<tr class="even">
<td style="text-align: left;">GeneralSimulations</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Samples</td>
</tr>
<tr class="even">
<td style="text-align: left;">DASimulations</td>
</tr>
<tr class="odd">
<td style="text-align: left;">IncrementsMaxToxProb</td>
</tr>
<tr class="even">
<td style="text-align: left;">EffFlexi</td>
</tr>
<tr class="odd">
<td style="text-align: left;">McmcOptions</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>The majority of these classes relate to simulation of the operating characteristics of CRM trials. Reporting of this information is likely to need customisation that is beyond the scope of a simple function<sup>4</sup>.</p>



</section>


<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-Xie2024" class="csl-entry">
Xie, Yihui. 2024. <span>“Custom Print Methods.”</span> <a href="https://CRAN.R-project.org/package=knitr/vignettes/knit_print.html">https://CRAN.R-project.org/package=knitr/vignettes/knit_print.html</a>.
</div>
</div></section><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>Except for <code>tox_label = "toxicity"</code>, which becomes <code>tox_label = c("toxicity", "toxicities")</code>.↩︎</p></li>
<li id="fn2"><p>Because markdown header styles are defined only for six levels, the greatest value for <code>level</code>, including values generated by nested calls, is <code>6</code>.↩︎</p></li>
<li id="fn3"><p>For simplicity, the <code>tox_label</code> and <code>asis</code> parameters, which are defined in the current implementation of the function, are omitted in this custom implementation. They should be preserved in any “real world” customisation.↩︎</p></li>
<li id="fn4"><p>The <code>crmPack</code> team is considering the creation of markdown or Quarto templates that may assist in this area, but consider this to be a long-term ambition.↩︎</p></li>
</ol>
</section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Utilities</category>
  <guid>https://www.crmpack.org/vignettes/utilities/crmPack_knit_print/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_12.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Parallel computing with crmPack extensions</title>
  <dc:creator>Oliver Boix, Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/utilities/crmPack_parallel_computing/</link>
  <description><![CDATA[ 




<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>One of the big advantages of <code>crmPack</code> over existing R implementations is its flexible framework based on the S4 classes and methods system <span class="citation" data-cites="Chambers2008">(Chambers 2008)</span>. Users can extend the existing functionality easily to the specific needs of the study <span class="citation" data-cites="SabanesBove2019">(Sabanés Bové et al. 2019)</span>.</p>
<p>User defined extensions of classes and methods can be easily created and used together with existing <code>crmPack</code> classes and methods when setting up the study and performing analysis with observed data. As long as no parallel computing is used, no special care needs to be taken utilizing both native and user defined classes and methods. When trial simulations need to be performed to derive the operational characteristics of a study setup, run times may become long with single core processing. The run time depends mainly on the number of study replications and MCMC samples. In cases of long run times, utilizing parallel computing, i.e., using multiple CPU cores, can overcome these challenge and decrease run times significantly.</p>
<p>Parallel computing is supported by <code>crmPack</code> by design, i.e., whenever the simulation call is invoked with parameters <code>parallel = TRUE</code> and <code>nCores =</code> more than one CPU, each core is initialized with the <code>crmPack</code> package and the global environment.</p>
<p>Due to the nature of the S4 object system, user defined classes and method that were defined in the global environment cannot just be made available at each core by initializing the core with the global environment. User defined classes and method needs to be executed at any core that is initialized to warrant full functionality of the S4 objects.</p>
<p>The following paragraphs provide an example of how user defined extensions can be used utilizing parallel computing within <code>crmPack</code>.</p>
</section>
<section id="high-level-usage" class="level2">
<h2 class="anchored" data-anchor-id="high-level-usage">High level usage</h2>
<p>To use user written extension with parallel computing and <code>crmPack</code>, the user written code needs to be embedded in a function. This function will be stored in the value of a global option with the fixed name <code>crmpack_extensions</code>. The existence of the global option is evaluated when parallel computing is requested. In case the option <code>crmpack_extensions</code> exists, the content is submitted to any node of the cluster, so that the user written S4 classes and methods are available along with the <code>crmPack</code> package.</p>
<p>The following code show at a high level, how the option is utilized.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(</span>
<span id="cb1-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">crmpack_extensions =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb1-3">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ..... user code .....</span></span>
<span id="cb1-4">  }</span>
<span id="cb1-5">)</span></code></pre></div></div>
</div>
</section>
<section id="important-information-for-usage" class="level2">
<h2 class="anchored" data-anchor-id="important-information-for-usage">Important information for usage</h2>
<p>When operation characteristics of the design needs to be derived utilizing parallel computing, the simulation function must be executed with the parameter <code>parallel = TRUE</code> and <code>nCores =</code> a number greater than one. In this case, it is evaluated if a global option with the name <code>crmpack_extensions</code> exists. If this is true, the value of the global option <code>crmpack_extensions</code> is executed at each core at the time of initialization, i.e., the character string that is equal to the global option <code>crmpack_extensions</code> is executed at any core of the cluster, so that the code is available for the use with parallel computing.</p>
<p>Please note that the wrapper function that holds the user extensions is the most convenient way to hand over <code>class</code> and <code>method</code> definitions and the user constructor function to the <code>crmpack_extensions</code> option. However, the constructor function must be available in the environment from which it is called. When the extensions are directly coded within the wrapper function, the <code>&lt;&lt;-</code> operator must be used for any new user defined constructor function that is defined within the wrapper function. The <code>&lt;&lt;-</code> operator will force a function to become visible within the global environment. Another possibility is to store the user extensions in a file that is sourced within the wrapper function. In this case user defined constructor function can be assigned with the regular <code>&lt;-</code> operator, as source parse the content of the file in the environment.</p>
<p>To avoid errors it is important to understand that packages attached to the current environment are not available at the workers environment. I.e., even though the code may work without any problems when used with single core processing, it may fail in parallel execution as functions are not attached to the workers environment. Therefore it is necessary to make sure that all called functions are available in the workers environment. This can be achieved by including a <code>library</code> statement within the wrapper function or by using the double colon operator <code>::</code>.</p>
<p>Any of the above described usage options are further detailed in the example.</p>
</section>
<section id="information-for-debugging" class="level2">
<h2 class="anchored" data-anchor-id="information-for-debugging">Information for debugging</h2>
<p>It is expected as a good practice, that any new written extension is first tested and validated with one CPU core, before utilizing the global option <code>crmpack_extensions</code>. It is important to understand that the character string that is the value of the global option <code>crmpack_extensions</code> is executed directly at each core and will not be checked for validity or correctness. In case that the code run into errors, the returned error message while using parallel computing may be misleading and may not help to identify the root cause of problem. Debugging of newly written code is much easier without using parallel computing.</p>
</section>
<section id="worked-out-example" class="level2">
<h2 class="anchored" data-anchor-id="worked-out-example">Worked out example</h2>
<p>Let us assume we want to utilize a two-parameter logistic regression model, where the slope parameter should have only positive values, with a normal prior that is truncated for the slope parameter, so that the slope can have only positive values. In this case we want to set the prior distribution of the slope parameter to be a truncated normal distribution bounded by zero on the lower end. This model representation is not part of the <code>crmPack</code> package but can easily be added as shown below. Please note that for this example the extra code is directly inserted into the option <code>crmpack_extensions</code> as a function. As mentioned before, user should write and test their code first without embedding it into a function which is set equal to the option <code>crmpack_extensions</code>, to assure that no errors occur during the whole execution and the results are as expected.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(crmPack)</span>
<span id="cb2-2"></span>
<span id="cb2-3">my_own_extension <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb2-4">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Attach the package checkmate with library(checkmate) here, to avoid usage of</span></span>
<span id="cb2-5">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># the :: operator in the code below.</span></span>
<span id="cb2-6"></span>
<span id="cb2-7">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># LogisticNormalTruncPrior ----</span></span>
<span id="cb2-8"></span>
<span id="cb2-9">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## class ----</span></span>
<span id="cb2-10"></span>
<span id="cb2-11">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' `LogisticNormalTruncPrior`</span></span>
<span id="cb2-12">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-13">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @description `r lifecycle::badge("experimental")`</span></span>
<span id="cb2-14">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-15">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' [`LogisticNormalTruncPrior`] is the class for the usual logistic regression</span></span>
<span id="cb2-16">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'  model with bivariate normal prior on the intercept and slope.</span></span>
<span id="cb2-17">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-18">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @aliases LogisticNormalTruncPrior</span></span>
<span id="cb2-19">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @export</span></span>
<span id="cb2-20">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-21">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @slot mean1 the mean of the intercept</span></span>
<span id="cb2-22">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @slot mean2 the mean of the slope</span></span>
<span id="cb2-23">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @slot var1 the variance of the intercept</span></span>
<span id="cb2-24">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @slot var2 the variance of the slope</span></span>
<span id="cb2-25">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-26">  .LogisticNormalTruncPrior <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setClass</span>(</span>
<span id="cb2-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Class =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LogisticNormalTruncPrior"</span>,</span>
<span id="cb2-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">contains =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GeneralModel"</span>,</span>
<span id="cb2-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slots =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb2-30">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean1 =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>,</span>
<span id="cb2-31">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean2 =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>,</span>
<span id="cb2-32">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var1 =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>,</span>
<span id="cb2-33">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var2 =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span></span>
<span id="cb2-34">    )</span>
<span id="cb2-35">  )</span>
<span id="cb2-36"></span>
<span id="cb2-37">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## constructor ----</span></span>
<span id="cb2-38"></span>
<span id="cb2-39">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @rdname LogisticNormalTruncPrior-class</span></span>
<span id="cb2-40"></span>
<span id="cb2-41">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' Initialization function for the `LogisticNormalTruncPrior` class</span></span>
<span id="cb2-42">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-43">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param mean1 the mean of the intercept</span></span>
<span id="cb2-44">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param mean2 the mean of the slope</span></span>
<span id="cb2-45">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param var1 the variance of the intercept</span></span>
<span id="cb2-46">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param var2 the variance of the slope</span></span>
<span id="cb2-47">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @return the \code{\linkS4class{LogisticNormalTruncPrior}} object</span></span>
<span id="cb2-48">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-49">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @export</span></span>
<span id="cb2-50">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @keywords methods</span></span>
<span id="cb2-51">  LogisticNormalTruncPrior <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(mean1, mean2, var1, var2) {</span>
<span id="cb2-52">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">.LogisticNormalTruncPrior</span>(</span>
<span id="cb2-53">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean1 =</span> mean1,</span>
<span id="cb2-54">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean2 =</span> mean2,</span>
<span id="cb2-55">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var1 =</span> var1,</span>
<span id="cb2-56">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var2 =</span> var2,</span>
<span id="cb2-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">datamodel =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb2-58">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>nObs) {</span>
<span id="cb2-59">          y[i] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dbern</span>(mean[i])</span>
<span id="cb2-60">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">logit</span>(mean[i]) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> alpha0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> alpha1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> x[i]</span>
<span id="cb2-61">        }</span>
<span id="cb2-62">      },</span>
<span id="cb2-63">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">priormodel =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb2-64">        alpha0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dnorm</span>(mean1, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> var1)</span>
<span id="cb2-65">        alpha1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dnorm</span>(mean2, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> var2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%_%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">I</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, )</span>
<span id="cb2-66">      },</span>
<span id="cb2-67">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">datanames =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nObs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x"</span>),</span>
<span id="cb2-68">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">modelspecs =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb2-69">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb2-70">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean1 =</span> mean1,</span>
<span id="cb2-71">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean2 =</span> mean2,</span>
<span id="cb2-72">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var1 =</span> var1,</span>
<span id="cb2-73">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var2 =</span> var2</span>
<span id="cb2-74">        )</span>
<span id="cb2-75">      },</span>
<span id="cb2-76">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">init =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb2-77">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> mean1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> mean2)</span>
<span id="cb2-78">      },</span>
<span id="cb2-79">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"alpha0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"alpha1"</span>)</span>
<span id="cb2-80">    )</span>
<span id="cb2-81">  }</span>
<span id="cb2-82"></span>
<span id="cb2-83">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## dose ----</span></span>
<span id="cb2-84"></span>
<span id="cb2-85">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @describeIn dose compute the dose level reaching a specific toxicity</span></span>
<span id="cb2-86">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'   probability.</span></span>
<span id="cb2-87">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-88">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @aliases dose-LogisticNormalTruncPrior</span></span>
<span id="cb2-89">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @export</span></span>
<span id="cb2-90">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-91">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setMethod</span>(</span>
<span id="cb2-92">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">f =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dose"</span>,</span>
<span id="cb2-93">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">signature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">signature</span>(</span>
<span id="cb2-94">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>,</span>
<span id="cb2-95">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LogisticNormalTruncPrior"</span>,</span>
<span id="cb2-96">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples"</span></span>
<span id="cb2-97">    ),</span>
<span id="cb2-98">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">definition =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x, model, samples) {</span>
<span id="cb2-99">      checkmate<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">assert_probabilities</span>(x)</span>
<span id="cb2-100">      checkmate<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">assert_subset</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"alpha0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"alpha1"</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(samples))</span>
<span id="cb2-101">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">assert_length</span>(x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">len =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">size</span>(samples))</span>
<span id="cb2-102"></span>
<span id="cb2-103">      alpha0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha0</span>
<span id="cb2-104">      alpha1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha1</span>
<span id="cb2-105">      (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">logit</span>(x) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> alpha0) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> alpha1</span>
<span id="cb2-106">    }</span>
<span id="cb2-107">  )</span>
<span id="cb2-108"></span>
<span id="cb2-109">  <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## prob ----</span></span>
<span id="cb2-110"></span>
<span id="cb2-111">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @describeIn prob compute the toxicity probability of a specific dose.</span></span>
<span id="cb2-112">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-113">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @aliases prob-LogisticNormalTruncPrior</span></span>
<span id="cb2-114">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @export</span></span>
<span id="cb2-115">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#'</span></span>
<span id="cb2-116">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setMethod</span>(</span>
<span id="cb2-117">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">f =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"prob"</span>,</span>
<span id="cb2-118">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">signature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">signature</span>(</span>
<span id="cb2-119">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dose =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"numeric"</span>,</span>
<span id="cb2-120">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LogisticNormalTruncPrior"</span>,</span>
<span id="cb2-121">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples"</span></span>
<span id="cb2-122">    ),</span>
<span id="cb2-123">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">definition =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(dose, model, samples) {</span>
<span id="cb2-124">      checkmate<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">assert_numeric</span>(</span>
<span id="cb2-125">        dose,</span>
<span id="cb2-126">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lower =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>L, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">any.missing =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min.len =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb2-127">      )</span>
<span id="cb2-128">      checkmate<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">assert_subset</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"alpha0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"alpha1"</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(samples))</span>
<span id="cb2-129">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">assert_length</span>(dose, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">len =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">size</span>(samples))</span>
<span id="cb2-130"></span>
<span id="cb2-131">      alpha0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha0</span>
<span id="cb2-132">      alpha1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha1</span>
<span id="cb2-133">      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>alpha0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> alpha1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> dose))</span>
<span id="cb2-134">    }</span>
<span id="cb2-135">  )</span>
<span id="cb2-136">}</span></code></pre></div></div>
</div>
<p>After the new code is defined and embedded into a function, we can store the function as value of a global option, which we will name <code>crmpack_extensions</code>.</p>
<p>Please note that <code>&lt;&lt;-</code>operator is used to assign the <code>LogisticNormalTruncPrior</code> function to the global environment. The assertion functions from the package <code>checkmate</code> are referenced by the double colon operator in this example. In case that the package <code>checkmate</code> is attached within the function, i.e., the statement <code>library(checkmate)</code> is used in the code above, the direct reference <code>checkmate::</code> can be removed. Either way works with parallel computing as this makes sure that the functions can be used in the current environment and at the workers when parallel study simulations are performed.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Store the function into the global option crmpack_extensions.</span></span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">crmpack_extensions =</span> my_own_extension)</span></code></pre></div></div>
</div>
<p>Now we are able to use the newly created model <code>LogisticNormalTruncPrior</code> to set up a study. First, we get the value from the global option <code>crmpack_extensions</code>, which is the function that we have defined above. Then we execute the function within the global environment, so that the constructor function and the corresponding classes and methods for <code>prob</code> and <code>dose</code> become available.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Execute the user written extensions.</span></span>
<span id="cb4-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">getOption</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"crmpack_extensions"</span>)()</span></code></pre></div></div>
</div>
<p>Next we can set up the study with the new model and desired design features.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create the dose grid.</span></span>
<span id="cb5-2">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb5-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb5-4">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">120</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">160</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">240</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">320</span>,</span>
<span id="cb5-5">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">480</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">640</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">960</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1280</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1920</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2400</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3000</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4000</span></span>
<span id="cb5-6">  ),</span>
<span id="cb5-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placebo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb5-8">)</span>
<span id="cb5-9"></span>
<span id="cb5-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create data for basic testing of the setup.</span></span>
<span id="cb5-11">my_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb5-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">160</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">160</span>),</span>
<span id="cb5-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb5-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>),</span>
<span id="cb5-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>,</span>
<span id="cb5-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> emptydata<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid</span>
<span id="cb5-17">)</span>
<span id="cb5-18"></span>
<span id="cb5-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Setup the model.</span></span>
<span id="cb5-20">my_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticNormalTruncPrior</span>(</span>
<span id="cb5-21">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean1 =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb5-22">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.00075</span>,</span>
<span id="cb5-23">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var1 =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb5-24">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.000009</span></span>
<span id="cb5-25">)</span>
<span id="cb5-26"></span>
<span id="cb5-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Options used for simulations.</span></span>
<span id="cb5-28">my_options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb5-29">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb5-30">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb5-31">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb5-32">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rng_kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mersenne-Twister"</span>,</span>
<span id="cb5-33">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rng_seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">94</span></span>
<span id="cb5-34">)</span>
<span id="cb5-35"></span>
<span id="cb5-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create mcmc samples.</span></span>
<span id="cb5-37">my_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(my_data, my_model, my_options)</span>
<span id="cb5-38"></span>
<span id="cb5-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Plot the dose toxicity curve.</span></span>
<span id="cb5-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(my_samples, my_model, my_data)</span>
<span id="cb5-41"></span>
<span id="cb5-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Specify increments.</span></span>
<span id="cb5-43">my_increments <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelativeDLT</span>(</span>
<span id="cb5-44">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb5-45">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb5-46">)</span>
<span id="cb5-47"></span>
<span id="cb5-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Maximum dose.</span></span>
<span id="cb5-49">this_max_dose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxDose</span>(my_increments, my_data)</span>
<span id="cb5-50"></span>
<span id="cb5-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Next best dose.</span></span>
<span id="cb5-52">my_next_best <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">NextBestMinDist</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">target =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>)</span>
<span id="cb5-53">this_next_dose <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextBest</span>(</span>
<span id="cb5-54">  my_next_best, this_max_dose, my_samples, my_model, my_data</span>
<span id="cb5-55">)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>value</span>
<span id="cb5-56"></span>
<span id="cb5-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Stopping rule.</span></span>
<span id="cb5-58">my_stopping <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">StoppingPatientsNearDose</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">percentage =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb5-59"></span>
<span id="cb5-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Stop trial based on criteria and observed data.</span></span>
<span id="cb5-61"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopTrial</span>(my_stopping, this_next_dose, my_samples, my_model, my_data)</span>
<span id="cb5-62"></span>
<span id="cb5-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Cohorts size.</span></span>
<span id="cb5-64">my_size <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeDLT</span>(</span>
<span id="cb5-65">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb5-66">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb5-67">)</span>
<span id="cb5-68"></span>
<span id="cb5-69"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Design.</span></span>
<span id="cb5-70">my_design <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Design</span>(</span>
<span id="cb5-71">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> my_model,</span>
<span id="cb5-72">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nextBest =</span> my_next_best,</span>
<span id="cb5-73">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stopping =</span> my_stopping,</span>
<span id="cb5-74">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> my_increments,</span>
<span id="cb5-75">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> my_size,</span>
<span id="cb5-76">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> emptydata,</span>
<span id="cb5-77">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">startingDose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span></span>
<span id="cb5-78">)</span></code></pre></div></div>
</div>
<p>After setting up the model and the design features, it is very useful to check the model decisions in case that no DLT is observed until a certain dose level before any study simulations are performed. This check can also serve as additional test for the new written code.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Examine the design.</span></span>
<span id="cb6-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">examine</span>(my_design, my_options)</span></code></pre></div></div>
</div>
<p>When examine runs as expected, study simulations can be performed. To demonstrate the difference between single core processing and multiple core processing, two scenarios where processed with single core processing, followed by 5 scenarios utilizing parallel computing.</p>
<p>With regard to run times in this example, please see the note at the end of the vignette.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Set up scenarios</span></span>
<span id="cb7-2">scenario_setup <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(intercept, mtd_prob, mtd_dose) {</span>
<span id="cb7-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(</span>
<span id="cb7-4">    my_model,</span>
<span id="cb7-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">logit</span>(intercept),</span>
<span id="cb7-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">logit</span>(mtd_prob) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">logit</span>(intercept)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mtd_dose</span>
<span id="cb7-7">  )</span>
<span id="cb7-8">}</span>
<span id="cb7-9"></span>
<span id="cb7-10">safe_scenario <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scenario_setup</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20000</span>)</span>
<span id="cb7-11">late_scenario <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scenario_setup</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span>)</span>
<span id="cb7-12">early_scenario <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scenario_setup</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">700</span>)</span>
<span id="cb7-13">toxic_scenario <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scenario_setup</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb7-14">peak_scenario <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(</span>
<span id="cb7-15">  dose,</span>
<span id="cb7-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">scenario =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cbind</span>(emptydata<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)))</span>
<span id="cb7-17">) {</span>
<span id="cb7-18">  scenario[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">match</span>(dose, scenario[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]</span>
<span id="cb7-19">}</span>
<span id="cb7-20"></span>
<span id="cb7-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Helper function that outputs the elapsed time.</span></span>
<span id="cb7-22">report_time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(report_text) {</span>
<span id="cb7-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(</span>
<span id="cb7-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Sys.time</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">usetz =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb7-25">    report_text,</span>
<span id="cb7-26">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"done - elapsed time from start:"</span>,</span>
<span id="cb7-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">difftime</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Sys.time</span>(), start_time, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">units =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mins"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-28">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-29">  )</span>
<span id="cb7-30">}</span>
<span id="cb7-31"></span>
<span id="cb7-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Helper function that simulates a specific truth.</span></span>
<span id="cb7-33">get_oc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(truth) {</span>
<span id="cb7-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulate</span>(</span>
<span id="cb7-35">    my_design,</span>
<span id="cb7-36">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">args =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb7-37">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">truth =</span> truth,</span>
<span id="cb7-38">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsim =</span> my_nsim,</span>
<span id="cb7-39">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmcOptions =</span> my_options,</span>
<span id="cb7-40">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> do_parallel,</span>
<span id="cb7-41">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nCores =</span> parallelly<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">availableCores</span>()</span>
<span id="cb7-42">  )</span>
<span id="cb7-43">}</span>
<span id="cb7-44"></span>
<span id="cb7-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># get operation characteristics without utilizing parallel computing for</span></span>
<span id="cb7-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># selected truth (to reduce the run time).</span></span>
<span id="cb7-47">time_no_parallel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">system.time</span>({</span>
<span id="cb7-48">  start_time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Sys.time</span>()</span>
<span id="cb7-49">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Sys.time</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">usetz =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"start"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb7-50"></span>
<span id="cb7-51">  my_nsim <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span></span>
<span id="cb7-52">  do_parallel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb7-53"></span>
<span id="cb7-54">  safe <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_oc</span>(safe_scenario)</span>
<span id="cb7-55"></span>
<span id="cb7-56">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">report_time</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"safe (single core processing)"</span>)</span>
<span id="cb7-57"></span>
<span id="cb7-58">  late <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_oc</span>(late_scenario)</span>
<span id="cb7-59"></span>
<span id="cb7-60">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">report_time</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"late (single core processing)"</span>)</span>
<span id="cb7-61">})</span></code></pre></div></div>
</div>
<p>When simulations with single core processing are running successful, the full operation characteristics utilizing parallel computing can be derived.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get full operation characteristics utilizing parallel computing.</span></span>
<span id="cb8-2">time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">system.time</span>({</span>
<span id="cb8-3">  start_time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Sys.time</span>()</span>
<span id="cb8-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Sys.time</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">usetz =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"start"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb8-5"></span>
<span id="cb8-6">  my_nsim <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span></span>
<span id="cb8-7">  do_parallel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb8-8"></span>
<span id="cb8-9">  safe <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_oc</span>(safe_scenario)</span>
<span id="cb8-10"></span>
<span id="cb8-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">report_time</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"safe"</span>)</span>
<span id="cb8-12"></span>
<span id="cb8-13">  late <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_oc</span>(late_scenario)</span>
<span id="cb8-14"></span>
<span id="cb8-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">report_time</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"late"</span>)</span>
<span id="cb8-16"></span>
<span id="cb8-17">  early <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_oc</span>(early_scenario)</span>
<span id="cb8-18"></span>
<span id="cb8-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">report_time</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"early"</span>)</span>
<span id="cb8-20"></span>
<span id="cb8-21">  toxic <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_oc</span>(toxic_scenario)</span>
<span id="cb8-22"></span>
<span id="cb8-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">report_time</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"toxic"</span>)</span>
<span id="cb8-24"></span>
<span id="cb8-25">  peak <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_oc</span>(peak_scenario)</span>
<span id="cb8-26"></span>
<span id="cb8-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">report_time</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"peak"</span>)</span>
<span id="cb8-28">})</span></code></pre></div></div>
</div>
</section>
<section id="alternative-read-user-code-from-external-file" class="level2">
<h2 class="anchored" data-anchor-id="alternative-read-user-code-from-external-file">Alternative: read user code from external file</h2>
<p>As an alternative it may be more convenient to store the user extensions in an external file and source the file in the wrapper function. This has the advantage, that the <code>&lt;&lt;-</code> operator is not necessary for user constructor functions and can be replaced by the usual assignment <code>&lt;-</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) {</span>
<span id="cb9-2">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Store code example form above in external file and</span></span>
<span id="cb9-3">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove the wrapper function structure.</span></span>
<span id="cb9-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dump</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"my_own_extension"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">file =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"user_extension.R"</span>)</span>
<span id="cb9-5">  file_con <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"user_extension.R"</span>)</span>
<span id="cb9-6">  tmp <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(file_con)[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">135</span>)]</span>
<span id="cb9-7">  tmp <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;&lt;-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;-"</span>, tmp)</span>
<span id="cb9-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">writeLines</span>(tmp, file_con)</span>
<span id="cb9-9"></span>
<span id="cb9-10">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Source the stored file in the wrapper function.</span></span>
<span id="cb9-11">  my_own_extension2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb9-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"user_extension.R"</span>)</span>
<span id="cb9-13">  }</span>
<span id="cb9-14"></span>
<span id="cb9-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">crmpack_extensions =</span> my_own_extension2)</span>
<span id="cb9-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">getOption</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"crmpack_extensions"</span>)()</span>
<span id="cb9-17"></span>
<span id="cb9-18">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Run the rest of the code from above example</span></span>
<span id="cb9-19">}</span></code></pre></div></div>
</div>
</section>
<section id="note" class="level2">
<h2 class="anchored" data-anchor-id="note">Note</h2>
<p>The analyses presented in this vignette have used chains of a very short length as well as a very limited number of trial simulations. This is purely for convenience. Study simulations for real trials should use considerably longer chains and a much higher number of trial simulations.</p>
<p>In this example it is apparent that for small number of study simulations, the overhead of initializing the cluster for parallel computing, leads to longer run time of the simulations in comparison to single core processing. However, for a relevant number of study simulations, the substantial run time benefit utilizing parallel computation can easily be seen.</p>
</section>
<section id="references" class="level2">




</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-Chambers2008" class="csl-entry">
Chambers, John. 2008. <em>Software for Data Analysis</em>. Statistics and Computing. Springer-Verlag.
</div>
<div id="ref-SabanesBove2019" class="csl-entry">
Sabanés Bové, Daniel, Wai Yin Yeung, Giuseppe Palermo, and Thomas Jaki. 2019. <span>“Model-Based Dose Escalation Designs in r with crmPack.”</span> <em>Journal of Statistical Software</em> 89. <a href="https://doi.org/10.18637/jss.v089.i10">https://doi.org/10.18637/jss.v089.i10</a>.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Utilities</category>
  <guid>https://www.crmpack.org/vignettes/utilities/crmPack_parallel_computing/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_13.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Using tidy methods with crmPack to facilitate reporting</title>
  <dc:creator>John Kirkpatrick, Daniel Sabanés Bové</dc:creator>
  <link>https://www.crmpack.org/vignettes/utilities/crmPack_tidy/</link>
  <description><![CDATA[ 




<section id="introducing-tidy-methods-to-crmpack" class="level1">
<h1>Introducing tidy methods to crmPack</h1>
<p>The latest release of <code>crmPack</code> introduces <code>broom</code>-like tidy methods for all <code>crmPack</code> classes. These methods convert the underlying S4 classes to (lists of) <code>tibble</code>s. This should facilitate reporting of all aspects of CRM trials as well as making it easier to integrate <code>crmPack</code> with other packages such as <code>ggplot2</code>.</p>
<section id="basic-approach" class="level2">
<h2 class="anchored" data-anchor-id="basic-approach">Basic approach</h2>
<p>The following is the general approach we take to tidying <code>crmPack</code> classes:</p>
<ul>
<li>All slots that are not functions are converted to <code>tibble</code>s or a list of <code>tibble</code>s.</li>
<li>If the slot’s value is a <code>list</code>, these rules are applied to each element of the list in turn.</li>
<li>If the slot’s value is scalar, the slot is converted to a 1x1 <code>tibble</code>. This will ease downstream operations such as <code>row_bind</code>ing.</li>
<li>If the object being tidied contains multiple slots of (potentially) different lengths, the result is a list of <code>tibble</code>s. The list may be nested to multiple levels. (See, for example, <code>LogisticLogNormal</code>.)</li>
<li>The column names of the tidied <code>tibble</code> correspond to the slot names of the parent object.
<ul>
<li>Exception: where the slot has name in the plural and contains a <code>vector</code> or <code>list</code>, the column name will be singular. See, for example, <code>CohortSizeParts</code> below.</li>
</ul></li>
<li>When the value of a slot has not been set, a zero-row <code>tibble</code> is returned.</li>
<li>When the value of a slot has scalar attributes, these attributes are added as columns of the <code>tibble</code>, whose name is the name of the attribute and whose value is the value of the attribute for every row of the tibble. Vector attributes can be added, by default, as a nested tibble. The nested tibble is 1 row x n column, with column names defined by the name of the attribute and values given by the value of the corresponding attribute.</li>
<li><code>tbl_&lt;className&gt;</code> is prepended to the class of the (list of) tidy <code>tibble</code>(s).</li>
</ul>
</section>
<section id="exceptions" class="level2">
<h2 class="anchored" data-anchor-id="exceptions">Exceptions</h2>
<ul>
<li>Where a vector slot (or series of vector slots) define a range ()for example, the <code>intervals</code> slot in various <code>CohortSize</code> and <code>Increments</code> classes, then the naming convention described above is not followed. Instead, columns named <code>min</code> and <code>max</code> define the extent of the range.</li>
</ul>
</section>
<section id="examples" class="level2">
<h2 class="anchored" data-anchor-id="examples">Examples</h2>
<p><code>CohortSizeConst</code> is a trivial example and illustrates the default approach for all classes.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>()</span>
<span id="cb1-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # A tibble: 1 × 1</span></span>
<span id="cb1-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    size</span></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   &lt;int&gt;</span></span>
<span id="cb1-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1     3</span></span></code></pre></div></div>
</div>
<p><code>IncrementsRelative</code> illustrate how ranges are handled.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">IncrementsRelative</span>(</span>
<span id="cb2-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>),</span>
<span id="cb2-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">increments =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.33</span>)</span>
<span id="cb2-4">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb2-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>()</span>
<span id="cb2-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # A tibble: 2 × 3</span></span>
<span id="cb2-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     min   max increment</span></span>
<span id="cb2-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   &lt;dbl&gt; &lt;dbl&gt;     &lt;dbl&gt;</span></span>
<span id="cb2-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1     0    20      1   </span></span>
<span id="cb2-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 2    20   Inf      0.33</span></span></code></pre></div></div>
</div>
<p><code>CohortSizeMax</code> contains a slot whose value is a list.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">cs_max <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">maxSize</span>(</span>
<span id="cb3-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeConst</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb3-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeDLT</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb3-4">)</span>
<span id="cb3-5">cs_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>()</span>
<span id="cb3-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[1]]</span></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # A tibble: 1 × 1</span></span>
<span id="cb3-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    size</span></span>
<span id="cb3-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   &lt;int&gt;</span></span>
<span id="cb3-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1     3</span></span>
<span id="cb3-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb3-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [[2]]</span></span>
<span id="cb3-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # A tibble: 2 × 3</span></span>
<span id="cb3-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     min   max cohort_size</span></span>
<span id="cb3-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   &lt;dbl&gt; &lt;dbl&gt;       &lt;int&gt;</span></span>
<span id="cb3-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1     0     1           1</span></span>
<span id="cb3-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 2     1   Inf           3</span></span>
<span id="cb3-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb3-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attr(,"class")</span></span>
<span id="cb3-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] "tbl_CohortSizeMax" "tbl_CohortSizeMax" "list"</span></span></code></pre></div></div>
</div>
<p>The <code>Samples</code> class likely to the most useful when making presentations not yet supported by <code>crmPack</code> directly.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb4-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb4-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb4-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span></span>
<span id="cb4-5">)</span>
<span id="cb4-6"></span>
<span id="cb4-7">emptydata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>))</span>
<span id="cb4-8"></span>
<span id="cb4-9">model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticLogNormal</span>(</span>
<span id="cb4-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb4-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span></span>
<span id="cb4-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb4-13">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb4-14">    ),</span>
<span id="cb4-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ref_dose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">56</span></span>
<span id="cb4-16">)</span>
<span id="cb4-17">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(emptydata, model, options)</span>
<span id="cb4-18">tidySamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>()</span>
<span id="cb4-19">tidySamples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>()</span>
<span id="cb4-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; $data</span></span>
<span id="cb4-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # A tibble: 2,000 × 10</span></span>
<span id="cb4-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    Iteration Chain alpha0 alpha1 nChains nParameters nIterations nBurnin nThin</span></span>
<span id="cb4-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        &lt;int&gt; &lt;int&gt;  &lt;dbl&gt;  &lt;dbl&gt;   &lt;int&gt;       &lt;int&gt;       &lt;int&gt;   &lt;int&gt; &lt;int&gt;</span></span>
<span id="cb4-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  1         1     1 -2.23   8.35        1           1        2100     100     1</span></span>
<span id="cb4-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  2         2     1 -0.654  3.73        1           1        2100     100     1</span></span>
<span id="cb4-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  3         3     1 -2.21   7.35        1           1        2100     100     1</span></span>
<span id="cb4-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  4         4     1 -1.39   1.70        1           1        2100     100     1</span></span>
<span id="cb4-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  5         5     1  0.261  9.20        1           1        2100     100     1</span></span>
<span id="cb4-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  6         6     1  0.234  0.735       1           1        2100     100     1</span></span>
<span id="cb4-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  7         7     1 -2.91   5.04        1           1        2100     100     1</span></span>
<span id="cb4-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  8         8     1 -0.395  0.370       1           1        2100     100     1</span></span>
<span id="cb4-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  9         9     1 -0.325  2.40        1           1        2100     100     1</span></span>
<span id="cb4-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 10        10     1 -0.843  1.85        1           1        2100     100     1</span></span>
<span id="cb4-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # ℹ 1,990 more rows</span></span>
<span id="cb4-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # ℹ 1 more variable: parallel &lt;lgl&gt;</span></span>
<span id="cb4-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb4-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; $options</span></span>
<span id="cb4-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # A tibble: 1 × 5</span></span>
<span id="cb4-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   iterations burnin  step rng_kind rng_seed</span></span>
<span id="cb4-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        &lt;int&gt;  &lt;int&gt; &lt;int&gt; &lt;chr&gt;       &lt;int&gt;</span></span>
<span id="cb4-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1       2100    100     1 &lt;NA&gt;           NA</span></span></code></pre></div></div>
</div>
</section>
<section id="using-tidy-crmpack-data" class="level2">
<h2 class="anchored" data-anchor-id="using-tidy-crmpack-data">Using tidy <code>crmPack</code> data</h2>
<p>Tidy <code>crmPack</code> data can be easily reported using <code>knitr</code> or similar packages in the obvious way.</p>
<section id="cohort-size" class="level3">
<h3 class="anchored" data-anchor-id="cohort-size">Cohort size</h3>
<p>The cohort size for this trial is determined by the dose to be used in the current cohort according to the rules described in the table below:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">CohortSizeRange</span>(</span>
<span id="cb5-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intervals =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>),</span>
<span id="cb5-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort_size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb5-4">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(</span>
<span id="cb5-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Min"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Cohort size"</span>),</span>
<span id="cb5-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rules for selecting the cohort size"</span></span>
<span id="cb5-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_header_above</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dose"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<caption>Rules for selecting the cohort size</caption>
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th colspan="2" data-quarto-table-cell-role="th" style="text-align: center; border-bottom: hidden; padding-bottom: 0; padding-left: 3px; padding-right: 3px;"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">
Dose
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: right; empty-cells: hide; border-bottom: hidden;"></th>
</tr>
<tr class="even">
<th style="text-align: right;" data-quarto-table-cell-role="th">Min</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Max</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Cohort size</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">50</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="even">
<td style="text-align: right;">50</td>
<td style="text-align: right;">300</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: right;">300</td>
<td style="text-align: right;">Inf</td>
<td style="text-align: right;">5</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Or presentations not directly supported by <code>crmPack</code> can be easily produced. Here, we create plots of the dose-specific PDFs for prior probabilities of toxicity after the first DLT is observed in a fictional trial.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">options <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">McmcOptions</span>(</span>
<span id="cb6-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">burnin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5000</span>,</span>
<span id="cb6-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb6-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">samples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40000</span></span>
<span id="cb6-5">)</span>
<span id="cb6-6"></span>
<span id="cb6-7">data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Data</span>(</span>
<span id="cb6-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">doseGrid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>),</span>
<span id="cb6-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>),</span>
<span id="cb6-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb6-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ID =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>L,</span>
<span id="cb6-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cohort =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>))</span>
<span id="cb6-13">)</span>
<span id="cb6-14"></span>
<span id="cb6-15">model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">LogisticLogNormal</span>(</span>
<span id="cb6-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb6-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cov =</span></span>
<span id="cb6-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb6-19">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb6-20">    ),</span>
<span id="cb6-21">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ref_dose =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">56</span></span>
<span id="cb6-22">)</span>
<span id="cb6-23">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc</span>(data, model, options)</span>
<span id="cb6-24">tidySamples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>()</span>
<span id="cb6-25"></span>
<span id="cb6-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># The magrittr pipe is necessary here</span></span>
<span id="cb6-27">tidySamples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>data <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-28">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand</span>(</span>
<span id="cb6-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nesting</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!!!</span>.[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>]),</span>
<span id="cb6-30">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Dose =</span> data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span>doseGrid[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>]</span>
<span id="cb6-31">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Prob =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">probFunction</span>(model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha0 =</span> alpha0, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha1 =</span> alpha1)(Dose)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_density</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> Prob, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>(Dose)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-35">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb6-36">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Posterior dose-specific PDFs for p(Tox)"</span>,</span>
<span id="cb6-37">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dose 1 omitted as p(Tox) is essentially 0"</span>,</span>
<span id="cb6-38">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p(Tox)"</span></span>
<span id="cb6-39">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-40">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_discrete</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dose"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-41">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_light</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-42">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb6-43">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.ticks.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb6-44">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb6-45">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>()</span>
<span id="cb6-46">  )</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.crmpack.org/vignettes/utilities/crmPack_tidy/index_files/figure-html/unnamed-chunk-7-1.png" class="img-fluid figure-img" style="width:100.0%"></p>
</figure>
</div>
</div>
</div>


</section>
</section>
</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div></div></section></div> ]]></description>
  <category>Utilities</category>
  <guid>https://www.crmpack.org/vignettes/utilities/crmPack_tidy/</guid>
  <pubDate>Mon, 02 Mar 2026 09:08:07 GMT</pubDate>
  <media:content url="https://www.crmpack.org/photos/by_friedrich_pahlke_14.jpg" medium="image" type="image/jpeg"/>
</item>
</channel>
</rss>
