# NOT RUN {
library("survival")
library("rms")
# Load imputed SMART data; only use the first 120 samples
data("smart")
x = as.matrix(smart[, -c(1, 2)])[1:120, ]
time = smart$TEVENT[1:120]
event = smart$EVENT[1:120]
y = Surv(time, event)
# Fit Cox model with Mnet penalty
fit = hdcox.mnet(
x, y, nfolds = 3,
gammas = 3, alphas = c(0.3, 0.8),
max.iter = 15000, seed = 1010)
# Prepare data for hdnom.nomogram
x.df = as.data.frame(x)
dd = datadist(x.df)
options(datadist = "dd")
# Generate hdnom.nomogram objects and plot nomogram
nom = hdnom.nomogram(
fit$mnet_model, model.type = "mnet",
x, time, event, x.df, pred.at = 365 * 2,
funlabel = "2-Year Overall Survival Probability")
plot(nom)
# }
Run the code above in your browser using DataLab