title: R survival package; plotting log(-log(survival)) against log(time)
body: <p>I'm trying to use the R survival package, to produce a plot of <code>log(-log(survival))</code> against log(time)</p>
  
  <p><sub>(This is something sometimes recommended as a way to visually inspect for accelerated lifetime or proportional hazard properties). </sub></p>
  
  <p>The "<code>fun=cloglog</code>" option in <code>plot.survfit</code> is not producing what I expect it to.</p>
  
  <p>Using the "gehan" data from the "MASS" library:</p>
  
  <p>first, here is a simple plot of survival against time, for the treatment and control groups:</p>
  
  <pre><code> data(gehan, package="MASS")
   gehansurv=Surv(gehan$time, gehan$cens)
   plot(survfit(gehansurv ~ gehan$treat), col=c("black", "red"))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/PPLFo.jpg" alt="enter image description here"></p>
  
  <p>OK so far. Now, if I use the <code>fun=cloglog</code> option, the documentation for plot.survfit makes me think that I'll get a plot of <code>log(-log(survival))</code> against <code>log(time)</code>:</p>
  
  <blockquote>
    <p>fun</p>
    
    <p>an arbitrary function defining a transformation of the survival curve. For example fun=log
    is an alternative way to draw a log-survival curve (but with the axis labeled with log(S) 
    values), and fun=sqrt would generate a curve on square root scale. Four often used 
    transformations can be specified with a character argument instead: "log" is the same as 
    using the log=T option, "event" plots cumulative events (f(y) = 1-y), "cumhaz" plots the 
    cumulative hazard function (f(y) = -log(y)), and "cloglog" creates a complimentary log-log 
    survival plot (f(y) = log(-log(y)) along with log scale for the x-axis).</p>
  </blockquote>
  
  <p>However, when I try this, it doesn't seem to use the <code>log(-log(y))</code> function, because the displayed curve is still decreasing (since the original survival curve is decreasing, and the applied <code>f(y)=log(-log(y))</code> function is a decreasing function, the resulting <code>log(-log(survival))</code> curve should be increasing). </p>
  
  <p>Also, the x-axis is not log-scaled:</p>
  
  <pre><code>library(VGAM)
   plot(survfit(gehansurv ~ gehan$treat), col=c("black", "red"), fun=cloglog)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/m4Twe.jpg" alt="enter image description here"></p>
  
  <p>I can get what I want by defining my own <code>log(-log())</code> function and using the <code>log="x"</code> option:</p>
  
  <pre><code>&gt; myfun=function(p){return(log(-log(p)))}
  &gt; plot(survfit(gehansurv ~ gehan$treat), col=c("black", "red"), fun=myfun, log="x")
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/cp2Ce.jpg" alt="enter image description here"></p>
  
  <p>So: What am I doing wrong above (or how am I misinterpreting the <code>plot.survfit</code> documentation)? </p>
  
  <p>Supplementary question: how would a <code>"fun="</code> option change the scaling on the horizontal axis as the documentation claims that <code>"fun=cloglog"</code> would, when on the face of it the argument to <code>"fun"</code> is a function applied to the vertical variable?</p>