<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/an-introduction-to-joint-modeling-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://talesofr.wordpress.com/2018/02/23/an-introduction-to-joint-modeling-in-r/"> R – Tales of R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><em>By J Espasandin, O Lado, A Bouzas, A Baluja. </em></p>
<p>You can also check this post, written in <a rel="nofollow" href="https://twitter.com/hashtag/blogdown" target="_blank">#blogdown</a>, here: <a rel="nofollow" href="https://aurora-mareviv.github.io/talesofr/2018/02/intro-joint-modeling-r/" target="_blank">intro-joint-modeling-r</a>.</p>
<div><img src="https://i0.wp.com/aurora-mareviv.github.io/talesofr/images/jointmod.gif?w=456&ssl=1" data-recalc-dims="1"></div>
<p>These days, between the 19th and 21st of February, has taken place the learning activity titled “<strong>An Introduction to the Joint Modeling of Longitudinal and Survival Data, with Applications in R</strong>” organized by the Interdisciplinary Group of Biostatistics (<a rel="nofollow" href="http://icbusc.com/" target="_blank">ICBUSC</a>), directed by Professor Carmen Cadarso-Suárez, from the <a rel="nofollow" href="http://www.usc.es/en/index.html" target="_blank">University of Santiago de Compostela</a>.</p>
<p>The international nature of this scientific activity has been marked by the presence of researchers from different European countries such as Germany, Portugal, Holland, Greece or Turkey. It also emphasizes its interdisciplinary nature, with attendees from different fields of research, such as statistics, biology, medicine, ecology or bioinformatics, belonging to different universities, biomedical institutions or the industry.</p>
<p>The training activity has been taught by the professor <a rel="nofollow" href="http://www.drizopoulos.com/" target="_blank">Dimitris Rizopoulos</a> of the Erasmus University Medical Center in Rotterdam, specialist in <a rel="nofollow" href="http://www.drizopoulos.com/courses/EMC/ESP72.pdf" target="_blank">joint-modeling techniques</a>. Professor Rizopoulos is the author of a <a rel="nofollow" href="https://www.crcpress.com/Joint-Models-for-Longitudinal-and-Time-to-Event-Data-With-Applications/Rizopoulos/p/book/9781439872864" target="_blank">book on joint modeling</a>, as well as numerous publications and two related R packages: <a rel="nofollow" href="https://cran.r-project.org/web/packages/JM/index.html" target="_blank">JM</a> and <a rel="nofollow" href="https://cran.r-project.org/web/packages/JMbayes/index.html" target="_blank">JMbayes</a>.</p>
<p>The Joint Modeling techniques presented during the scientific meeting allow for the simultaneous study of longitudinal and time-to-event data. <strong>Longitudinal data</strong> includes repeated measurements of individuals over time, and <strong>time-to event data</strong> represent the expected time before an event occurs (like death, an asthma crisis or a transplant). That combination of data frequently arises in the biomedical sciences, where it is common to analyze the evolution of a sick person over time.</p>
<p>This novel statistical tool is especially useful in the field of biomedicine. For instance, in patient follow-up studies after surgery; to design a personalised pattern of medical visits; to carry out predictions of survival based on the evolution of a patient, or updating those predictions in light of new data; identification of useful biomarkers; prediction of patient outcome with different chronic diseases such as diabetes, some types of cancer or cardiovascular disease.</p>
<p>The applicability of these models has been illustrated through the JM and JMBayes R packages (by D Rizopoulos), as well as the packages <a rel="nofollow" href="https://cran.r-project.org/web/packages/joineR/index.html" target="_blank">joineR</a> (by Philipson et al.), and <a rel="nofollow" href="https://cran.r-project.org/web/packages/lcmm/index.html" target="_blank">lcmm</a> (by Proust-Lima et al.)</p>
<div>
<h1>An overview of joint modeling</h1>
<p>It basically combines (joins) the probability distributions from a linear mixed-effects model with random effects (which takes care of the longitudinal data) and a survival Cox model (which calculates the hazard ratio for an event from the censored data). The whole model and its parts can be extended in several ways:</p>
<ul>
<li>To find latent population heterogeneity (<em>latent class joint models</em>).</li>
<li>Allow for multiple longitudinal markers.</li>
<li>Allow for the analysis of multiple failure times. This is the case of competing risks and recurrent events (for instance, when a child develops asthma attacks, to find the risk of recurrence).</li>
<li>Time-Dependent accelerated failure time (<em>AFT</em>) Models.</li>
<li>Dynamic predictions when new values are added for the longitudinal variable, using Maximum Likelihood Estimates and empirical Bayes estimates.</li>
</ul>
<p>Also, the <a rel="nofollow" href="https://cran.r-project.org/web/packages/JM/index.html" target="_blank">JM</a> package has functions for <em>discrimination</em> and <em>callibration</em>, (of a single marker and between models): <em>sensitivity</em> &amp; <em>specificity</em>, <em>time-dependent ROCs</em> and <em>AUC</em>.</p>
<div>
<h3>Applications for joint modeling</h3>
<p>Citing D. Rizopoulos:</p>
<blockquote>
<p>Joint models for longitudinal and time-to-event data have become a valuable tool in the analysis of follow-up data. These models are applicable mainly in two settings: First, when the focus is on the survival outcome and we wish to account for the effect of an endogenous time-dependent covariate measured with error, and second, when the focus is on the longitudinal outcome and we wish to correct for nonrandom dropout.</p>
</blockquote>
</div>
<div>
<h2>Summary</h2>
<blockquote>
<p>When we need joint models for longitudinal and survival outcomes?</p>
</blockquote>
<div>
<ul>
<li>To handle endogenous time-varying covariates in a survival analysis context</li>
<li>To account for nonrandom dropout in a longitudinal data analysis context</li>
</ul>
</div>
<blockquote>
<p>How joint models work?</p>
</blockquote>
<div>
<ul>
<li>A mixed model for the longitudinal outcome</li>
<li>A relative risk model for the event process</li>
<li>Explain interrelationships with shared random effects</li>
</ul>
</div>
</div>
<div>
<h2>Last but not least… a dynamic predicion GIF!</h2>
<pre><code><span>library</span>(JM)
<span># Animation example </span>
<span># Mixed-effects model fit</span>
lmeFit.p1 &lt;- lme(log(pro) ~ time + time:treat, data = prothro,
    random = ~ time | id)  

<span># Cox survival model fit</span>
survFit.p1 &lt;- coxph(Surv(Time, death) ~ treat, data = prothros, x = <span>TRUE</span>)  

<span># Joint model</span>
jointFit.p1 &lt;- jointModel(lmeFit.p1, survFit.p1, timeVar = <span>&quot;time&quot;</span>,
    method = <span>&quot;piecewise-PH-aGH&quot;</span>)

<span># We are interested in producing predictions of survival probabilities for Patient 155</span>
dataP155 &lt;- prothro[prothro$id == <span>155</span>, ]
len_id &lt;- nrow(dataP155)

<span># We can plot the data</span>
sfit3 &lt;- survfitJM(jointFit.p1, newdata = dataP155[<span>1</span>:<span>3</span>, ]) 
sfit4 &lt;- survfitJM(jointFit.p1, newdata = dataP155[<span>1</span>:<span>4</span>, ]) 

par(mfrow=c(<span>1</span>,<span>2</span>))
plotfit3 &lt;- plot(sfit3, estimator=<span>&quot;mean&quot;</span>, include.y = <span>TRUE</span>, conf.int=<span>0.95</span>, fill.area=<span>TRUE</span>, col.area=<span>&quot;lightblue&quot;</span>, main=<span>&quot;Patient 155&quot;</span>)
plotfit4 &lt;- plot(sfit4, estimator=<span>&quot;mean&quot;</span>, include.y = <span>TRUE</span>, conf.int=<span>0.95</span>, fill.area=<span>TRUE</span>, col.area=<span>&quot;lightblue&quot;</span>, main=<span>&quot;Patient 155&quot;</span>)</code></pre>
<p><img src="https://i1.wp.com/aurora-mareviv.github.io/talesofr/post/2018-02-23-intro-joint-modeling-r_files/figure-html/unnamed-chunk-3-1.png?w=450&ssl=1" data-recalc-dims="1"></p>
<pre><code><span>library</span>(animation)
saveGIF({
  <span>for</span>(i <span>in</span> c(<span>1</span>:len_id)){
      sfit &lt;- survfitJM(jointFit.p1, newdata = dataP155[<span>1</span>:i, ]) 
      plot(sfit, estimator=<span>&quot;mean&quot;</span>, include.y = <span>TRUE</span>, conf.int=<span>0.95</span>, fill.area=<span>TRUE</span>, col.area=<span>&quot;lightblue&quot;</span>, main=<span>&quot;Patient 1&quot;</span>)
      
  }
},ani.width = <span>400</span>, ani.height=<span>400</span>)</code></pre>
<p><img src="https://i0.wp.com/aurora-mareviv.github.io/talesofr/images/jointmod.gif?w=456&ssl=1" data-recalc-dims="1"></p>
<blockquote>
<p>A great crowd over there!</p>
</blockquote>
<div><img src="https://i0.wp.com/aurora-mareviv.github.io/talesofr/images/jointmodelcrowd.jpg?w=456&ssl=1" data-recalc-dims="1"></div>
</div>
</div>
<p> </p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://talesofr.wordpress.com/2018/02/23/an-introduction-to-joint-modeling-in-r/"> R – Tales of R</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/aIuMvgufio4" height="1"></a></div>