<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Survival analysis on Stats and R</title>
    <link>https://statsandr.com/tags/survival-analysis/</link>
    <description>Recent content in Survival analysis on Stats and R</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Mon, 16 Jun 2025 00:00:00 +0000</lastBuildDate>
    
	<atom:link href="https://statsandr.com/tags/survival-analysis/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Paper: &#39;Semi-Markov modeling for disease incidence risk and duration&#39;</title>
      <link>https://statsandr.com/blog/paper-semi-markov-modeling-for-disease-incidence-risk-and-duration/</link>
      <pubDate>Mon, 16 Jun 2025 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/paper-semi-markov-modeling-for-disease-incidence-risk-and-duration/</guid>
      <description>


&lt;p&gt;&lt;img src=&#34;images/paper-semi-markov-modeling-for-disease-incidence-risk-and-duration.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;I’m happy to share that my latest research paper, &lt;em&gt;“Semi-Markov modeling for disease incidence risk and duration”&lt;/em&gt; has been accepted for publication in the journal Biostatistics &amp;amp; Epidemiology &lt;a href=&#34;https://doi.org/10.1080/24709360.2025.2517916&#34;&gt;(Soetewey et al., 2025)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Read the full paper &lt;a href=&#34;https://doi.org/10.1080/24709360.2025.2517916&#34;&gt;here&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;This work focuses on the use of a &lt;strong&gt;Semi-Markov illness-death model&lt;/strong&gt; to estimate both:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The risk of cancer incidence&lt;/strong&gt; over a future time period&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The number of years of life lost (YLL)&lt;/strong&gt; due to cancer, with a focus on loss before age 70&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The analysis relies on real-world data from the &lt;strong&gt;Belgian Cancer Registry&lt;/strong&gt;, covering over 160,000 cases of melanoma, thyroid, and female breast cancer diagnosed between 2004 and 2020. By modeling transitions between “healthy,” “ill,” and “dead” states, we provide a comprehensive framework to better understand disease burden over time, not just at diagnosis, but also for long-term survivors.&lt;/p&gt;
&lt;p&gt;One key feature of this work is its application to &lt;strong&gt;non-homogeneous Semi-Markov processes&lt;/strong&gt;, allowing us to account for the time since diagnosis when estimating survival and life expectancy. This adds a clinically meaningful dynamic dimension to traditional multi-state models.&lt;/p&gt;
&lt;p&gt;Beyond its methodological contributions, this study has important implications for &lt;strong&gt;public health&lt;/strong&gt; and &lt;strong&gt;insurance regulation&lt;/strong&gt;. In particular, the results offer quantitative support for the &lt;strong&gt;right to be forgotten&lt;/strong&gt;; a legal provision that allows cancer survivors to apply for credit or insurance products without being penalized once they’ve reached a certain number of years since the end of treatment.&lt;/p&gt;
&lt;p&gt;Our results suggest that, for many patients who survive 10 years post-diagnosis, the expected loss in life years compared to the general population becomes minimal, sometimes even below one year. This is especially true for cancers like melanoma and thyroid cancer. These findings could contribute to more equitable and evidence-based insurance underwriting practices.&lt;/p&gt;
&lt;p&gt;This research was a collaborative effort, and I would like to express my sincere thanks to my former PhD supervisors, Catherine Legrand, Michel Denuit (UCLouvain) and Geert Silversmit (Belgian Cancer Registry), for their invaluable guidance and support throughout the project.&lt;/p&gt;
&lt;p&gt;Thanks for reading!&lt;/p&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;p&gt;Soetewey, A., Legrand, C., Denuit, M., &amp;amp; Silversmit, G. (2025). Semi-Markov modeling for disease incidence risk and duration. &lt;em&gt;Biostatistics &amp;amp; Epidemiology, 9&lt;/em&gt;(1). &lt;a href=&#34;https://doi.org/10.1080/24709360.2025.2517916&#34; class=&#34;uri&#34;&gt;https://doi.org/10.1080/24709360.2025.2517916&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Paper: &#39;Right to be forgotten for mortgage insurance issued to cancer survivors: critical assessment and new proposal&#39;</title>
      <link>https://statsandr.com/blog/paper-right-to-be-forgotten-for-mortgage-insurance-issued-to-cancer-survivors-critical-assessment-and-new-proposal/</link>
      <pubDate>Tue, 05 Nov 2024 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/paper-right-to-be-forgotten-for-mortgage-insurance-issued-to-cancer-survivors-critical-assessment-and-new-proposal/</guid>
      <description>


&lt;p&gt;&lt;img src=&#34;images/paper-right-to-be-forgotten-for-mortgage-insurance-issued-to-cancer-survivors-critical-assessment-and-new-proposal.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;I am happy to announce that our paper entitled “Right to be forgotten for mortgage insurance issued to cancer survivors: critical assessment and new proposal” has been accepted for publication in &lt;em&gt;European Actuarial Journal&lt;/em&gt; &lt;a href=&#34;https://doi.org/10.1007/s13385-024-00403-6&#34;&gt;(Soetewey et al., 2025)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this paper, we propose an alternative method to determine the waiting period opening the right to be forgotten in insurance. This new method is based on a constraint imposed to the premium, which is then transposed into a target on the conditional observed survival. Furthermore, the paper also investigates the impact of the stage of the tumor at diagnosis on waiting periods.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Read more &lt;a href=&#34;http://dx.doi.org/10.1007/s13385-024-00403-6&#34;&gt;here&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Thanks to all co-authors for the great work. We are also thankful to the two anonymous reviewers for their input that has greatly helped shape the paper.&lt;/p&gt;
&lt;p&gt;As always, if you have any question related to the topic covered in this paper, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;p&gt;Soetewey, A., Legrand, C., Denuit, M. et al. Right to be forgotten for mortgage insurance issued to cancer survivors: critical assessment and new proposal. &lt;em&gt;European Actuarial Journal&lt;/em&gt; &lt;strong&gt;15&lt;/strong&gt;, 15–43 (2025). &lt;a href=&#34;https://doi.org/10.1007/s13385-024-00403-6&#34; class=&#34;uri&#34;&gt;https://doi.org/10.1007/s13385-024-00403-6&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>What is survival analysis? Examples by hand and in R</title>
      <link>https://statsandr.com/blog/what-is-survival-analysis/</link>
      <pubDate>Thu, 22 Dec 2022 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/what-is-survival-analysis/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#what-is-survival-analysis&#34; id=&#34;toc-what-is-survival-analysis&#34;&gt;What is survival analysis?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#why-do-we-need-special-methods-for-survival-analysis&#34; id=&#34;toc-why-do-we-need-special-methods-for-survival-analysis&#34;&gt;Why do we need special methods for survival analysis?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#common-functions-in-survival-analysis&#34; id=&#34;toc-common-functions-in-survival-analysis&#34;&gt;Common functions in survival analysis&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#survival-function&#34; id=&#34;toc-survival-function&#34;&gt;Survival function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#cumulative-hazard-function&#34; id=&#34;toc-cumulative-hazard-function&#34;&gt;Cumulative hazard function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hazard-function&#34; id=&#34;toc-hazard-function&#34;&gt;Hazard function&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#estimation&#34; id=&#34;toc-estimation&#34;&gt;Estimation&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand&#34; id=&#34;toc-by-hand&#34;&gt;By hand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#in-r&#34; id=&#34;toc-in-r&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#hypothesis-testing&#34; id=&#34;toc-hypothesis-testing&#34;&gt;Hypothesis testing&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#log-rank-test&#34; id=&#34;toc-log-rank-test&#34;&gt;Log-rank test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#by-hand-1&#34; id=&#34;toc-by-hand-1&#34;&gt;By hand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#in-r-1&#34; id=&#34;toc-in-r-1&#34;&gt;In R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#to-go-further&#34; id=&#34;toc-to-go-further&#34;&gt;To go further&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/what-is-survival-analysis.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that this article is inspired from:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;the lecture notes of Prof. Van Keilegom and my personal notes as teaching assistant for her course entitled “Analysis of Survival and Duration Data” given at UCLouvain&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;the lecture notes of Prof. Legrand for her course entitled “Statistics in clinical trials” given at UCLouvain&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;For the last post of the year, I would like to present a rather unknown (yet important) statistical method–&lt;strong&gt;survival analysis&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Although survival analysis is a branch of statistics, it is usually not covered in introductory statistics courses and it is rather unknown to the general public. It is mostly taught in biostatistics courses or advanced statistics study programs.&lt;/p&gt;
&lt;p&gt;In this article, I will explain what is survival analysis, in which context and how it is used. I will explain the main tools and methods used by biostatisticians to analyze survival data and how to estimate and interpret survival curves.&lt;/p&gt;
&lt;p&gt;I will show in detail how to apply these techniques in R with concrete examples. In practice, survival analysis is almost always done via a statistical program and never done by hand. However, as for any statistical concept, I believe that doing it by hand allows to really understand the concepts and what these programs actually do. For this reason, I will also show a brief example on how to perform a basic survival analysis by hand.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;what-is-survival-analysis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What is survival analysis?&lt;/h1&gt;
&lt;p&gt;&lt;strong&gt;Survival analysis&lt;/strong&gt; (also called time-to-event analysis or duration analysis) is a branch of statistics aimed at &lt;strong&gt;analyzing the duration of time from a well-defined time origin until one or more events happen&lt;/strong&gt;, called survival times or duration times.&lt;/p&gt;
&lt;p&gt;In other words, in survival analysis, we are interested in a certain event and want to &lt;strong&gt;analyze the time until the event happens&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;While the event of interest is often death (in this case we study the time to death for patients having a specific disease) or recurrence (in this case we study the time to relapse of a certain disease), it is not limited to the medical field or epidemiology.&lt;/p&gt;
&lt;p&gt;In fact, it can be used in many domains. For example, we may also analyze the time until:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;getting cured from a certain disease&lt;/li&gt;
&lt;li&gt;finding a new job after a period of unemployment&lt;/li&gt;
&lt;li&gt;being arrested again after having been released from jail&lt;/li&gt;
&lt;li&gt;the first pregnancy&lt;/li&gt;
&lt;li&gt;the failure of a mechanical system or a machine&lt;/li&gt;
&lt;li&gt;a bank or a company goes bankrupt&lt;/li&gt;
&lt;li&gt;a customer buys a new product or stops its current subscription&lt;/li&gt;
&lt;li&gt;a letter is delivered&lt;/li&gt;
&lt;li&gt;a taxi picks you up after having called the taxi company&lt;/li&gt;
&lt;li&gt;an employee leaves the company&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As you can see, the event of interest does not necessarily have to be the death or the occurrence of a disease, but in all situations &lt;strong&gt;we are interested in analyzing the time until a specific event occurs&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;why-do-we-need-special-methods-for-survival-analysis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Why do we need special methods for survival analysis?&lt;/h1&gt;
&lt;p&gt;Survival data, also referred as time-to-event data, requires a special set of statistical methods for three main reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Duration times&lt;/strong&gt; are &lt;strong&gt;always positive&lt;/strong&gt;: the time until an event of interest occurs cannot be less than 0. Moreover, the distribution of survival times is right-skewed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Different measures&lt;/strong&gt; are of interest depending on the research question, context, etc. For instance, we could be interested in:
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;probability&lt;/strong&gt; that a cancer patient survives longer than 5 years after diagnosis?&lt;/li&gt;
&lt;li&gt;The typical &lt;strong&gt;waiting time&lt;/strong&gt; for a cab to arrive after having called the taxi company?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How many&lt;/strong&gt;, out of 100 unemployed people, are expected to have a job again after 2 months of unemployment?&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Censoring&lt;/strong&gt; is almost always an issue:
&lt;ul&gt;
&lt;li&gt;When the event occurred before the end of the study, the survival time is known.&lt;/li&gt;
&lt;li&gt;However, sometimes, the event is not yet observed at the end of the study. Suppose that we study the time until death of patients with breast cancer. Luckily, some patients will not die before the end of the study.
&lt;!-- + Other times, another event occurs before the event of interest which prevents it from ever happening. For example, a cancer patient may die from a car accident. --&gt;&lt;/li&gt;
&lt;li&gt;It can also happen that the patient withdraws from the study or moves to another country before the end of the study (known as lost to follow up or drop out).&lt;/li&gt;
&lt;li&gt;In all situations, his or her survival time cannot be observed because the event is not observed for the duration of the study.&lt;/li&gt;
&lt;li&gt;Censoring can be seen, in some sense, as a type of missing data.&lt;/li&gt;
&lt;li&gt;For these reasons, many “standard” statistical tools such as &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt;, &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis tests&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;regression models&lt;/a&gt; are not appropriate for this kind of data. Specific statistical methods are required to take into account the fact that the &lt;em&gt;exact&lt;/em&gt; survival duration for some patients is missing. It is known that they survived a certain amount of time (until the end of the study or until the time of withdrawal), but their exact survival time is unknown.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For your information, there are three types of censoring:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;right-censoring (the most frequent),&lt;/li&gt;
&lt;li&gt;left-censoring (the least frequent) and&lt;/li&gt;
&lt;li&gt;interval-censoring.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When the event is not yet observed at the end of the study (i.e., the survival time is greater than the observed duration), this is referred as right-censoring. Left-censoring occurs if a participant is entered into the study when the event of interest occurred prior to study entry but we do not know exactly when. Interval-censoring implies that the event occurred within a time interval (between two known dates, two visits, etc.); the exact moment of occurrence is not known. The goal is of course to analyze all available data, including information about censored patients.&lt;/p&gt;
&lt;p&gt;The goal of survival analysis is thus to model and describe time-to-event data in an appropriate way, taking the particularities of this type of data into account.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;common-functions-in-survival-analysis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Common functions in survival analysis&lt;/h1&gt;
&lt;p&gt;We are not going to go to much into the details, but it is important to lay the foundation with the most common functions in survival analysis.&lt;/p&gt;
&lt;p&gt;Let &lt;span class=&#34;math inline&#34;&gt;\(T\)&lt;/span&gt; be a non-negative continuous random variable, representing the time until the event of interest. We consider the following functions:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Survival function&lt;/li&gt;
&lt;li&gt;Cumulative hazard function&lt;/li&gt;
&lt;li&gt;Hazard function&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;survival-function&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Survival function&lt;/h2&gt;
&lt;p&gt;The most common one is the survival function.&lt;/p&gt;
&lt;p&gt;Let &lt;span class=&#34;math inline&#34;&gt;\(T\)&lt;/span&gt; be a non-negative continuous random variable, representing the time until the event of interest. The survival function &lt;span class=&#34;math inline&#34;&gt;\(S(t)\)&lt;/span&gt; is the probability that a randomly chosen individual is still at risk at time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;, where &lt;span class=&#34;math inline&#34;&gt;\(0 \le t \le +\infty\)&lt;/span&gt;. For each &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;, it is given by&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{align*}
    S(t) &amp;amp;= P(T &amp;gt; t)\\
    &amp;amp;= 1 - P(T \le t)\\
    &amp;amp;= 1 - F(t)\\
    &amp;amp;= 1 - \int^t_0 f(u)\text{d}u,
\end{align*}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;span class=&#34;math inline&#34;&gt;\(f(\cdot)\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(F(\cdot)\)&lt;/span&gt; are the density and the cumulative distribution functions of &lt;span class=&#34;math inline&#34;&gt;\(T\)&lt;/span&gt;, respectively.&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(S(t)\)&lt;/span&gt; represents, for each time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;, the probability that the time until the event is greater than this time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;. In other words, it models the probability that the event of interest happens &lt;strong&gt;after&lt;/strong&gt; &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In the context of our examples mentioned above, it gives the probability that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a randomly selected patient will survive beyond time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; or the proportion of patients still alive after time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;a cab takes more than &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; minutes to arrive, or&lt;/li&gt;
&lt;li&gt;an unemployed person take more than &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; months to find a new job.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The survival function &lt;span class=&#34;math inline&#34;&gt;\(S(t)\)&lt;/span&gt; is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a decreasing function,&lt;/li&gt;
&lt;li&gt;taking values in &lt;span class=&#34;math inline&#34;&gt;\([0, 1]\)&lt;/span&gt; (since it is a probability), and&lt;/li&gt;
&lt;li&gt;equal to 1 at &lt;span class=&#34;math inline&#34;&gt;\(t = 0\)&lt;/span&gt; (i.e., &lt;span class=&#34;math inline&#34;&gt;\(S(0) = 1\)&lt;/span&gt;) and 0 at &lt;span class=&#34;math inline&#34;&gt;\(t = \infty\)&lt;/span&gt; (i.e., &lt;span class=&#34;math inline&#34;&gt;\(S(\infty) = 0\)&lt;/span&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Visually we have:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-1-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The curve shows the proportion of individuals (or experimental units) who, as time goes on, have not experienced the event of interest. As time progresses, events occur, so the proportion who have not experienced the event decreases.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;cumulative-hazard-function&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Cumulative hazard function&lt;/h2&gt;
&lt;p&gt;The cumulative hazard function, which is the total hazard experienced up to time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;, is defined as:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[H(t) = -log\left(S(t)\right)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and has the following properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;increasing function,&lt;/li&gt;
&lt;li&gt;taking value in &lt;span class=&#34;math inline&#34;&gt;\([0, +\infty]\)&lt;/span&gt;, and&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(S(t) = exp(-H(t))\)&lt;/span&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;hazard-function&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Hazard function&lt;/h2&gt;
&lt;p&gt;The hazard function &lt;span class=&#34;math inline&#34;&gt;\(h(t)\)&lt;/span&gt;, or hazard rate, defines the instantaneous event rate at time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; for an individual still at risk at that time. It can be obtained by&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{align*}
h(t) &amp;amp;= \lim_{\Delta t \rightarrow 0} \frac{P(t \le T &amp;lt; t + \Delta t | T \ge t)}{\Delta t}\\
&amp;amp;= \frac{d}{dt} H(t)\\
&amp;amp;= \frac{f(t)}{S(t)}.
\end{align*}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and has the following properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;positive function (not necessarily increasing or decreasing)&lt;/li&gt;
&lt;li&gt;the hazard function &lt;span class=&#34;math inline&#34;&gt;\(h(t)\)&lt;/span&gt; can have many different shapes and is therefore a useful tool to summarize survival data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the context of cancer research when death is the event of interest, &lt;span class=&#34;math inline&#34;&gt;\(h(t)\)&lt;/span&gt; measures the instantaneous risk of dying right after time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; given the individual is alive at time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;To link the hazard rate with the survival function; the survival curve represents the hazard rates. A steeper slope indicates a higher hazard rate because events happen more frequently, reducing the proportion of individuals who have not experienced the event at a faster rate. On the contrary, a gradual and flatter slope indicates a lower hazard rate because events occur less frequently, reducing the proportion of individuals who have not experiences the event at a slower rate. More formally:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[S(t) = \exp\left(-\int^t_0 h(u) \text{d}u\right).\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Note that, in contrast to the survival function which focuses on not having an event, the hazard function focuses on the event occurring.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;estimation&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Estimation&lt;/h1&gt;
&lt;p&gt;To estimate the survival function, we need to use an estimator which is able to deal with censoring. The most common one is the nonparametric &lt;strong&gt;&lt;span class=&#34;citation&#34;&gt;Kaplan and Meier (&lt;a href=&#34;#ref-kaplan1958nonparametric&#34;&gt;1958&lt;/a&gt;)&lt;/span&gt; estimator&lt;/strong&gt; (also sometimes referred as the product-limit estimator, or more simply, the K-M estimator).&lt;/p&gt;
&lt;p&gt;The advantages of the Kaplan-Meier estimator are that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it is simple and straightforward to use and interpret&lt;/li&gt;
&lt;li&gt;it is a nonparametric estimator, so it constructs a survival curve from the data and no assumptions is made about the shape of the underlying distribution&lt;/li&gt;
&lt;li&gt;it gives a graphical representation of the survival function(s), useful for illustrative purposes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The principle behind this estimator is that surviving beyond time &lt;span class=&#34;math inline&#34;&gt;\(t_i\)&lt;/span&gt; implies surviving beyond time &lt;span class=&#34;math inline&#34;&gt;\(t_{i-1}\)&lt;/span&gt; and surviving at time &lt;span class=&#34;math inline&#34;&gt;\(t_i\)&lt;/span&gt;. Note that an important assumption for the estimation to hold is that censoring is independent of the occurrence of events. We say that censoring is non-informative, that is, censored subjects have the same survival prospects as subjects who are not censored and who continue to be followed.&lt;/p&gt;
&lt;div id=&#34;by-hand&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;By hand&lt;/h2&gt;
&lt;p&gt;To understand how it works, let’s first estimate it by hand on the following dataset:&lt;a href=&#34;#fn1&#34; class=&#34;footnote-ref&#34; id=&#34;fnref1&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div id=&#34;ezedjhlbwf&#34; style=&#34;padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;&#34;&gt;
&lt;style&gt;#ezedjhlbwf table {
  font-family: system-ui, &#39;Segoe UI&#39;, Roboto, Helvetica, Arial, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;, &#39;Noto Color Emoji&#39;;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#ezedjhlbwf thead, #ezedjhlbwf tbody, #ezedjhlbwf tfoot, #ezedjhlbwf tr, #ezedjhlbwf td, #ezedjhlbwf th {
  border-style: none;
}

#ezedjhlbwf p {
  margin: 0;
  padding: 0;
}

#ezedjhlbwf .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#ezedjhlbwf .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#ezedjhlbwf .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#ezedjhlbwf .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#ezedjhlbwf .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#ezedjhlbwf .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#ezedjhlbwf .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#ezedjhlbwf .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#ezedjhlbwf .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#ezedjhlbwf .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#ezedjhlbwf .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#ezedjhlbwf .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#ezedjhlbwf .gt_spanner_row {
  border-bottom-style: hidden;
}

#ezedjhlbwf .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#ezedjhlbwf .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#ezedjhlbwf .gt_from_md &gt; :first-child {
  margin-top: 0;
}

#ezedjhlbwf .gt_from_md &gt; :last-child {
  margin-bottom: 0;
}

#ezedjhlbwf .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#ezedjhlbwf .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#ezedjhlbwf .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#ezedjhlbwf .gt_row_group_first td {
  border-top-width: 2px;
}

#ezedjhlbwf .gt_row_group_first th {
  border-top-width: 2px;
}

#ezedjhlbwf .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#ezedjhlbwf .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#ezedjhlbwf .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#ezedjhlbwf .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#ezedjhlbwf .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#ezedjhlbwf .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#ezedjhlbwf .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#ezedjhlbwf .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#ezedjhlbwf .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#ezedjhlbwf .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#ezedjhlbwf .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#ezedjhlbwf .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#ezedjhlbwf .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#ezedjhlbwf .gt_left {
  text-align: left;
}

#ezedjhlbwf .gt_center {
  text-align: center;
}

#ezedjhlbwf .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#ezedjhlbwf .gt_font_normal {
  font-weight: normal;
}

#ezedjhlbwf .gt_font_bold {
  font-weight: bold;
}

#ezedjhlbwf .gt_font_italic {
  font-style: italic;
}

#ezedjhlbwf .gt_super {
  font-size: 65%;
}

#ezedjhlbwf .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#ezedjhlbwf .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#ezedjhlbwf .gt_indent_1 {
  text-indent: 5px;
}

#ezedjhlbwf .gt_indent_2 {
  text-indent: 10px;
}

#ezedjhlbwf .gt_indent_3 {
  text-indent: 15px;
}

#ezedjhlbwf .gt_indent_4 {
  text-indent: 20px;
}

#ezedjhlbwf .gt_indent_5 {
  text-indent: 25px;
}

#ezedjhlbwf .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#ezedjhlbwf div.Reactable &gt; div.rt-table &gt; div.rt-thead &gt; div.rt-tr.rt-tr-group-header &gt; div.rt-th-group:after {
  height: 0px !important;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34; data-quarto-disable-processing=&#34;false&#34; data-quarto-bootstrap=&#34;false&#34;&gt;
  &lt;thead&gt;
    &lt;tr class=&#34;gt_col_headings&#34;&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;subject&#34;&gt;subject&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;time&#34;&gt;time&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_right&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;event&#34;&gt;event&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody class=&#34;gt_table_body&#34;&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;0&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;3&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;7&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;4&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;18&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;0&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;6&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;16&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;7&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;2&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;8&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;9&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;9&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;16&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;1&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;subject&#34; class=&#34;gt_row gt_right&#34;&gt;10&lt;/td&gt;
&lt;td headers=&#34;time&#34; class=&#34;gt_row gt_right&#34;&gt;5&lt;/td&gt;
&lt;td headers=&#34;event&#34; class=&#34;gt_row gt_right&#34;&gt;0&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;subject&lt;/code&gt; is the individual’s identifier&lt;/li&gt;
&lt;li&gt;&lt;code&gt;time&lt;/code&gt; is the time to event (in years)&lt;a href=&#34;#fn2&#34; class=&#34;footnote-ref&#34; id=&#34;fnref2&#34;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;event&lt;/code&gt; is the event status (0 = censored, 1 = event happened)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Remember that for each subject, we need to know at least 2 pieces of information:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the time until the event of interest or the time until the censoring, and&lt;/li&gt;
&lt;li&gt;whether we have observed the event of interest or if we have observed censoring.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We first need to count the number of distinct event times. Ignoring censored observations, we have 5 distinct event times:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;2&lt;/em&gt;, &lt;em&gt;5&lt;/em&gt;, &lt;em&gt;7&lt;/em&gt;, &lt;em&gt;9&lt;/em&gt; and &lt;em&gt;16&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The easiest way to do the calculation by hand is by filling the following table (a table with 5 rows since there are 5 distinct event times):&lt;/p&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_gqi6wniv912vuheaxhyt = TinyTable.createTableFunctions(&#34;tinytable_gqi6wniv912vuheaxhyt&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 }, { i: &#39;5&#39;, j: 4 }, { i: &#39;5&#39;, j: 5 } ], css_id: &#39;tinytable_css_63tzhumrxmy06nvag0kk&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 }, { i: &#39;1&#39;, j: 4 }, { i: &#39;2&#39;, j: 4 }, { i: &#39;3&#39;, j: 4 }, { i: &#39;4&#39;, j: 4 }, { i: &#39;1&#39;, j: 5 }, { i: &#39;2&#39;, j: 5 }, { i: &#39;3&#39;, j: 5 }, { i: &#39;4&#39;, j: 5 } ], css_id: &#39;tinytable_css_odk2y8mjqugbkfu3h9e3&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 }, { i: &#39;0&#39;, j: 4 }, { i: &#39;0&#39;, j: 5 } ], css_id: &#39;tinytable_css_x7q8xsf3ainkuuago1c3&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_gqi6wniv912vuheaxhyt.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_gqi6wniv912vuheaxhyt td.tinytable_css_63tzhumrxmy06nvag0kk, #tinytable_gqi6wniv912vuheaxhyt th.tinytable_css_63tzhumrxmy06nvag0kk {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_gqi6wniv912vuheaxhyt td.tinytable_css_odk2y8mjqugbkfu3h9e3, #tinytable_gqi6wniv912vuheaxhyt th.tinytable_css_odk2y8mjqugbkfu3h9e3 { text-align: left }
    #tinytable_gqi6wniv912vuheaxhyt td.tinytable_css_x7q8xsf3ainkuuago1c3, #tinytable_gqi6wniv912vuheaxhyt th.tinytable_css_x7q8xsf3ainkuuago1c3 {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_gqi6wniv912vuheaxhyt&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$y_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$d_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;4&#34;&gt;$R_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;5&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;p&gt;We fill columns one by one:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(y_{(j)}\)&lt;/span&gt; = the ordered distinct event times:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;2&lt;/em&gt;, &lt;em&gt;5&lt;/em&gt;, &lt;em&gt;7&lt;/em&gt;, &lt;em&gt;9&lt;/em&gt; and &lt;em&gt;16&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So the table becomes:&lt;/p&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_pfttpztdnahkfolt80rf = TinyTable.createTableFunctions(&#34;tinytable_pfttpztdnahkfolt80rf&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 }, { i: &#39;5&#39;, j: 4 }, { i: &#39;5&#39;, j: 5 } ], css_id: &#39;tinytable_css_6a61u2qsubu2inwtd56y&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 }, { i: &#39;1&#39;, j: 4 }, { i: &#39;2&#39;, j: 4 }, { i: &#39;3&#39;, j: 4 }, { i: &#39;4&#39;, j: 4 }, { i: &#39;1&#39;, j: 5 }, { i: &#39;2&#39;, j: 5 }, { i: &#39;3&#39;, j: 5 }, { i: &#39;4&#39;, j: 5 } ], css_id: &#39;tinytable_css_8lne9bdpjx6dn6p4x3gd&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 }, { i: &#39;0&#39;, j: 4 }, { i: &#39;0&#39;, j: 5 } ], css_id: &#39;tinytable_css_bniz86tc4lp4m19bq9xc&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_pfttpztdnahkfolt80rf.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_pfttpztdnahkfolt80rf td.tinytable_css_6a61u2qsubu2inwtd56y, #tinytable_pfttpztdnahkfolt80rf th.tinytable_css_6a61u2qsubu2inwtd56y {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_pfttpztdnahkfolt80rf td.tinytable_css_8lne9bdpjx6dn6p4x3gd, #tinytable_pfttpztdnahkfolt80rf th.tinytable_css_8lne9bdpjx6dn6p4x3gd { text-align: left }
    #tinytable_pfttpztdnahkfolt80rf td.tinytable_css_bniz86tc4lp4m19bq9xc, #tinytable_pfttpztdnahkfolt80rf th.tinytable_css_bniz86tc4lp4m19bq9xc {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_pfttpztdnahkfolt80rf&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$y_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$d_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;4&#34;&gt;$R_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;5&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;7&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;9&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;16&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(d_{(j)}\)&lt;/span&gt; = the number of observations for each distinct event time. For this, the frequency for each distinct event time is useful:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;## time
##  2  5  7  9 16 
##  2  1  1  1  2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The table becomes:&lt;/p&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_jyqpf16iauwvmx2i0oim = TinyTable.createTableFunctions(&#34;tinytable_jyqpf16iauwvmx2i0oim&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 }, { i: &#39;5&#39;, j: 4 }, { i: &#39;5&#39;, j: 5 } ], css_id: &#39;tinytable_css_p57hqjnq2thdknhk1o3h&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 }, { i: &#39;1&#39;, j: 4 }, { i: &#39;2&#39;, j: 4 }, { i: &#39;3&#39;, j: 4 }, { i: &#39;4&#39;, j: 4 }, { i: &#39;1&#39;, j: 5 }, { i: &#39;2&#39;, j: 5 }, { i: &#39;3&#39;, j: 5 }, { i: &#39;4&#39;, j: 5 } ], css_id: &#39;tinytable_css_uci8h8g7nt7wfi557l1d&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 }, { i: &#39;0&#39;, j: 4 }, { i: &#39;0&#39;, j: 5 } ], css_id: &#39;tinytable_css_689d9x9gs8twi4f8vbpv&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_jyqpf16iauwvmx2i0oim.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_jyqpf16iauwvmx2i0oim td.tinytable_css_p57hqjnq2thdknhk1o3h, #tinytable_jyqpf16iauwvmx2i0oim th.tinytable_css_p57hqjnq2thdknhk1o3h {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_jyqpf16iauwvmx2i0oim td.tinytable_css_uci8h8g7nt7wfi557l1d, #tinytable_jyqpf16iauwvmx2i0oim th.tinytable_css_uci8h8g7nt7wfi557l1d { text-align: left }
    #tinytable_jyqpf16iauwvmx2i0oim td.tinytable_css_689d9x9gs8twi4f8vbpv, #tinytable_jyqpf16iauwvmx2i0oim th.tinytable_css_689d9x9gs8twi4f8vbpv {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_jyqpf16iauwvmx2i0oim&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$y_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$d_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;4&#34;&gt;$R_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;5&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;7&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;9&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;16&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;4&#34;&gt;&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(R_{(j)}\)&lt;/span&gt; = the remaining number of individuals at risk. For this, the distribution of time (censored and not censored) is useful:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;## time
##  2  3  5  7  9 16 18 
##  2  1  2  1  1  2  1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;At the beginning there are 10 subjects&lt;/li&gt;
&lt;li&gt;Just before time &lt;span class=&#34;math inline&#34;&gt;\(t = 5\)&lt;/span&gt;, there are 7 subjects left (10 subjects - 2 who had the event - 1 who is censored)&lt;/li&gt;
&lt;li&gt;Just before time &lt;span class=&#34;math inline&#34;&gt;\(t = 7\)&lt;/span&gt;, there are 5 subjects left (= 10 - 2 - 1 - 2)&lt;/li&gt;
&lt;li&gt;Just before time &lt;span class=&#34;math inline&#34;&gt;\(t = 9\)&lt;/span&gt;, there are 4 subjects left (= 10 - 2 - 1 - 2 - 1)&lt;/li&gt;
&lt;li&gt;Just before time &lt;span class=&#34;math inline&#34;&gt;\(t = 16\)&lt;/span&gt;, there are 3 subjects left (= 10 - 2 - 1 - 2 - 1 - 1)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The table becomes:&lt;/p&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_13fjo3fhqofxmr77b0ro = TinyTable.createTableFunctions(&#34;tinytable_13fjo3fhqofxmr77b0ro&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 }, { i: &#39;5&#39;, j: 4 }, { i: &#39;5&#39;, j: 5 } ], css_id: &#39;tinytable_css_05oab03bspdqdzznbf9c&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 }, { i: &#39;1&#39;, j: 4 }, { i: &#39;2&#39;, j: 4 }, { i: &#39;3&#39;, j: 4 }, { i: &#39;4&#39;, j: 4 }, { i: &#39;1&#39;, j: 5 }, { i: &#39;2&#39;, j: 5 }, { i: &#39;3&#39;, j: 5 }, { i: &#39;4&#39;, j: 5 } ], css_id: &#39;tinytable_css_h96li1wtavwkgoy72cy6&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 }, { i: &#39;0&#39;, j: 4 }, { i: &#39;0&#39;, j: 5 } ], css_id: &#39;tinytable_css_cb86r59qgslap7na03m7&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_13fjo3fhqofxmr77b0ro.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_13fjo3fhqofxmr77b0ro td.tinytable_css_05oab03bspdqdzznbf9c, #tinytable_13fjo3fhqofxmr77b0ro th.tinytable_css_05oab03bspdqdzznbf9c {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_13fjo3fhqofxmr77b0ro td.tinytable_css_h96li1wtavwkgoy72cy6, #tinytable_13fjo3fhqofxmr77b0ro th.tinytable_css_h96li1wtavwkgoy72cy6 { text-align: left }
    #tinytable_13fjo3fhqofxmr77b0ro td.tinytable_css_cb86r59qgslap7na03m7, #tinytable_13fjo3fhqofxmr77b0ro th.tinytable_css_cb86r59qgslap7na03m7 {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_13fjo3fhqofxmr77b0ro&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$y_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$d_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;4&#34;&gt;$R_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;5&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;4&#34;&gt;10&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;4&#34;&gt;7&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;7&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;4&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;9&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;1&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;4&#34;&gt;4&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;16&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;2&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;4&#34;&gt;3&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;5&#34;&gt;&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(1 - \frac{d_{(j)}}{R_{(j)}}\)&lt;/span&gt; is straightforward, so the table becomes:&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_pwro8an6lcdmghyyn84k = TinyTable.createTableFunctions(&#34;tinytable_pwro8an6lcdmghyyn84k&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 }, { i: &#39;5&#39;, j: 4 }, { i: &#39;5&#39;, j: 5 } ], css_id: &#39;tinytable_css_kvroag0647on9aibrtmk&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 }, { i: &#39;1&#39;, j: 4 }, { i: &#39;2&#39;, j: 4 }, { i: &#39;3&#39;, j: 4 }, { i: &#39;4&#39;, j: 4 }, { i: &#39;1&#39;, j: 5 }, { i: &#39;2&#39;, j: 5 }, { i: &#39;3&#39;, j: 5 }, { i: &#39;4&#39;, j: 5 } ], css_id: &#39;tinytable_css_jdhilsydd0ovjj4g5zxc&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 }, { i: &#39;0&#39;, j: 4 }, { i: &#39;0&#39;, j: 5 } ], css_id: &#39;tinytable_css_2l0ch1qqpad19ftfdsmj&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_pwro8an6lcdmghyyn84k.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_pwro8an6lcdmghyyn84k td.tinytable_css_kvroag0647on9aibrtmk, #tinytable_pwro8an6lcdmghyyn84k th.tinytable_css_kvroag0647on9aibrtmk {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_pwro8an6lcdmghyyn84k td.tinytable_css_jdhilsydd0ovjj4g5zxc, #tinytable_pwro8an6lcdmghyyn84k th.tinytable_css_jdhilsydd0ovjj4g5zxc { text-align: left }
    #tinytable_pwro8an6lcdmghyyn84k td.tinytable_css_2l0ch1qqpad19ftfdsmj, #tinytable_pwro8an6lcdmghyyn84k th.tinytable_css_2l0ch1qqpad19ftfdsmj {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_pwro8an6lcdmghyyn84k&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$y_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$d_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;4&#34;&gt;$R_{(j)}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;5&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1.00&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;2.00&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;2.00&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;4&#34;&gt;10.00&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;5&#34;&gt;0.80&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2.00&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;5.00&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;1.00&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;4&#34;&gt;7.00&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;5&#34;&gt;0.86&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3.00&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;7.00&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;1.00&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;4&#34;&gt;5.00&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;5&#34;&gt;0.80&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4.00&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;9.00&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;1.00&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;4&#34;&gt;4.00&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;5&#34;&gt;0.75&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5.00&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;16.00&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;2.00&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;4&#34;&gt;3.00&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;5&#34;&gt;0.33&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;p&gt;The Kaplan-Meier estimator is:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\hat{S}_{KM}(t) = \prod_{j:y_{(j)} \le t} \left(1 - \frac{d_{(j)}}{R_{(j)}} \right)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For each &lt;span class=&#34;math inline&#34;&gt;\(j\)&lt;/span&gt;, we thus take the cumulative product:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(j_1 = 0.8\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(j_2 = 0.8 \cdot 0.857 = 0.6856\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(j_3 = 0.6856 \cdot 0.8 = 0.54848\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(j_4 = 0.54848 \cdot 0.75 = 0.41136\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(j_5 = 0.41136 \cdot 0.333 = 0.1369829\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So finally, we have the survival probabilities (rounded to 3 digits):&lt;/p&gt;
&lt;!-- preamble start --&gt;

    &lt;script src=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js&#34;&gt;&lt;/script&gt;

    &lt;script&gt;
      // Create table-specific functions using external factory
      const tableFns_9g2vmc4l85a2ai8cd30l = TinyTable.createTableFunctions(&#34;tinytable_9g2vmc4l85a2ai8cd30l&#34;);
      // tinytable span after
      window.addEventListener(&#39;load&#39;, function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: &#39;5&#39;, j: 1 }, { i: &#39;5&#39;, j: 2 }, { i: &#39;5&#39;, j: 3 } ], css_id: &#39;tinytable_css_0gsa3vc5mq6m4zyan8g2&#39;,}, 
          { positions: [ { i: &#39;1&#39;, j: 1 }, { i: &#39;2&#39;, j: 1 }, { i: &#39;3&#39;, j: 1 }, { i: &#39;4&#39;, j: 1 }, { i: &#39;1&#39;, j: 2 }, { i: &#39;2&#39;, j: 2 }, { i: &#39;3&#39;, j: 2 }, { i: &#39;4&#39;, j: 2 }, { i: &#39;1&#39;, j: 3 }, { i: &#39;2&#39;, j: 3 }, { i: &#39;3&#39;, j: 3 }, { i: &#39;4&#39;, j: 3 } ], css_id: &#39;tinytable_css_qudi29yolqth1f9pviev&#39;,}, 
          { positions: [ { i: &#39;0&#39;, j: 1 }, { i: &#39;0&#39;, j: 2 }, { i: &#39;0&#39;, j: 3 } ], css_id: &#39;tinytable_css_v46u97wgn8bmam0b8xgb&#39;,}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  tableFns_9g2vmc4l85a2ai8cd30l.styleCell(cell.i, cell.j, group.css_id);
              });
          });
      });
    &lt;/script&gt;

    &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css&#34;&gt;
    &lt;style&gt;
    /* tinytable css entries after */
    #tinytable_9g2vmc4l85a2ai8cd30l td.tinytable_css_0gsa3vc5mq6m4zyan8g2, #tinytable_9g2vmc4l85a2ai8cd30l th.tinytable_css_0gsa3vc5mq6m4zyan8g2 {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.08em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    #tinytable_9g2vmc4l85a2ai8cd30l td.tinytable_css_qudi29yolqth1f9pviev, #tinytable_9g2vmc4l85a2ai8cd30l th.tinytable_css_qudi29yolqth1f9pviev { text-align: left }
    #tinytable_9g2vmc4l85a2ai8cd30l td.tinytable_css_v46u97wgn8bmam0b8xgb, #tinytable_9g2vmc4l85a2ai8cd30l th.tinytable_css_v46u97wgn8bmam0b8xgb {  position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: var(--tt-line-color); --line-color-left: var(--tt-line-color); --line-color-right: var(--tt-line-color); --line-color-top: var(--tt-line-color); --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.08em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; ; text-align: left }
    &lt;/style&gt;
    &lt;div class=&#34;container&#34;&gt;
      &lt;table class=&#34;tinytable&#34; id=&#34;tinytable_9g2vmc4l85a2ai8cd30l&#34; style=&#34;width: auto; margin-left: auto; margin-right: auto;&#34; data-quarto-disable-processing=&#39;true&#39;&gt;
        
        &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;1&#34;&gt;$j$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;2&#34;&gt;$1 - \frac{d_{(j)}}{R_{(j)}}$&lt;/th&gt;
                &lt;th scope=&#34;col&#34; data-row=&#34;0&#34; data-col=&#34;3&#34;&gt;$\hat{S}_{KM}(t)$&lt;/th&gt;
              &lt;/tr&gt;
        &lt;/thead&gt;
        
        &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;1&#34;&gt;1.00&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;2&#34;&gt;0.80&lt;/td&gt;
                  &lt;td data-row=&#34;1&#34; data-col=&#34;3&#34;&gt;0.80&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;1&#34;&gt;2.00&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;2&#34;&gt;0.86&lt;/td&gt;
                  &lt;td data-row=&#34;2&#34; data-col=&#34;3&#34;&gt;0.69&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;1&#34;&gt;3.00&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;2&#34;&gt;0.80&lt;/td&gt;
                  &lt;td data-row=&#34;3&#34; data-col=&#34;3&#34;&gt;0.55&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;1&#34;&gt;4.00&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;2&#34;&gt;0.75&lt;/td&gt;
                  &lt;td data-row=&#34;4&#34; data-col=&#34;3&#34;&gt;0.41&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;1&#34;&gt;5.00&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;2&#34;&gt;0.33&lt;/td&gt;
                  &lt;td data-row=&#34;5&#34; data-col=&#34;3&#34;&gt;0.14&lt;/td&gt;
                &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
&lt;!-- hack to avoid NA insertion in last line --&gt;
&lt;p&gt;We can now represent graphically the Kaplan-Meier estimator:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-13-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To draw this survival curve, remember that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the x-axis corresponds to the &lt;code&gt;time&lt;/code&gt; variable in the initial dataset, and&lt;/li&gt;
&lt;li&gt;the y-axis corresponds to the survival probabilities found above.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;In R&lt;/h2&gt;
&lt;p&gt;We now compare our results with the results found in R.&lt;/p&gt;
&lt;p&gt;We first create the dataset with the time and event variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# create dataset
dat &amp;lt;- data.frame(
  time = c(3, 5, 7, 2, 18, 16, 2, 9, 16, 5),
  event = c(0, 1, 1, 1, 0, 1, 1, 1, 1, 0)
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We then run the Kaplan-Meier estimator with the &lt;code&gt;survfit()&lt;/code&gt; and &lt;code&gt;Surv()&lt;/code&gt; functions:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# KM
library(survival)

km &amp;lt;- survfit(Surv(time, event) ~ 1,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice that the &lt;code&gt;Surv()&lt;/code&gt; function accepts two arguments:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the &lt;code&gt;time&lt;/code&gt; variable, and&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;event&lt;/code&gt; variable.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The &lt;code&gt;~ 1&lt;/code&gt; in the &lt;code&gt;survfit()&lt;/code&gt; function indicates that we estimate the Kaplan-Meier without any grouping. See more on this later in the post.&lt;/p&gt;
&lt;p&gt;Finally, we display the results and draw the Kaplan-Meier plot:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# results
summary(km)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Call: survfit(formula = Surv(time, event) ~ 1, data = dat)
## 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     2     10       2    0.800   0.126       0.5868        1.000
##     5      7       1    0.686   0.151       0.4447        1.000
##     7      5       1    0.549   0.172       0.2963        1.000
##     9      4       1    0.411   0.176       0.1782        0.950
##    16      3       2    0.137   0.126       0.0225        0.834&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot
plot(km,
  xlab = &amp;quot;Time&amp;quot;,
  ylab = &amp;quot;Survival probability&amp;quot;,
  conf.int = FALSE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-16-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The survival probabilities can be found in the &lt;code&gt;survival&lt;/code&gt; column. Remark that results by hand and in R are similar (any difference with the results by hand is due to rounding).&lt;/p&gt;
&lt;p&gt;Alternatively, we can use the &lt;code&gt;ggsurvplot()&lt;/code&gt; function within the &lt;code&gt;{survminer}&lt;/code&gt; package:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(survminer)

# plot
ggsurvplot(km,
  conf.int = FALSE,
  legend = &amp;quot;none&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-17-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that the crosses on the survival curve denote the censored observations.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The advantage with the &lt;code&gt;ggsurvplot()&lt;/code&gt; function is that it is easy to draw the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#median&#34;&gt;median&lt;/a&gt; survival directly on the plot:&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggsurvplot(km,
  conf.int = FALSE,
  surv.median.line = &amp;quot;hv&amp;quot;,
  legend = &amp;quot;none&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-18-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To find the median survival:&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(km)$table[&amp;quot;median&amp;quot;]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## median 
##      9&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# or more simply
km&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Call: survfit(formula = Surv(time, event) ~ 1, data = dat)
## 
##       n events median 0.95LCL 0.95UCL
## [1,] 10      7      9       5      NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Suppose that the event of interest is death:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;At time zero, the survival probability is 1 (100% of the subjects are alive).&lt;/li&gt;
&lt;li&gt;The median indicates that the median survival time is 9 years.&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt; This is the time at which the survival &lt;span class=&#34;math inline&#34;&gt;\(S(t)\)&lt;/span&gt; is 50%. In other words, is the time after which half of the subjects are expected to have died.&lt;/li&gt;
&lt;li&gt;From the plot, we also see that &lt;span class=&#34;math inline&#34;&gt;\(S(5) = P(T &amp;gt; 5 \text{ years}) =\)&lt;/span&gt; Probability of survival of more than 5 years for these subjects = 68.6%. This means that 68.6% of all subjects survive longer than 5 years, and that 31.4% of all subjects die within the first 5 years.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the sake of completeness, let’s do another example with a much larger dataset; the &lt;code&gt;tongue&lt;/code&gt; dataset within the &lt;code&gt;{KMsurv}&lt;/code&gt; package.&lt;a href=&#34;#fn6&#34; class=&#34;footnote-ref&#34; id=&#34;fnref6&#34;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load data
library(KMsurv)
data(tongue)

# preview data
head(tongue)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   type time delta
## 1    1    1     1
## 2    1    3     1
## 3    1    3     1
## 4    1    4     1
## 5    1   10     1
## 6    1   13     1&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;type&lt;/code&gt; is the tumor DNA profile (1 = aneuploid tumor, 2 = diploid tumor)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;time&lt;/code&gt; is the time to death or on-study time (in weeks)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;delta&lt;/code&gt; is the death indicator (0 = alive, 1 = dead)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this example, we focus on the aneuploid type:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;anaploid &amp;lt;- subset(tongue, type == 1)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can now plot the estimated survival function and estimate the median time to death. Since it is an estimator, we can also construct a confidence interval for the estimated survival at each time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt; and for the estimated median survival time.&lt;a href=&#34;#fn7&#34; class=&#34;footnote-ref&#34; id=&#34;fnref7&#34;&gt;&lt;sup&gt;7&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# results
fit &amp;lt;- survfit(Surv(time, delta) ~ 1,
  data = anaploid,
  conf.type = &amp;quot;log-log&amp;quot;
)

fit&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Call: survfit(formula = Surv(time, delta) ~ 1, data = anaploid, conf.type = &amp;quot;log-log&amp;quot;)
## 
##       n events median 0.95LCL 0.95UCL
## [1,] 52     31     93      65     157&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# plot
ggsurvplot(fit,
  surv.median.line = &amp;quot;hv&amp;quot;,
  legend = &amp;quot;none&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-22-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The median survival time is estimated to be 93 weeks, with a 95% confidence interval between 65 and 157 weeks.&lt;/p&gt;
&lt;p&gt;Kaplan-Meier curves can be seen as &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics&lt;/a&gt; for survival data. We now focus on the second branch of statistics, &lt;a href=&#34;https://statsandr.com/blog/hypothesis-test-by-hand/&#34;&gt;hypothesis testing&lt;/a&gt; which allows to draw conclusions on the population based on a sample (see a quick reminder about the &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;difference between population and sample&lt;/a&gt; if you need).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;hypothesis-testing&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Hypothesis testing&lt;/h1&gt;
&lt;p&gt;Hypothesis testing in the field of survival analysis mostly concerns:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The hazard function of &lt;strong&gt;one population&lt;/strong&gt;: in this case we test whether a censored sample comes from a population with a known hazard function &lt;span class=&#34;math inline&#34;&gt;\(h_0(t)\)&lt;/span&gt;. For example, we may be interested to compare survival in a sample of patients to the survival in the overall population (derived from the life tables).&lt;/li&gt;
&lt;li&gt;The comparison of the hazard function of &lt;strong&gt;two or more populations&lt;/strong&gt;: in this case we are interested in assessing whether there are differences in survival among different groups of subjects. For example:
&lt;ul&gt;
&lt;li&gt;2 groups: we are interested in comparing survival for female and male colon cancer patients&lt;/li&gt;
&lt;li&gt;3 groups or more: we are interested in comparing survival for melanoma cancer patients according to their treatments (with treatments A, B and C for example)&lt;a href=&#34;#fn8&#34; class=&#34;footnote-ref&#34; id=&#34;fnref8&#34;&gt;&lt;sup&gt;8&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;log-rank-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Log-rank test&lt;/h2&gt;
&lt;p&gt;In this article, we focus on comparing survival between two groups using the &lt;strong&gt;log-rank test&lt;/strong&gt; (also known as Mantel-Cox test). This test is the most common hypothesis test to compare survival between two groups.&lt;/p&gt;
&lt;p&gt;The intuition behind the test is that if the two groups have different hazard rates, the two survival curves (so their slopes) will differ. More precisely, the log-rank test compares the observed number of events in each group to what would be expected if the survival curves were identical (i.e., if the null hypothesis were true).&lt;/p&gt;
&lt;p&gt;Note that, as for the Kaplan-Meier estimator, the log-rank test is a nonparametric test, which makes no assumptions about the survival distributions.&lt;/p&gt;
&lt;p&gt;For this example, consider the following dataset:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;##    patient group time event
## 1        1     1  4.1     1
## 2        2     1  7.8     0
## 3        3     1 10.0     1
## 4        4     1 10.0     1
## 5        5     1 12.3     0
## 6        6     1 17.2     1
## 7        7     2  9.7     1
## 8        8     2 10.0     1
## 9        9     2 11.1     0
## 10      10     2 13.1     0
## 11      11     2 19.7     1
## 12      12     2 24.1     0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;patient&lt;/code&gt; is the patient’s identifier&lt;/li&gt;
&lt;li&gt;&lt;code&gt;group&lt;/code&gt; is the group (group 1 or 2)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;time&lt;/code&gt; is the time to death (in years)&lt;a href=&#34;#fn9&#34; class=&#34;footnote-ref&#34; id=&#34;fnref9&#34;&gt;&lt;sup&gt;9&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;event&lt;/code&gt; is the event status (0 = censored, 1 = death)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Suppose we are interested in comparing group 1 and 2 in terms of survival, that is, we compare survival curves between the 2 groups:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_0 : S_1(t) = S_2(t)\)&lt;/span&gt; for all &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(H_1 : S_1(t) \ne S_2(t)\)&lt;/span&gt; for some &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is a statistical test, so if the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &amp;lt; &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; (usually 0.05), we reject the null hypothesis and we conclude that survival (or the time to event) is significantly different between the two groups considered.&lt;/p&gt;
&lt;p&gt;To perform the log-rank test, the following test statistic will be useful:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{eqnarray}
U &amp;amp;=&amp;amp; \sum_{j=1}^r w(y_{(j)})\left(O_j - E_j\right) \\
&amp;amp;=&amp;amp; \sum_{j=1}^r w(y_{(j)})\left( d_{(j)1} - \frac{d_{(j)}R_{(j)1}}{R_{(j)}}\right)
\end{eqnarray}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;with &lt;span class=&#34;math inline&#34;&gt;\(U^{obs} = \frac{U}{\sqrt{Var(U)}} \sim N(0,1)\)&lt;/span&gt; and&lt;a href=&#34;#fn10&#34; class=&#34;footnote-ref&#34; id=&#34;fnref10&#34;&gt;&lt;sup&gt;10&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[\begin{eqnarray}
Var(U) &amp;amp;=&amp;amp; \sum_{j=1}^r w^2(y_{(j)}) \frac{N_{(j)}}{ D_{(j)}  }\\
&amp;amp;=&amp;amp; \sum_{j=1}^r w^2(y_{(j)}) \frac{ d_{(j)} \frac{R_{(j)1}}{R_{(j)} } \left( 1 - \frac{R_{(j)1}}{R_{(j)} } \right) \left( R_{(j)} - d_{(j)}\right) }{ R_{(j)} - 1  }
\end{eqnarray}\]&lt;/span&gt;&lt;/p&gt;
&lt;div id=&#34;by-hand-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;By hand&lt;/h3&gt;
&lt;p&gt;As for the Kaplan-Meier estimator by hand, it is best to also fill in a table for the log-rank test by hand.&lt;/p&gt;
&lt;p&gt;Let’s present the final table and comment below on how to fill it, column by column:&lt;/p&gt;
&lt;table style=&#34;width:100%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;5%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;7%&#34; /&gt;
&lt;col width=&#34;7%&#34; /&gt;
&lt;col width=&#34;7%&#34; /&gt;
&lt;col width=&#34;7%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;5%&#34; /&gt;
&lt;col width=&#34;5%&#34; /&gt;
&lt;col width=&#34;10%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(j\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(y_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(d_{(j)1}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(R_{(j)1}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(d_{(j)2}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(R_{(j)2}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(d_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(R_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(E_{j}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(O_{j}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(O_{j} - E_{j}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(N_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(D_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(N_{(j)}/D_{(j)}\)&lt;/span&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4.1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;12&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2.75&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;11&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;9.7&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;10&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-0.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2.16&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;10&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.333&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.667&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4.44&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.555&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;17.2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.333&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.667&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.44&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.22&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;19.7&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;span class=&#34;math inline&#34;&gt;\(Total\)&lt;/span&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;7&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2.566&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.433&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.265&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(j\)&lt;/span&gt;&lt;/strong&gt; is the number of distinct event times. We see that there are 5 (ignoring censored observations), so we write 1 to 5 in the table.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(y_{(j)}\)&lt;/span&gt;&lt;/strong&gt; is the ordered distinct event times:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;4.1&lt;/em&gt;, &lt;em&gt;9.7&lt;/em&gt;, &lt;em&gt;10&lt;/em&gt;, &lt;em&gt;17.2&lt;/em&gt; and &lt;em&gt;19.7&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)1}\)&lt;/span&gt;&lt;/strong&gt; is the number of observations for each distinct event time, for group 1:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## time
##  4.1   10 17.2 
##    1    2    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When there is no event, we simply write 0 in the table.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)1}\)&lt;/span&gt;&lt;/strong&gt; is the remaining number of patients at risk, for group 1. For this, the distribution of time (censored and not censored, for group 1) is useful:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## time
##  4.1  7.8   10 12.3 17.2 
##    1    1    2    1    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We see that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;At the beginning, there are 6 patients&lt;/li&gt;
&lt;li&gt;Before time 9.7, there are 4 patients left (6 - 1 who had the event at time 4.1 - 1 who was censored at time 7.8)&lt;/li&gt;
&lt;li&gt;Before time 10, there are 4 patients left (6 - 2)&lt;/li&gt;
&lt;li&gt;Before time 17.2, there are 1 patient left (6 - 5)&lt;/li&gt;
&lt;li&gt;Before time 19.7, there are 0 patient left (6 - 6)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Columns &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)2}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)2}\)&lt;/span&gt;&lt;/strong&gt; follow the same principle, but for group 2 this time. So we have, respectively for &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)2}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)2}\)&lt;/span&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## time
##  9.7   10 19.7 
##    1    1    1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## time
##  9.7   10 11.1 13.1 19.7 24.1 
##    1    1    1    1    1    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Columns &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)}\)&lt;/span&gt;&lt;/strong&gt; also follow the same principle, but this time considering both groups. So we have, respectively for &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)}\)&lt;/span&gt; and &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)}\)&lt;/span&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## time
##  4.1  9.7   10 17.2 19.7 
##    1    1    3    1    1&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## time
##  4.1  7.8  9.7   10 11.1 12.3 13.1 17.2 19.7 24.1 
##    1    1    1    3    1    1    1    1    1    1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(E_{j}\)&lt;/span&gt;&lt;/strong&gt; is the expected number of events in the first group assuming that &lt;span class=&#34;math inline&#34;&gt;\(h_1 \equiv h_2\)&lt;/span&gt;. It is obtained as follows&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[ E_{j} = \frac{d_{(j)}R_{(j)1}}{R_{(j)}}\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(O_{j}\)&lt;/span&gt;&lt;/strong&gt; is the observed number of events in the first group, so it is equal to the &lt;span class=&#34;math inline&#34;&gt;\(d_{(j)1}\)&lt;/span&gt; column.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(O_{j} - E_{j}\)&lt;/span&gt;&lt;/strong&gt; is straightforward.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(N_{(j)}\)&lt;/span&gt;&lt;/strong&gt; is defined as follows&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[N_{(j)} = d_{(j)} \frac{R_{(j)1}}{R_{(j)} } \left( 1 - \frac{R_{(j)1}}{R_{(j)} } \right) \left( R_{(j)} - d_{(j)}\right)\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(D_{(j)}\)&lt;/span&gt;&lt;/strong&gt; is &lt;span class=&#34;math inline&#34;&gt;\(R_{(j)} - 1\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Column &lt;span class=&#34;math inline&#34;&gt;\(N_{(j)}/D_{(j)}\)&lt;/span&gt;&lt;/strong&gt; is straightforward.&lt;/p&gt;
&lt;p&gt;Since &lt;span class=&#34;math inline&#34;&gt;\(w(y_{(j)}) = w^2(y_{(j)}) = 1\)&lt;/span&gt; for a log-rank test, we have&lt;a href=&#34;#fn11&#34; class=&#34;footnote-ref&#34; id=&#34;fnref11&#34;&gt;&lt;sup&gt;11&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[ U^{obs} = \frac{U}{\sqrt{Var(U)}} = \frac{1.434}{\sqrt{1.265}} = 1.275.\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We reject &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt; if &lt;span class=&#34;math inline&#34;&gt;\(|U^{obs}|&amp;gt;z_{1-\alpha/2}\)&lt;/span&gt;, so at the 5% significance level we reject &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt; if &lt;span class=&#34;math inline&#34;&gt;\(|U^{obs}|&amp;gt;z_{0.975}=1.96\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;We have &lt;span class=&#34;math inline&#34;&gt;\(|U^{obs}| = 1.275 &amp;lt; z_{0.975}=1.96\)&lt;/span&gt;. Hence, at the 5% significance level we do not reject &lt;span class=&#34;math inline&#34;&gt;\(H_0\)&lt;/span&gt;. This means that, based on the data, we are not able to conclude that survival is different between the two groups (which is equivalent than saying that we do not reject the hypothesis that survival is equal between the two groups).&lt;/p&gt;
&lt;p&gt;If you are interested in computing the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value &lt;span class=&#34;math inline&#34;&gt;\(= 2\times P(Z&amp;gt;1.275) = 2 \times 0.101 = 0.202 &amp;gt; 0.05\)&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;in-r-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;In R&lt;/h3&gt;
&lt;p&gt;We now compare our results in R with the &lt;code&gt;survdiff()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- data.frame(
  group = c(rep(1, 6), rep(2, 6)),
  time = c(4.1, 7.8, 10, 10, 12.3, 17.2, 9.7, 10, 11.1, 13.1, 19.7, 24.1),
  event = c(1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0)
)

dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##    group time event
## 1      1  4.1     1
## 2      1  7.8     0
## 3      1 10.0     1
## 4      1 10.0     1
## 5      1 12.3     0
## 6      1 17.2     1
## 7      2  9.7     1
## 8      2 10.0     1
## 9      2 11.1     0
## 10     2 13.1     0
## 11     2 19.7     1
## 12     2 24.1     0&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;survdiff(Surv(time, event) ~ group,
  data = dat
)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Call:
## survdiff(formula = Surv(time, event) ~ group, data = dat)
## 
##         N Observed Expected (O-E)^2/E (O-E)^2/V
## group=1 6        4     2.57     0.800      1.62
## group=2 6        3     4.43     0.463      1.62
## 
##  Chisq= 1.6  on 1 degrees of freedom, p= 0.2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, we can use the &lt;code&gt;ggsurvplot()&lt;/code&gt; function to draw the survival curves and perform the log-rank test at the same time:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;fit &amp;lt;- survfit(Surv(time, event) ~ group, data = dat)

ggsurvplot(fit,
  pval = TRUE,
  pval.method = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-30-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values and the conclusions are the same (any difference with the results by hand is due to rounding).&lt;/p&gt;
&lt;p&gt;As for the Kaplan-Meier estimation, we do another example on a larger dataset. Consider the data on the times until staphylococcus infection of burn patients, also available in the &lt;code&gt;{KMsurv}&lt;/code&gt;:&lt;a href=&#34;#fn12&#34; class=&#34;footnote-ref&#34; id=&#34;fnref12&#34;&gt;&lt;sup&gt;12&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# load data
data(burn)

# preview data
head(burn)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   Obs Z1 Z2 Z3 Z4 Z5 Z6 Z7 Z8 Z9 Z10 Z11 T1 D1 T2 D2 T3 D3
## 1   1  0  0  0 15  0  0  1  1  0   0   2 12  0 12  0 12  0
## 2   2  0  0  1 20  0  0  1  0  0   0   4  9  0  9  0  9  0
## 3   3  0  0  1 15  0  0  0  1  1   0   2 13  0 13  0  7  1
## 4   4  0  0  0 20  1  0  1  0  0   0   2 11  1 29  0 29  0
## 5   5  0  0  1 70  1  1  1  1  0   0   2 28  1 31  0  4  1
## 6   6  0  0  1 20  1  0  1  0  0   0   4 11  0 11  0  8  1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using the log-rank test, we want to test the hypothesis of difference in the time to staphylococcus infection (&lt;code&gt;T3&lt;/code&gt; variable) between patients whose burns were cared for with a routine bathing care method (&lt;code&gt;Z1 = 0&lt;/code&gt;) versus those whose body cleansing was initially performed using 4% chlorhexidine gluconate (&lt;code&gt;Z1 = 1&lt;/code&gt;). The event indicator is in variable &lt;code&gt;D3&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For this test, we use a two-sided alternative and a 5% significance level.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# fit
fit &amp;lt;- survfit(Surv(T3, D3) ~ Z1, data = burn)

# plot with log-rank test
ggsurvplot(fit,
  pval = TRUE,
  pval.method = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/what-is-survival-analysis/index_files/figure-html/unnamed-chunk-32-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In the sample&lt;/em&gt;, it seems that the time to infection for patients with routine bathing (&lt;code&gt;Z1 = 0&lt;/code&gt;) is smaller than for patients with body cleansing (&lt;code&gt;Z1 = 1&lt;/code&gt;). This is the case because the percentage of patients who have not experienced the infection decreases more quickly, so the hazard rate is greater.&lt;/p&gt;
&lt;p&gt;However, this conclusion cannot be generalized to the &lt;em&gt;population&lt;/em&gt; without performing a sound statistical test. And based on the result of the log-rank test, we do not reject the hypothesis that time to infection is the same between the two groups of patients (&lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value = 0.051).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;to-go-further&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;To go further&lt;/h1&gt;
&lt;p&gt;In this article, we have presented what is survival analysis, when, why and how to use it. We discussed about censoring and survival curves. We showed how to estimate the survival function via the Kaplan-Meier estimator and how to test survival between two groups via the log-rank test. We illustrated these approaches both by hand and in R.&lt;/p&gt;
&lt;p&gt;As you noticed, we did not show how to &lt;em&gt;model&lt;/em&gt; survival data. There are several regression models that can be applied to survival data, the most common one being the semiparametric Cox Proportional Hazards model &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-cox1972regression&#34;&gt;1972&lt;/a&gt;)&lt;/span&gt;. It originated from the medical area to investigate and assess the relationship between the survival times of patients and their corresponding predictor variables.&lt;/p&gt;
&lt;p&gt;We have seen that the Kaplan-Meier estimator is useful to visualize survival between groups and the log-rank test to test whether survival significantly differs between groups (so both approaches use a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#qualitative&#34;&gt;categorical variable&lt;/a&gt; as predictor). However, it does not work well for assessing the effect of &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#quantitative&#34;&gt;quantitative predictor&lt;/a&gt;. The Cox model has the advantage that it works for both quantitative as well as for categorical predictors, and for several risk factors at the same time (so it can model the effect of multiple variables at once).&lt;/p&gt;
&lt;p&gt;With the Cox model, we model the impact of different factors &lt;span class=&#34;math inline&#34;&gt;\(X_1, X_2, \ldots, X_q\)&lt;/span&gt; on survival via their impact on the hazard function:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[h(t|\textbf{X}) = h_0 (t) exp(\beta_1 X_1 + \beta_2 X_2 + \cdots + \beta_q X_q),\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(h(t|\textbf{X})\)&lt;/span&gt; is the instantaneous death rate conditional on having survived up to time &lt;span class=&#34;math inline&#34;&gt;\(t\)&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(h_0 (t)\)&lt;/span&gt; is the population-level baseline hazard – the underlying hazard function. It describes how the average person’s risk evolves over time.&lt;/li&gt;
&lt;li&gt;&lt;span class=&#34;math inline&#34;&gt;\(exp(\beta_1 X_1 + \beta_2 X_2 + \cdots + \beta_q X_q)\)&lt;/span&gt; describes how covariates affect the hazard. In particular, a unit increase in &lt;span class=&#34;math inline&#34;&gt;\(x_i\)&lt;/span&gt; leads to an increase of the hazard by a factor of &lt;span class=&#34;math inline&#34;&gt;\(\exp(\beta_i)\)&lt;/span&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This post aimed at presenting the introductory concepts in survival analysis, so this model will be developed in another post. In the meantime, if you would like to learn more about modeling survival data (thanks to the Cox model and other models), see this &lt;a href=&#34;https://rviews.rstudio.com/2022/09/06/deep-survival/&#34;&gt;post&lt;/a&gt; from Joseph Rickert.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-cox1972regression&#34; class=&#34;csl-entry&#34;&gt;
Cox, David R. 1972. &lt;span&gt;“Regression Models and Life-Tables.”&lt;/span&gt; &lt;em&gt;Journal of the Royal Statistical Society: Series B (Methodological)&lt;/em&gt; 34 (2): 187–202.
&lt;/div&gt;
&lt;div id=&#34;ref-kaplan1958nonparametric&#34; class=&#34;csl-entry&#34;&gt;
Kaplan, Edward L, and Paul Meier. 1958. &lt;span&gt;“Nonparametric Estimation from Incomplete Observations.”&lt;/span&gt; &lt;em&gt;Journal of the American Statistical Association&lt;/em&gt; 53 (282): 457–81.
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes footnotes-end-of-document&#34;&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id=&#34;fn1&#34;&gt;&lt;p&gt;Note that in survival analysis, the precision of the estimators (and the power of the tests) does not depend on the number of patients but on the number of events. So it is best to have many observations where the event does occur for the analyses to be effective. Here we work on a small sample for the sake of illustration.&lt;a href=&#34;#fnref1&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn2&#34;&gt;&lt;p&gt;Note that the &lt;code&gt;time&lt;/code&gt; variable can be expressed in other units, such as seconds, days, weeks, months, etc.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;Median is preferred over mean in survival analysis because survival functions are often skewed to the right. The mean is often influenced by &lt;a href=&#34;https://statsandr.com/blog/outliers-detection-in-r/&#34;&gt;outliers&lt;/a&gt;, whereas the median is not. See a discussion comparing the two in this &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-by-hand/#mean-vs.-median&#34;&gt;section&lt;/a&gt;.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;Note that if the survival curve does not cross 50% (because survival is greater than 50% at the last time point), then the median survival cannot be computed and is simply undefined.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;Note that the median survival is expressed in the same unit than the unit of the &lt;code&gt;time&lt;/code&gt; variable in the initial dataset. So if the time unit was months, the median survival time would be 9 months.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn6&#34;&gt;&lt;p&gt;More information about the dataset can be found on &lt;a href=&#34;https://cran.r-project.org/web/packages/KMsurv/&#34;&gt;CRAN&lt;/a&gt; or with &lt;code&gt;?tongue&lt;/code&gt;.&lt;a href=&#34;#fnref6&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn7&#34;&gt;&lt;p&gt;See the reason we use &lt;code&gt;log-log&lt;/code&gt; for the confidence interval in this &lt;a href=&#34;https://stats.stackexchange.com/questions/361354/choosing-conf-type-for-survfit-in-r&#34;&gt;thread&lt;/a&gt;.&lt;a href=&#34;#fnref7&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn8&#34;&gt;&lt;p&gt;Note that if the groups to compare have a natural ordering (such as the educational level; none, low, medium, high), tests that take it into consideration have more power to detect significant effects. These tests are referred as tests for trend.&lt;a href=&#34;#fnref8&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn9&#34;&gt;&lt;p&gt;Remember that the time unit can be different than years.&lt;a href=&#34;#fnref9&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn10&#34;&gt;&lt;p&gt;This is the case for large samples. The example described here does not meet this condition, but we still show it as an illustration.&lt;a href=&#34;#fnref10&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn11&#34;&gt;&lt;p&gt;Note that other weights can be considered, but this is beyond the scope of this article.&lt;a href=&#34;#fnref11&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn12&#34;&gt;&lt;p&gt;More information about the dataset can be found on &lt;a href=&#34;https://cran.r-project.org/web/packages/KMsurv/&#34;&gt;CRAN&lt;/a&gt; or with &lt;code&gt;?burn&lt;/code&gt;.&lt;a href=&#34;#fnref12&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Paper: &#39;Semi-Markov modeling for cancer insurance&#39;</title>
      <link>https://statsandr.com/blog/paper-semi-markov-modeling-for-cancer-insurance/</link>
      <pubDate>Wed, 06 Apr 2022 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/paper-semi-markov-modeling-for-cancer-insurance/</guid>
      <description>


&lt;p&gt;&lt;img src=&#34;images/Semi-Markov%20modeling%20for%20cancer%20insurance.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;I am happy to announce that our paper entitled “&lt;a href=&#34;https://rdcu.be/cKLGO&#34;&gt;Semi-Markov modeling for cancer insurance&lt;/a&gt;” has been accepted for publication in the European Actuarial Journal &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-soetewey2022semi&#34; role=&#34;doc-biblioref&#34;&gt;Soetewey et al. 2022&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Advancements in medicine and biostatistics have already resulted in a better access to insurance for people diagnosed with cancer. This materializes into the “right to be forgotten” adopted in several EU member states, granting access to insurance after a waiting period of at most 10 years starting at the end of the successful therapeutic protocol.&lt;/p&gt;
&lt;p&gt;This paper concentrates on insurance covers on a market where such a right has been implemented. Stand-alone products are considered, as well as guarantees included as a rider in an existing package. The cost of offering standard premium rates to all applicants in mortgage insurance related to property loans is also evaluated.&lt;/p&gt;
&lt;p&gt;The 3-state (healthy—ill—dead) Semi-Markov hierarchical model developed in Denuit et al. (2019) for long-term care insurance is adopted here for actuarial calculations. Semi-Markov transition intensities are estimated from cancer cases recorded by the Belgian Cancer Registry. The obtained results suggest that a new offer could develop, targeting the particular needs of cancer patients.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Read more &lt;a href=&#34;https://rdcu.be/cKLGO&#34;&gt;here&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Note that this paper is written jointly with Prof. Legrand and Prof. Denuit—my PhD supervisors at UCLouvain—and Dr. Silversmit from the Belgian Cancer Registry.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this paper will, to some extent, be helpful for your research.&lt;/p&gt;
&lt;p&gt;As always, if you have any question related to the topic covered in this paper, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2 unnumbered&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-soetewey2022semi&#34; class=&#34;csl-entry&#34;&gt;
Soetewey, Antoine, Catherine Legrand, Michel Denuit, and Geert Silversmit. 2022. &lt;span&gt;“Semi-Markov Modeling for Cancer Insurance.”&lt;/span&gt; &lt;em&gt;European Actuarial Journal&lt;/em&gt;, 1–25. &lt;a href=&#34;https://doi.org/10.1007/s13385-022-00308-2&#34;&gt;https://doi.org/10.1007/s13385-022-00308-2&lt;/a&gt;.
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Paper: &#39;Waiting period from diagnosis for mortgage insurance issued to cancer survivors&#39;</title>
      <link>https://statsandr.com/blog/waiting-period-cancer-survivors/</link>
      <pubDate>Mon, 23 Nov 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/waiting-period-cancer-survivors/</guid>
      <description>


&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-11-23-waiting-period-cancer-survivors_files/waiting-period-cancer-survivors.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;I am happy to announce that our paper entitled “&lt;a href=&#34;https://rdcu.be/cbagv&#34; target=&#34;_blank&#34;&gt;Waiting period from diagnosis for mortgage insurance issued to cancer survivors&lt;/a&gt;” has been published in the European Actuarial Journal &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-soetewey2021waiting&#34; role=&#34;doc-biblioref&#34;&gt;Soetewey et al. 2021&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Here is a brief &lt;strong&gt;summary&lt;/strong&gt; of it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;
Massart (2018) testimonial illustrates the difficulties faced by patients having survived cancer to access mortgage insurance securing home loan. Data collected by national registries nevertheless suggest that excess mortality due to some types of cancer becomes moderate or even negligible after some waiting period.
&lt;/p&gt;
&lt;p&gt;
In relation to the insurance laws passed in France and more recently in Belgium creating a right to be forgotten for cancer survivors, the present study aims to determine the waiting period after which standard premium rates become applicable. Compared to the French and Belgian laws, a waiting period starting at diagnosis (as recorded in national databases) is favored over a waiting period starting at the end of the therapeutic treatment protocol. This aims to avoid disputes when a claim is filed. Since diagnosis is often recorded in the official registry database, as is the case for the Belgian Cancer Registry, its date is reliable and unquestionable in case of claim.
&lt;/p&gt;
&lt;p&gt;
Based on 28,994 melanoma and thyroid cancer cases recorded by the Belgian Cancer Registry, the length of the waiting period is assessed with the help of widely-accepted tools from biostatistics, including relative survival models and time-to-cure indicators. It turns out for instance that a waiting period of 4 years after diagnosis is enough for 30-year-old thyroid cancer patients. This appears to be similar to the 3-year period starting at the end of treatment protocol according to the Belgian law in such a case.
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Read the full article &lt;a href=&#34;https://rdcu.be/cbagv&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here is a video explaining the paper and our research in general:&lt;/p&gt;
&lt;center&gt;
&lt;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#34;https://www.youtube.com/embed/qQrVV3prEDU&#34; frameborder=&#34;0&#34; allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&#34; allowfullscreen&gt;
&lt;/iframe&gt;
&lt;/center&gt;
&lt;p&gt;The paper also led to a &lt;a href=&#34;https://www.antoinesoetewey.com/files/Journee_modeles_de_guerison.pdf&#34; target=&#34;_blank&#34;&gt;talk&lt;/a&gt; organized by the French National Cancer Institute (INCa).&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This paper is written jointly with Prof. Catherine Legrand and Prof. Michel Denuit—my PhD supervisors—and Dr. Geert Silversmit from the Belgian Cancer Registry.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Thanks for reading. I hope this paper will, to some extent, be helpful for your research.&lt;/p&gt;
&lt;p&gt;As always, if you have any question related to the topic covered in this paper, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;div id=&#34;references&#34; class=&#34;section level2 unnumbered&#34;&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-soetewey2021waiting&#34; class=&#34;csl-entry&#34;&gt;
Soetewey, Antoine, Catherine Legrand, Michel Denuit, and Geert Silversmit. 2021. &lt;span&gt;“Waiting Period from Diagnosis for Mortgage Insurance Issued to Cancer Survivors.”&lt;/span&gt; &lt;em&gt;European Actuarial Journal&lt;/em&gt; 11: 135–60. &lt;a href=&#34;https://doi.org/10.1007/s13385-020-00254-x&#34;&gt;https://doi.org/10.1007/s13385-020-00254-x&lt;/a&gt;.
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>