tuneCOXen | R Documentation |
This function finds the optimal lambda and alpha parameters for an elastic net Cox regression.
tuneCOXen(times, failures, group=NULL, cov.quanti=NULL, cov.quali=NULL,
data, cv=10, parallel=FALSE, alpha, lambda,seed=NULL)
times |
The name of the variable related the numeric vector with the follow-up times. |
failures |
The name of the variable related the numeric vector with the event indicators (0=right censored, 1=event). |
group |
The name of the variable related to the exposure/treatment. This variable shall have only two modalities encoded 0 for the untreated/unexposed patients and 1 for the treated/exposed ones. The default value is |
cov.quanti |
The name(s) of the variable(s) related to the possible quantitative covariates. These variables must be numeric. |
cov.quali |
The name(s) of the variable(s) related to the possible qualitative covariates. These variables must be numeric with two levels: 0 and 1. A complete disjunctive form must be used for covariates with more levels. |
data |
A data frame for training the model in which to look for the variables related to the status of the follow-up time ( |
cv |
The value of the number of folds. The default value is 10. |
parallel |
If |
alpha |
The values of the regularization parameter alpha optimized over. |
lambda |
The values of the regularization parameter lambda optimized over. |
seed |
A numeric value for random seed for reproducibility. The default is |
The function runs the cv.glmnet
function of the glmnet
package and the glmnet_basesurv
function of the hdnom
package.
optimal |
The value of lambda that gives the minimum mean deviance. |
results |
The data frame with the mean deviance for each lambda values. |
Simon, N., Friedman, J., Hastie, T. and Tibshirani, R. (2011) Regularization Paths for Cox's Proportional Hazards Model via Coordinate Descent, Journal of Statistical Software, Vol. 39(5), 1-13, https://www.jstatsoft.org/v39/i05/
data(dataDIVAT2)
tune.model <- tuneCOXen(times="times", failures="failures", data=dataDIVAT2,
cov.quanti=c("age"), cov.quali=c("hla", "retransplant", "ecd"), cv=5,
alpha=seq(.1, 1, by=.1), lambda=seq(.1, 1, by=.1),seed=42)
tune.model$optimal$lambda # the estimated lambda value
# The estimation of the training modelwith the corresponding lambda value
model <- LIB_COXen(times="times", failures="failures", data=dataDIVAT2,
cov.quanti=c("age"), cov.quali=c("hla", "retransplant", "ecd"),
alpha=tune.model$optimal$alpha,
lambda=tune.model$optimal$lambda)
# The resulted predicted survival of the first subject of the training sample
plot(y=model$predictions[1,], x=model$times, xlab="Time (years)",
ylab="Predicted survival", col=1, type="l", lty=1, lwd=2, ylim=c(0,1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.