title: Accelerated Failure Time modelling: plotting survival probabilities with CI-s (example provided)
body: <p>As proportional hazards assumption is violated with my real data, I am using an AFT model, trying to calculate adjusted survival probabilities for study groups in interest. The example below is on <a href="https://stat.ethz.ch/R-manual/R-devel/library/survival/html/kidney.html" rel="nofollow noreferrer">kidney</a> data and I tried to follow ciTools <a href="https://cran.r-project.org/web/packages/ciTools/vignettes/ciTools_survreg_vignette.html" rel="nofollow noreferrer">vignette</a>.</p>
  <pre><code>library(tidyverse)
  library(ciTools)
  library(here)
  library(survival)
  library(survminer)
  
  #data
  kidney
  </code></pre>
  <p><a href="https://i.stack.imgur.com/XcHoG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XcHoG.png" alt="table" /></a></p>
  <p><strong>Model</strong></p>
  <pre><code>fit1 =  survreg(Surv(time, censored) ~ sex + age + disease, data = kidney)
  
  
  Call:
  survreg(formula = Surv(time, censored) ~ sex + age + disease, 
      data = kidney)
  
  Coefficients:
  (Intercept)   sexfemale         age   diseaseGN   diseaseAN  diseasePKD 
   8.41830937 -0.93959839 -0.01578812 -0.25274448 -0.38306425 -0.32830433 
  
  Scale= 1.642239 
  
  Loglik(model)= -122.1   Loglik(intercept only)= -122.7
      Chisq= 1.33 on 5 degrees of freedom, p= 0.931 
  n= 76 
  </code></pre>
  <p><strong>Adding survival probabilities for both sexes for surviving at least 365 days</strong></p>
  <pre><code>probs = ciTools::add_probs(kidney, fit1, q = 365,
                          name = c(&quot;prob&quot;, &quot;lcb&quot;, &quot;ucb&quot;),
                          comparison = &quot;&gt;&quot;)
  probs
  </code></pre>
  <p><a href="https://i.stack.imgur.com/KXUUF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KXUUF.png" alt="enter image description here" /></a></p>
  <p><strong>Trying to plot one-year survival probabilities for both sexes, but there are multiple point estimates for geom_point?</strong></p>
  <p>It seems for me that these point estimates are given for each <strong>age</strong> value. Can I edit the prediction so that it is made for mean or median age?</p>
  <pre><code>probs %&gt;% ggplot(aes(x = prob, y = sex)) +
      ggtitle(&quot;1-year survival probability&quot;) +
      xlim(c(0,1)) +
      theme_bw() +
      geom_point(aes(x = prob), alpha = 0.5, colour = &quot;red&quot;)+
      geom_linerange(aes(xmin = lcb, xmax = ucb), alpha = 0.5)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/YNVHO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YNVHO.png" alt="enter image description here" /></a></p>
  <p><strong>However, this approach seems to work with a simple model</strong></p>
  <pre><code>fit2 =  survreg(Surv(time, censored) ~ sex, data = kidney)
  
  probs2 = ciTools::add_probs(kidney, fit2, q = 365,
                              name = c(&quot;prob&quot;, &quot;lcb&quot;, &quot;ucb&quot;),
                              comparison = &quot;&gt;&quot;)
  
  probs2 %&gt;% ggplot(aes(x = prob, y = sex)) +
      ggtitle(&quot;1-year survival probability&quot;) +
      xlim(c(0,1)) +
      theme_bw() +
      geom_point(aes(x = prob), alpha = 0.5, colour = &quot;red&quot;)+
      geom_linerange(aes(xmin = lcb, xmax = ucb), alpha = 0.5)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/4b6oA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4b6oA.png" alt="enter image description here" /></a></p>
  <p><strong>Questions:</strong></p>
  <ol>
  <li>How can I get adjusted survival probabilities for both sexes? Or if this is impossible, what would be possible alternatives? Code would help with alternatives.</li>
  <li>If I would like to get adjusted survival probabilities for both sexes and for different time points, should I edit &quot;q&quot; value in ciTools::add_probs() function? For example: q = 30 for one month; q = 90 for three months etc. Or I should run a separate model for each time period?</li>
  </ol>