title: How to calculate the survival function in R for a glmnet cox family?
body: <p>I have a sample data of 583 type 2 diabetes patients and want to calculate the 5 year incidence probability of an event for every patient. Variables which were collected are time to an event variable censored at 5 years, event status and 38 independent parameters.  </p>
  
  <p>Cox regression was giving non significant results for all the variables so elastic net regression specified for a cox family was applied.</p>
  
  <p>The following commands in R were used:</p>
  
  <pre><code>library(survival)
  library(glmnet)
  
  y&lt;-Surv(time,status)
  x&lt;- cbind(Age,Sex,Tobacco,Alcohol,Energy,HbA1c...)
  y&lt;-Surv(time,status)
  
  fit&lt;-glmnet(x,y,family="cox",alpha=0.5)
  
  coef(fit)
  </code></pre>
  
  <p>After obtaining the beta coefficients, the risk score (RS) is determined from RS = B1*X1 + B2*X2 + ... + Bn*Xn. Next, I want to calculate the 5 year probability of the event. <a href="https://journals.lww.com/transplantjournal/fulltext/2017/06000/Predictive_Score_for_Posttransplantation_Outcomes.33.aspx" rel="nofollow noreferrer">Molnar et al. (2017)</a> used the formula "1 - S(5)EXP[RS]" and <a href="http://care.diabetesjournals.org/content/30/1/65.long" rel="nofollow noreferrer">Yang et al. (2007)</a> used the formula "1 - S(5)EXP[RS - mean of RS]".</p>
  
  <p>My questions are:</p>
  
  <p>1) How to calculate the survival function S(t) after applying glmnet? Is survfit command an option? Yang et al. states that S(t) is the survival function over t years when the risk score takes the value of its mean. How can this be determined?</p>
  
  <p>2) Which formula is the better choice to use? I can't find any background on the formula developed by Yang et al.</p>
  
  <p>Any help will be highly appreciated.</p>