I am using the "smart" dataset from the package "hdnom". Below mentioned is my code. I get the following error. Please let me know where I am going wrong. I am unable to understand the error.
Error in nomogram(fit, model.type = "aenet", x, time, event, x.df, lambda = lambda, : factor name(s) not in the design: model.type x time event x.df lambda pred.at
data("smart")
summary(smart)
dim(smart)
x = as.matrix(smart[,-c(1,2)])
str(x)
time = smart$TEVENT
#time <- as.numeric(time)
event = smart$EVENT
library(survival)
y = Surv(time, event)
suppressMessages(library(doParallel))
registerDoParallel(detectCores())
aenetfit = fit_aenet(x, y, nfolds = 10, rule = "lambda.1se",
seed = c(5, 7), parallel = TRUE)
names(aenetfit)
fit = aenetfit$model_init
alpha = aenetfit$alpha_init
lambda = aenetfit$lambda_init
adapen = aenetfit$pen_factor
suppressMessages(library("rms"))
x.df = as.data.frame(x)
dd = datadist(x.df)
options(datadist = "dd")
nom = nomogram(fit, model.type = "aenet", x, time, event, x.df,lambda = lambda, pred.at = 365 * 2,funlabel = "2-Year Overall Survival Probability")
In version 4.0
and 5.0
of hdnom
the function hdnom.nomogram
was available, as documented here and here. The syntax was:
nom <- hdnom.nomogram(fit, model.type = "aenet", x, time, event, x.df,
lambda = lambda, pred.at = 365 * 2,
funlabel = "2-Year Overall Survival Probability")
In version 6.0
this function was replaced by hdnom::as_nomogram
:
nom <- as_nomogram(aenetfit, x, time, event, pred.at = 365 * 2,
funlabel = "2-Year Overall Survival Probability")
plot(nom)
From the help of rms::nomogram
: this function accepts as input (the fit
argument) only regression models that were created with rms
; in addition, model.type
and lambda
are not valid arguments of this function.