title: Obtain Kaplan-Meier survival risk per individual instance
body: <h3>Problem</h3>
  
  <p>Given <em>n</em>-patient records with <code>time</code> and <code>status</code> variables (among others), I would like to obtain their survival risk in the time period they're within ie 2, 4, 6, 8, 10 years. </p>
  
  <p>I have a division of 24 - 47 months (2 years), 48 - 83 months (4 years), 84 - 107 months (6 years), 108 - 119 months (8 years) and 120 - "up to what's available" months (10 years).</p>
  
  <p>In an individual perspective, a patient with survival months of 30 months will be included in the two-year period and along with the other predictive variables I want to know this patient's survival risk within two years.</p>
  
  <h3>My method</h3>
  
  <p>I'm retrieving survival risk percentages for my data using the <a href="https://stats.stackexchange.com/a/26291/35842">R code described in this thread</a>. </p>
  
  <pre><code>km &lt;- survfit(Surv(time, status)~1, data=mydata)
  survest &lt;- stepfun(km$time, c(1, km$surv))
  </code></pre>
  
  <p>The <code>time</code> variable is the survival months and the <code>status</code> has values <code>1</code> and <code>0</code> for alive and dead respectively. </p>
  
  <p>The code outputs something like this (taken from <a href="https://stats.stackexchange.com/a/26291/35842">here</a>):</p>
  
  <pre><code>&gt; survest(0:100)
   [1] 1.0000000 0.9854015 0.9781022 0.9708029 0.9635036 0.9635036 0.9635036
   [8] 0.9416058 0.9124088 0.9124088 0.8978102 0.8905109 0.8759124 0.8613139
   [15] 0.8613139 0.8467153 0.8394161 0.8394161 0.8175182 0.8029197 0.7883212
   [22] 0.7737226 0.7664234 0.7664234 0.7518248 0.7299270 0.7299270 0.7225540
   [29] 0.7225540 0.7151810 0.7004350 0.6856890 0.6856890 0.6783160 0.6783160
  </code></pre>
  
  <p>My question is: are these the actual survival estimates for my 300,000 individual records wherein I need to use <code>survest(0:300000)</code>? I tried <code>survest(0:1000)</code> but the result already converged to some value and this does not answer my problem.</p>