Reputation: 11
Recently, I learnt about DynNom function which allows one to generate a dynamic nomogram. When I attempted to generate a dynamic nomogram from a Cox model allowing for time varying coefficient after using the survSplit function, an error reading “start/stop notation not supported”.
Below is a sample dataset and code to replicate the error.
# Load necessary libraries
library(survival)
library(rms)
library(DynNom)
# Example: Simulated dataset
set.seed(123)
n <- 200
data <- data.frame(
id = 1:n,
age = rnorm(n, 60, 10), # Age as a covariate
sex = sample(c(0, 1), n, replace = TRUE), # Sex as a binary covariate
start = 0,
stop = rexp(n, rate = 0.1), # Random survival times
event = sample(c(0, 1), n, replace = TRUE) # Random event indicator
)
# Split dataset to incorporate time-varying covariates
data_split <- survSplit(
Surv(start, stop, event) ~ .,
data = data,
cut = quantile(data$stop, probs = c(0.25, 0.5, 0.75)), # Time split points
episode = "time_period" # New variable for time periods
)
# Cox model with time-varying coefficients
cox_model <- coxph(
Surv(start, stop, event) ~ age + sex + time_period:age + time_period:sex,
data = data_split
)
# I tried the code below
# Dynamic nomogram
dd <- datadist(data_split)
options(datadist = "dd")
dyn_nom <- DynNom(cox_model, data_split)
And an error note above was returned.
Any suggestions about how a dynamic nomogram can be generated with data from survSplit?
Thank you very much for your time.
Upvotes: 1
Views: 26