How to calculate the survival function in R for a glmnet cox family? - Cross Validated most recent 30 from stats.stackexchange.com 2019-09-16T04:32:30Z https://stats.stackexchange.com/feeds/question/401965 https://creativecommons.org/licenses/by-sa/4.0/rdf https://stats.stackexchange.com/q/401965 2 How to calculate the survival function in R for a glmnet cox family? Faiz Yusufi https://stats.stackexchange.com/users/243940 2019-04-09T07:23:16Z 2019-04-09T09:36:18Z <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. Cox regression was giving non significant results for all the variables so elastic net regression specified for a cox family was applied. 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 <code>RS = B1*X1 + B2*X2 + ... + Bn*Xn</code>. 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> <ol> <li><p>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></li> <li><p>Which formula is the better choice to use? I can't find any background on the formula developed by Yang et al.</p></li> </ol> <p>Any help will be highly appreciated.</p>