# How to calculate the survival function in R for a glmnet cox family?

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:

library(survival)
library(glmnet)
y<-Surv(time,status)
x<- cbind(Age,Sex,Tobacco,Alcohol,Energy,HbA1c...)
y<-Surv(time,status)
fit<-glmnet(x,y,family="cox",alpha=0.5)
coef(fit)


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. Molnar et al. (2017) used the formula "1 - S(5)EXP[RS]" and Yang et al. (2007) used the formula "1 - S(5)EXP[RS - mean of RS]".

My questions are:

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?

2. Which formula is the better choice to use? I can't find any background on the formula developed by Yang et al.

Any help will be highly appreciated.