<p>The goal of this vignette is to show most of all possibilies with <em>aVT</em> (for <em>aVirtualTwins</em> meaning <em>a</em>daptation of <em>Virtual Twins</em> method) package.</p>
<p><em>VT</em> method (Jared Foster and al, 2011) has been created to find subgroup of patients with enhanced treatment effect, if it exists. Theorically, this method can be used for binary and continous outcome. This package only deals with binary outcome in a two arms clinical trial.</p>
<p><em>VT</em> method is based on random forests and regression/classification trees.</p>
<p>I decided to use a simulated dataset called <em>sepsis</em> in order to show how <em>aVT</em> package can be used. Type <code>?sepsis</code> to know more about this dataset. Anyway, the true subgroup is <code>PRAPACHE <= 26 & AGE <= 49.80</code>.</p>
<p><strong>NOTE:</strong> This true subgroup is defined with the <em>lower</em> event rate (<code>survival = 1</code>) in treatement arm. Therefore in following examples we’ll search the subgroup with the <em>highest</em> event rate, and we know it is <code>PRAPACHE > 26 & AGE > 49.80</code>.</p>
<p>Data used in <em>VT</em> are modelized by <spanclass="math">\(\left\{Y, T, X_1, \ldots, X_{p-2}\right\}\)</span>. <spanclass="math">\(p\)</span> is the number of variables.</p>
<ul>
<li><spanclass="math">\(Y\)</span> is a binary outcome. In R, <spanclass="math">\(Y\)</span> is a <code>factor</code>. Second level of this factor will be the desirable event. (<spanclass="math">\(Y=1\)</span>)</li>
<li><spanclass="math">\(T\)</span> is treatment variable, <spanclass="math">\(T=1\)</span> means <em>active treatement</em>, <spanclass="math">\(T=0\)</span> means <em>control treatment</em>. In R, <spanclass="math">\(T\)</span> is numeric.</li>
<li><spanclass="math">\(X_i\)</span> is covariables, <spanclass="math">\(X_i\)</span> can be categorical, continous, binary.</li>
</ul>
<p><strong>NOTE:</strong> if you run <em>VT</em> with interactions, categorical covariables must be transformed into binary variables.</p>
<p>Type <code>?formatRCTDataset</code> for details.</p>
<li>Use regression tree to explain <spanclass="math">\(Z\)</span> by covariables <spanclass="math">\(X\)</span>. Then subjects with predicted <spanclass="math">\(Z_i\)</span> greater than some threshold <spanclass="math">\(c\)</span> are considered to define a subgroup.</li>
<li>Use classification tree on new variable <spanclass="math">\(Z^{*}\)</span> defined by <spanclass="math">\(Z^{*}_i=1\)</span> if <spanclass="math">\(Z_i > c\)</span> and <spanclass="math">\(Z^{*}_i=0\)</span> otherwise.</li>
</ul>
<p>The idea is to identify which covariable from <spanclass="math">\(X\)</span> described variation of <spanclass="math">\(Z\)</span>.</p>
<p><em>Sepsis</em> dataset is a simulated clinical trial with two groups treatment about sepsis desease. See details. This dataset is taken from <ahref="http://biopharmnet.com/wiki/Software_for_subgroup_identification_and_analysis">SIDES method</a></p>
<p><em>Sepsis</em> contains simulated data on 470 subjects with a binary outcome survival, that stores survival status for patient after 28 days of treatment, value of 1 for subjects who died after 28 days and 0 otherwise. There are 11 covariates, listed below, all of which are numerical variables.</p>
<p>Note that contrary to the original dataset used in SIDES, missing values have been imputed by random forest <code>randomForest::rfImpute()</code>. See file <em>data-raw/sepsis.R</em> for more details.</p>
<p>True subgroup is <code>PRAPACHE <= 26 & AGE <= 49.80</code>. <strong>NOTE:</strong> This subgroup is defined with the <em>lower</em> event rate (survival = 1) in treatement arm.</p>
<p>470 patients and 13 variables:</p>
<ul>
<li><code>survival</code> : binary outcome</li>
<li><code>THERAPY</code> : 1 for active treatment, 0 for control treatment</li>
<li><code>TIMFIRST</code> : Time from first sepsis-organ fail to start drug</li>
<li><code>AGE</code> : Patient age in years</li>
<li><code>BLLPLAT</code> : Baseline local platelets</li>
<li><code>blSOFA</code> : Sum of baselin sofa (cardiovascular, hematology, hepaticrenal, and respiration scores)</li>
<li><code>BLLCREAT</code> : Base creatinine</li>
<li><code>ORGANNUM</code> : Number of baseline organ failures</li>
<p>In order to begin the two steps of <em>VT</em> method, aVirtualTwins package needs to be initialized with <code>vt.data()</code> function. type <code>?vt.data</code> for more details.</p>
<p><strong>NOTE:</strong> if running VT with interactions between <spanclass="math">\(T\)</span> and <spanclass="math">\(X\)</span>, set <code>interactions = TRUE</code>.</p>
<pre><code>## "1" will be the favorable outcome</code></pre>
<p>1 will be the favorable outcome because 1 is the second level of <code>"survival"</code> column. It means that <spanclass="math">\(P(Y=1)\)</span> is the probability of interest. Anyway, it’s still possible to compute <spanclass="math">\(P(Y=0)\)</span>.</p>
<p><strong>Quick example</strong></p>
<p><em>Sepsis</em> does not have any categorical variable, following example show how <code>vt.data</code> deals with categorical values depending on <code>interactions</code> parameter</p>
<preclass="sourceCode r"><codeclass="sourceCode r"><spanclass="co"># Creation of categorical variable</span>
<p>Following example used <em>sepsis</em> data created in previous part.</p>
<p>To perform simple random forest on <code>VT.object</code>, <code>randomForest</code>, <code>caret</code> and <code>party</code> package can be used.</p>
<p><code>cforest()</code> can be usefull however computing time is really long. I think there is an issue when giving <em>cforest object</em> in Reference Class parameter. Need to fix it.</p>
<preclass="sourceCode r"><codeclass="sourceCode r"><spanclass="co"># # use randomForest::randomForest()</span>
<p><strong>NOTE:</strong> use <code>trt</code> parameter in <code>VT.object::getX()</code> or <code>VT.object::getY()</code> methods to obtain part of data depending on treatment. See following example.</p>
<p>This idea is taken from <em>method 3</em> of Jared Foster paper :</p>
<blockquote>
<p>A modification of [previous methods] is to obtain <spanclass="math">\(\hat{P_{1i}}\)</span> and <spanclass="math">\(\hat{P_{0i}}\)</span> via cross-validation. In this méthod the specific data for subject <spanclass="math">\(i\)</span> is not used to obtain <spanclass="math">\(\hat{P_{1i}}\)</span> and <spanclass="math">\(\hat{P_{0i}}\)</span>. Using k-fold cross-validation, we apply random forest regression approach to <spanclass="math">\(\frac{k-1}{k}\)</span> of the data and use the resulting predictor to obtain estimates of <spanclass="math">\(P_{1i}\)</span> and <spanclass="math">\(P_{0i}\)</span> for the remaining <spanclass="math">\(\frac{1}{k}\)</span> of the observations. This is repeated <spanclass="math">\(k\)</span> times.</p>
<li><code>fold</code> : number of fold (e.g. <spanclass="math">\(5\)</span>)</li>
<li><code>ratio</code> : Control of sampsize balance. <code>ratio</code> of <spanclass="math">\(2\)</span> means that there 2 times le highest level compared to the other. “Highest” means the level with larger observations. It’s in test.</li>
<li><code>interactions</code> : Logical. If <code>TRUE</code>, interactions between covariables and treatments are used. <code>FALSE</code> otherwise.</li>
<p>Random Forests are not the only models you can use to compute <spanclass="math">\(\hat{P_{1i}}\)</span> and <spanclass="math">\(\hat{P_{0i}}\)</span>. Any prediction model can be used, as logitic regression, boosting …</p>
<p>Anyway, aVirtualTwins package can be used. To do so, you can use <code>VT.difft()</code> class. It is important to note this the parent class of all “forests” classes. It takes in argument :</p>
<ul>
<li><code>vt.object</code> : return of <code>vt.data()</code> function</li>
<li><code>twin1</code> : estimate of <spanclass="math">\(P(Y_{i} = 1 | T = T_{i})\)</span> : meaning response probability under the correct treatment.</li>
<li><code>twin1</code> : estimate of <spanclass="math">\(P(Y_{i} = 1 | T = 1-T_{i})\)</span> : meaning response probability under the other treatment.</li>
<h1>Step 2 : Estimate a Regression or Classification Tree</h1>
<p>As described in the method, we define <spanclass="math">\(Z_i = \hat{P_{1i}} - \hat{P_{0i}}\)</span>. It’s the difference in term of response of the active treatments compared to the control treatment. The idea is to try to explain this difference by few covariables.</p>
<divid="classification"class="section level2">
<h2>Classification</h2>
<p>We define a new variable <spanclass="math">\(Z^{*}\)</span>, <spanclass="math">\(Z^{*}_i=1\)</span> if <spanclass="math">\(Z_i > c\)</span> and <spanclass="math">\(Z^{*}_i=0\)</span> otherwise. Classification tree’s goal is to explain the value <spanclass="math">\(Z^*=1\)</span>. <spanclass="math">\(c\)</span> is a threshold given by the user. It’s the threshold for which the difference is “interesting”. One idea is to use quantiles of the <em>difft</em> distribution.</p>
<p>To compute a classifiction tree, <code>vt.tree("class", ...)</code> is used. Internally, <code>rpart::rpart()</code> is computed. It takes in argument:</p>
<li><code>sens</code> : <code>c(">", "<")</code>. <code>sens</code> corresponds to the way <spanclass="math">\(Z^{*}\)</span> is defined.
<ul>
<li><code>">"</code> (default) : <spanclass="math">\(Z^{*}\)</span>, <spanclass="math">\(Z^{*}_i=1\)</span> if <spanclass="math">\(Z_i > c\)</span> and <spanclass="math">\(Z^{*}_i=0\)</span> otherwise.</li>
<li><code>"<"</code> : <spanclass="math">\(Z^{*}\)</span>, <spanclass="math">\(Z^{*}_i=1\)</span> if <spanclass="math">\(Z_i < c\)</span> and <spanclass="math">\(Z^{*}_i=0\)</span> otherwise.<br/></li>
<li><code>threshold</code> : corresponds to <spanclass="math">\(c\)</span>, it can be a vector. <spanclass="math">\(seq(.5, .8, .1)\)</span> by default.</li>
<li><code>screening</code> : <code>NULL</code> is default value. If <code>TRUE</code> only covariables in <code>varimp</code><code>vt.data</code>’s field is used.</li>
<p>Use regression tree to explain <spanclass="math">\(Z\)</span> by covariables <spanclass="math">\(X\)</span>. Then some leafs have predicted <spanclass="math">\(Z_i\)</span> greater than the threshold <spanclass="math">\(c\)</span> (if <spanclass="math">\(sens\)</span> is “>”), and it defines which covariables explain <spanclass="math">\(Z\)</span>.</p>