<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/comparing-fancy-survival-curves-with-weighted-log-rank-tests-2/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html"> http://r-addict.com</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img src="https://i2.wp.com/r-addict.com/images/fulls/fancy_survminer.png?w=456" data-recalc-dims="1"> We have just adopted weighted Log-rank tests to the <a target="_blank" rel="nofollow" href="http://www.sthda.com/english/rpkgs/survminer/">survminer</a> package, thanks to <a target="_blank" rel="nofollow" href="https://cran.r-project.org/web/packages/survMisc/index.html">survMisc::comp</a>. What are they and why they are useful? Read this blog post to find out. I used <a target="_blank" rel="nofollow" href="https://github.com/cttobin/ggthemr">ggthemr</a> to make the presentation a little bit more bizarre.</p>
<ul>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#log-rank-statistic-for-2-groups">Log-rank statistic for 2 groups</a></li>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#weighted-log-rank-extensions">Weighted Log-rank extensions</a>
<ul>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#why-are-they-useful">Why are they useful?</a></li>
</ul>
</li>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#plots">Plots</a>
<ul>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#gghtemr">gghtemr</a></li>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#log-rank-survdiff--sea-theme">Log-rank (survdiff) + sea theme</a></li>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#log-rank-comp--dust-theme">Log-rank (comp) + dust theme</a></li>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#gehan-breslow-generalized-wilcoxon--flat-dark-theme">Gehan-Breslow (generalized Wilcoxon) + flat dark theme</a></li>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#tharone-ware--camoflauge">Tharone-Ware + camoflauge</a></li>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#peto-petos-modified-survival-estimate--fresh-theme">Peto-Peto’s modified survival estimate + fresh theme</a></li>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#modified-peto-petos-by-andersen--grass-theme">modified Peto-Peto’s (by Andersen) + grass theme</a></li>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#fleming-harrington-p1-q1--light-theme">Fleming-Harrington (p=1, q=1) + light theme</a></li>
</ul>
</li>
<li><a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html#references">References</a></li>
</ul>
<h1>Log-rank statistic for 2 groups</h1>
<p>Log-rank test, based on Log-rank statistic, is a popular tool that determines whether 2 (or more) estimates of survival curves differ significantly. As it is stated in the literature, the Log-rank test for comparing survival (estimates of survival curves) in 2 groups ( and ) is based on the below statistic</p>
<p></p>
<p>where</p>
<p></p>
<p>and</p>
<ul>
<li> for  are possible event times,</li>
<li> is the overall risk set size on the time  (),</li>
<li> is the risk set size on the time  in group ,</li>
<li> is the risk set size on the time  in group ,</li>
<li> overall observed events in the time  (),</li>
<li> observed events in the time  in group ,</li>
<li> observed events in the time  in group ,</li>
<li> number of overall expected events in the time  (),</li>
<li> number of expected events in the time  in group ,</li>
<li> number of expected events in the time  in group ,</li>
<li> is a weight for the statistic,</li>
</ul>
<p>also remember about few notes</p>
<p></p>
<p></p>
<p>that’s why we can substitute group  with  in  and receive same results.</p>
<h1>Weighted Log-rank extensions</h1>
<p>Regular Log-rank comparison uses  but many modifications to that approach have been proposed. The most popular modifications, called weighted Log-rank tests, are available in <code>?survMisc::comp</code></p>
<ul>
<li><code>n</code> Gehan and Breslow proposed to use  (this is also called generalized Wilcoxon),</li>
<li><code>srqtN</code> Tharone and Ware proposed to use ,</li>
<li><code>S1</code> Peto-Peto’s modified survival estimate ,</li>
<li><code>S2</code> modified Peto-Peto (by Andersen) ,</li>
<li><code>FH</code> Fleming-Harrington .</li>
</ul>
<blockquote>
<p>Watch out for <code>FH</code> as I <a target="_blank" rel="nofollow" href="https://github.com/dardisco/survMisc/issues/15">submitted an info on survMisc repository</a> where I think their mathematical notation is misleading for Fleming-Harrington.</p>
</blockquote>
<h2>Why are they useful?</h2>
<p>The regular Log-rank test is sensitive to detect differences in late survival times, where Gehan-Breslow and Tharone-Ware propositions might be used if one is interested in early differences in survival times. Peto-Peto modifications are also useful in early differences and are more robust (than Tharone-Whare or Gehan-Breslow) for situations where many observations are censored. The most flexible is Fleming-Harrington method for weights, where high <code>p</code> indicates detecting early differences and high <code>q</code> indicates detecting differences in late survival times. But there is always an issue on how to detect <code>p</code> and <code>q</code>.</p>
<blockquote>
<p>Remember that test selection should be performed at the research design level! Not after looking in the dataset.</p>
</blockquote>
<h1>Plots</h1>
<figure>
<pre><code data-lang="r"><span>library</span><span>(</span><span>survminer</span><span>)</span><span>
</span><span>library</span><span>(</span><span>survival</span><span>)</span><span>
</span><span>data</span><span>(</span><span>&quot;kidney&quot;</span><span>,</span><span> </span><span>package</span><span>=</span><span>&quot;KMsurv&quot;</span><span>)</span><span>
</span><span>fit</span><span> </span><span>&lt;-</span><span> </span><span>survfit</span><span>(</span><span>Surv</span><span>(</span><span>time</span><span>=</span><span>time</span><span>,</span><span> </span><span>event</span><span>=</span><span>delta</span><span>)</span><span> </span><span>~</span><span> </span><span>type</span><span>,</span><span> </span><span>data</span><span>=</span><span>kidney</span><span>)</span></code></pre>
</figure>
<p>After preparing a functionality for this GitHub’s issue <a target="_blank" rel="nofollow" href="https://github.com/kassambara/survminer/issues/17">Other tests than log-rank for testing survival curves</a> we are now able to compute p-values for various Log-rank tests in survminer package. Let as see below examples on executing all possible tests.</p>
<h3>gghtemr</h3>
<p>Let’s make it more interesting (or not) with <a target="_blank" rel="nofollow" href="https://github.com/cttobin/ggthemr">ggthemr</a> package that has many predefinied palettes.</p>
<p>After installation</p>
<figure>
<pre><code data-lang="r"><span>devtools</span><span>::</span><span>install_github</span><span>(</span><span>'cttobin/ggthemr'</span><span>)</span></code></pre>
</figure>
<p>one can set up a global ggplot2 palette/theme with</p>
<figure>
<pre><code data-lang="r"><span>library</span><span>(</span><span>ggthemr</span><span>)</span><span>
</span><span>ggthemr</span><span>(</span><span>'dust'</span><span>)</span></code></pre>
</figure>
<p>and check current colors with</p>
<figure>
<pre><code data-lang="r"><span>swatch</span><span>()</span></code></pre>
</figure>
<figure>
<pre><code data-lang="text">[1] &quot;#555555&quot; &quot;#db735c&quot; &quot;#EFA86E&quot; &quot;#9A8A76&quot; &quot;#F3C57B&quot; &quot;#7A6752&quot; &quot;#2A91A2&quot; &quot;#87F28A&quot; &quot;#6EDCEF&quot;
attr(,&quot;class&quot;)
[1] &quot;ggthemr_swatch&quot;</code></pre>
</figure>
<blockquote>
<p>Note: the first colour in a swatch is a special one. It is reserved for outlining boxplots, text etc. For color lines first color is not used.</p>
</blockquote>
<h2>Log-rank (survdiff) + sea theme</h2>
<figure>
<pre><code data-lang="r"><span>ggthemr</span><span>(</span><span>&quot;sea&quot;</span><span>)</span><span> </span><span># set ggthemr theme
</span><span>
</span><span>ggsurvplot</span><span>(</span><span>
</span><span>fit</span><span>,</span><span> </span><span># fitted survfit object
</span><span> </span><span>risk.table</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># include risk table?
</span><span> </span><span>conf.int</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add confidence intervals?
</span><span> </span><span>pval</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add p-value to the plot?
</span><span> </span><span>pval.method</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># write the name of the test </span><span> </span><span># that was used compute the p-value?
</span><span> </span><span>pval.method.coord</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>3</span><span>,</span><span> </span><span>0.1</span><span>),</span><span> </span><span># coordinates for the name
</span><span> </span><span>pval.method.size</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span> </span><span># size for the name of the test
</span><span> </span><span>log.rank.weights</span><span> </span><span>=</span><span> </span><span>&quot;survdiff&quot;</span><span>,</span><span> </span><span># type of weights in log-rank test
</span><span> </span><span>### few options are set by defualt in survminer
</span><span> </span><span>### we will need to turn them off to allow
</span><span> </span><span>### ggthemr to work in his full glory
</span><span> </span><span>palette</span><span> </span><span>=</span><span> </span><span>swatch</span><span>()[</span><span>2</span><span>:</span><span>3</span><span>],</span><span> </span><span># pass the active palette
</span><span> </span><span>ggtheme</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer theme
</span><span> </span><span>font.x</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the x axis
</span><span> </span><span>font.y</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the y axis
</span><span> </span><span>font.main</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the title
</span><span> </span><span>font.submain</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the subtitle
</span><span> </span><span>font.caption</span><span> </span><span>=</span><span> </span><span>NULL</span><span> </span><span># disable adding custom survminer font for the caption
</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk unnamed-chunk-6" src="https://i1.wp.com/r-addict.com/figure/source/2017-02-09-Fancy-Survival-Plots/unnamed-chunk-6-1.png?w=456" data-recalc-dims="1"></p>
<h2>Log-rank (comp) + dust theme</h2>
<figure>
<pre><code data-lang="r"><span>ggthemr</span><span>(</span><span>&quot;dust&quot;</span><span>)</span><span> </span><span># set ggthemr theme
</span><span>
</span><span>ggsurvplot</span><span>(</span><span>
</span><span>fit</span><span>,</span><span> </span><span># fitted survfit object
</span><span> </span><span>risk.table</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># include risk table?
</span><span> </span><span>conf.int</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add confidence intervals?
</span><span> </span><span>pval</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add p-value to the plot?
</span><span> </span><span>pval.method</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># write the name of the test </span><span> </span><span># that was used compute the p-value?
</span><span> </span><span>pval.method.coord</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>3</span><span>,</span><span> </span><span>0.1</span><span>),</span><span> </span><span># coordinates for the name
</span><span> </span><span>pval.method.size</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span> </span><span># size for the name of the test
</span><span> </span><span>log.rank.weights</span><span> </span><span>=</span><span> </span><span>&quot;1&quot;</span><span>,</span><span> </span><span># type of weights in log-rank test
</span><span> </span><span>### few options are set by defualt in survminer
</span><span> </span><span>### we will need to turn them off to allow
</span><span> </span><span>### ggthemr to work in his full glory
</span><span> </span><span>palette</span><span> </span><span>=</span><span> </span><span>swatch</span><span>()[</span><span>2</span><span>:</span><span>3</span><span>],</span><span> </span><span># pass the active palette
</span><span> </span><span>ggtheme</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer theme
</span><span> </span><span>font.x</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the x axis
</span><span> </span><span>font.y</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the y axis
</span><span> </span><span>font.main</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the title
</span><span> </span><span>font.submain</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the subtitle
</span><span> </span><span>font.caption</span><span> </span><span>=</span><span> </span><span>NULL</span><span> </span><span># disable adding custom survminer font for the caption
</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk unnamed-chunk-7" src="https://i2.wp.com/r-addict.com/figure/source/2017-02-09-Fancy-Survival-Plots/unnamed-chunk-7-1.png?w=456" data-recalc-dims="1"></p>
<h2>Gehan-Breslow (generalized Wilcoxon) + flat dark theme</h2>
<figure>
<pre><code data-lang="r"><span>ggthemr</span><span>(</span><span>&quot;flat dark&quot;</span><span>)</span><span> </span><span># set ggthemr theme
</span><span>
</span><span>ggsurvplot</span><span>(</span><span>
</span><span>fit</span><span>,</span><span> </span><span># fitted survfit object
</span><span> </span><span>risk.table</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># include risk table?
</span><span> </span><span>conf.int</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add confidence intervals?
</span><span> </span><span>pval</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add p-value to the plot?
</span><span> </span><span>pval.method</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># write the name of the test </span><span> </span><span># that was used compute the p-value?
</span><span> </span><span>pval.method.coord</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>5</span><span>,</span><span> </span><span>0.1</span><span>),</span><span> </span><span># coordinates for the name
</span><span> </span><span>pval.method.size</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span> </span><span># size for the name of the test
</span><span> </span><span>log.rank.weights</span><span> </span><span>=</span><span> </span><span>&quot;n&quot;</span><span>,</span><span> </span><span># type of weights in log-rank test
</span><span> </span><span>### few options are set by defualt in survminer
</span><span> </span><span>### we will need to turn them off to allow
</span><span> </span><span>### ggthemr to work in his full glory
</span><span> </span><span>palette</span><span> </span><span>=</span><span> </span><span>swatch</span><span>()[</span><span>2</span><span>:</span><span>3</span><span>],</span><span> </span><span># pass the active palette
</span><span> </span><span>ggtheme</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer theme
</span><span> </span><span>font.x</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the x axis
</span><span> </span><span>font.y</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the y axis
</span><span> </span><span>font.main</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the title
</span><span> </span><span>font.submain</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the subtitle
</span><span> </span><span>font.caption</span><span> </span><span>=</span><span> </span><span>NULL</span><span> </span><span># disable adding custom survminer font for the caption
</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk unnamed-chunk-8" src="https://i2.wp.com/r-addict.com/figure/source/2017-02-09-Fancy-Survival-Plots/unnamed-chunk-8-1.png?w=456" data-recalc-dims="1"></p>
<h2>Tharone-Ware + camoflauge</h2>
<figure>
<pre><code data-lang="r"><span>ggthemr</span><span>(</span><span>&quot;camoflauge&quot;</span><span>)</span><span> </span><span># set ggthemr theme
</span><span>
</span><span>ggsurvplot</span><span>(</span><span>
</span><span>fit</span><span>,</span><span> </span><span># fitted survfit object
</span><span> </span><span>risk.table</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># include risk table?
</span><span> </span><span>conf.int</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add confidence intervals?
</span><span> </span><span>pval</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add p-value to the plot?
</span><span> </span><span>pval.method</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># write the name of the test </span><span> </span><span># that was used compute the p-value?
</span><span> </span><span>pval.method.coord</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>3</span><span>,</span><span> </span><span>0.1</span><span>),</span><span> </span><span># coordinates for the name
</span><span> </span><span>pval.method.size</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span> </span><span># size for the name of the test
</span><span> </span><span>log.rank.weights</span><span> </span><span>=</span><span> </span><span>&quot;sqrtN&quot;</span><span>,</span><span> </span><span># type of weights in log-rank test
</span><span> </span><span>### few options are set by defualt in survminer
</span><span> </span><span>### we will need to turn them off to allow
</span><span> </span><span>### ggthemr to work in his full glory
</span><span> </span><span>palette</span><span> </span><span>=</span><span> </span><span>swatch</span><span>()[</span><span>2</span><span>:</span><span>3</span><span>],</span><span> </span><span># pass the active palette
</span><span> </span><span>ggtheme</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer theme
</span><span> </span><span>font.x</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the x axis
</span><span> </span><span>font.y</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the y axis
</span><span> </span><span>font.main</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the title
</span><span> </span><span>font.submain</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the subtitle
</span><span> </span><span>font.caption</span><span> </span><span>=</span><span> </span><span>NULL</span><span> </span><span># disable adding custom survminer font for the caption
</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk unnamed-chunk-9" src="https://i1.wp.com/r-addict.com/figure/source/2017-02-09-Fancy-Survival-Plots/unnamed-chunk-9-1.png?w=456" data-recalc-dims="1"></p>
<h2>Peto-Peto’s modified survival estimate + fresh theme</h2>
<figure>
<pre><code data-lang="r"><span>ggthemr</span><span>(</span><span>&quot;fresh&quot;</span><span>)</span><span> </span><span># set ggthemr theme
</span><span>
</span><span>ggsurvplot</span><span>(</span><span>
</span><span>fit</span><span>,</span><span> </span><span># fitted survfit object
</span><span> </span><span>risk.table</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># include risk table?
</span><span> </span><span>conf.int</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add confidence intervals?
</span><span> </span><span>pval</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add p-value to the plot?
</span><span> </span><span>pval.method</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># write the name of the test </span><span> </span><span># that was used compute the p-value?
</span><span> </span><span>pval.method.coord</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>5</span><span>,</span><span> </span><span>0.1</span><span>),</span><span> </span><span># coordinates for the name
</span><span> </span><span>pval.method.size</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span> </span><span># size for the name of the test
</span><span> </span><span>log.rank.weights</span><span> </span><span>=</span><span> </span><span>&quot;S1&quot;</span><span>,</span><span> </span><span># type of weights in log-rank test
</span><span> </span><span>### few options are set by defualt in survminer
</span><span> </span><span>### we will need to turn them off to allow
</span><span> </span><span>### ggthemr to work in his full glory
</span><span> </span><span>palette</span><span> </span><span>=</span><span> </span><span>swatch</span><span>()[</span><span>2</span><span>:</span><span>3</span><span>],</span><span> </span><span># pass the active palette
</span><span> </span><span>ggtheme</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer theme
</span><span> </span><span>font.x</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the x axis
</span><span> </span><span>font.y</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the y axis
</span><span> </span><span>font.main</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the title
</span><span> </span><span>font.submain</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the subtitle
</span><span> </span><span>font.caption</span><span> </span><span>=</span><span> </span><span>NULL</span><span> </span><span># disable adding custom survminer font for the caption
</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk unnamed-chunk-10" src="https://i1.wp.com/r-addict.com/figure/source/2017-02-09-Fancy-Survival-Plots/unnamed-chunk-10-1.png?w=456" data-recalc-dims="1"></p>
<h2>modified Peto-Peto’s (by Andersen) + grass theme</h2>
<figure>
<pre><code data-lang="r"><span>ggthemr</span><span>(</span><span>&quot;grass&quot;</span><span>)</span><span> </span><span># set ggthemr theme
</span><span>
</span><span>ggsurvplot</span><span>(</span><span>
</span><span>fit</span><span>,</span><span> </span><span># fitted survfit object
</span><span> </span><span>risk.table</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># include risk table?
</span><span> </span><span>conf.int</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add confidence intervals?
</span><span> </span><span>pval</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add p-value to the plot?
</span><span> </span><span>pval.method</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># write the name of the test </span><span> </span><span># that was used compute the p-value?
</span><span> </span><span>pval.method.coord</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>5</span><span>,</span><span> </span><span>0.1</span><span>),</span><span> </span><span># coordinates for the name
</span><span> </span><span>pval.method.size</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span> </span><span># size for the name of the test
</span><span> </span><span>log.rank.weights</span><span> </span><span>=</span><span> </span><span>&quot;S2&quot;</span><span>,</span><span> </span><span># type of weights in log-rank test
</span><span> </span><span>### few options are set by defualt in survminer
</span><span> </span><span>### we will need to turn them off to allow
</span><span> </span><span>### ggthemr to work in his full glory
</span><span> </span><span>palette</span><span> </span><span>=</span><span> </span><span>swatch</span><span>()[</span><span>2</span><span>:</span><span>3</span><span>],</span><span> </span><span># pass the active palette
</span><span> </span><span>ggtheme</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer theme
</span><span> </span><span>font.x</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the x axis
</span><span> </span><span>font.y</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the y axis
</span><span> </span><span>font.main</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the title
</span><span> </span><span>font.submain</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the subtitle
</span><span> </span><span>font.caption</span><span> </span><span>=</span><span> </span><span>NULL</span><span> </span><span># disable adding custom survminer font for the caption
</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk unnamed-chunk-11" src="https://i2.wp.com/r-addict.com/figure/source/2017-02-09-Fancy-Survival-Plots/unnamed-chunk-11-1.png?w=456" data-recalc-dims="1"></p>
<h2>Fleming-Harrington (p=1, q=1) + light theme</h2>
<figure>
<pre><code data-lang="r"><span>ggthemr</span><span>(</span><span>&quot;light&quot;</span><span>)</span><span> </span><span># set ggthemr theme
</span><span>
</span><span>ggsurvplot</span><span>(</span><span>
</span><span>fit</span><span>,</span><span> </span><span># fitted survfit object
</span><span> </span><span>risk.table</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># include risk table?
</span><span> </span><span>conf.int</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add confidence intervals?
</span><span> </span><span>pval</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># add p-value to the plot?
</span><span> </span><span>pval.method</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span># write the name of the test </span><span> </span><span># that was used compute the p-value?
</span><span> </span><span>pval.method.coord</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>5</span><span>,</span><span> </span><span>0.1</span><span>),</span><span> </span><span># coordinates for the name
</span><span> </span><span>pval.method.size</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span> </span><span># size for the name of the test
</span><span> </span><span>log.rank.weights</span><span> </span><span>=</span><span> </span><span>&quot;FH_p=1_q=1&quot;</span><span>,</span><span> </span><span># type of weights in log-rank test
</span><span> </span><span>### few options are set by defualt in survminer
</span><span> </span><span>### we will need to turn them off to allow
</span><span> </span><span>### ggthemr to work in his full glory
</span><span> </span><span>palette</span><span> </span><span>=</span><span> </span><span>swatch</span><span>()[</span><span>2</span><span>:</span><span>3</span><span>],</span><span> </span><span># pass the active palette
</span><span> </span><span>ggtheme</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer theme
</span><span> </span><span>font.x</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the x axis
</span><span> </span><span>font.y</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the y axis
</span><span> </span><span>font.main</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the title
</span><span> </span><span>font.submain</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span># disable adding custom survminer font for the subtitle
</span><span> </span><span>font.caption</span><span> </span><span>=</span><span> </span><span>NULL</span><span> </span><span># disable adding custom survminer font for the caption
</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk unnamed-chunk-12" src="https://i1.wp.com/r-addict.com/figure/source/2017-02-09-Fancy-Survival-Plots/unnamed-chunk-12-1.png?w=456" data-recalc-dims="1"></p>
<h1>References</h1>
<ul>
<li>
<p>Gehan A. A Generalized Wilcoxon Test for Comparing Arbitrarily Singly-Censored Samples. Biometrika 1965 Jun. 52(1/2):203-23. <a target="_blank" rel="nofollow" href="http://r-addict.com/2017/02/09/www.jstor.org/stable/2333825">JSTOR</a></p>
</li>
<li>
<p>Tarone RE, Ware J 1977 On Distribution-Free Tests for Equality of Survival Distributions. Biometrika;64(1):156-60. <a target="_blank" rel="nofollow" href="http://www.jstor.org/stable/2335790">JSTOR</a></p>
</li>
<li>
<p>Peto R, Peto J 1972 Asymptotically Efficient Rank Invariant Test Procedures. J Royal Statistical Society 135(2):186-207. <a target="_blank" rel="nofollow" href="http://www.jstor.org/stable/2344317">JSTOR</a></p>
</li>
<li>
<p>Fleming TR, Harrington DP, O’Sullivan M 1987 Supremum Versions of the Log-Rank and Generalized Wilcoxon Statistics. J American Statistical Association 82(397):312-20. <a target="_blank" rel="nofollow" href="http://www.jstor.org/stable/2289169">JSTOR</a></p>
</li>
<li>
<p>Billingsly P 1999 Convergence of Probability Measures. New York: John Wiley &amp; Sons. <a target="_blank" rel="nofollow" href="http://dx.doi.org/10.1002/9780470316962">Wiley (paywall)</a></p>
</li>
</ul>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://r-addict.com/2017/02/09/Fancy-Survival-Plots.html"> http://r-addict.com</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/wQ_Wc1QxKcU"></a></div>