This is a test version of Biostars. For the public version, visit https://www.biostars.org.
A error in drawing nomogram for multivariate cox regression with rms package

I kept getting the following error when i tried to draw a nomogram with rms package:

Error in lims[[i]] : subscript out of bounds

I've eliminated all the missing data from the dataset and transformed all the variables into continuous variables, but nothing really changed. I'd appreciate it if my question is answered.

regression nomogram. r cox rms

Please improve your post by adding your code and example of your data. As it stands we can't help you.

Oh sorry, I just uploaded the code and data you might need. Thank you so much!!

1 answer

The code I used is listed below:

fit_cox <- coxph(Surv(surviving_days,vital == 1) ~ gender + ajcc_pathologic_stage + risk_factor, data = clinical)
fit_cox <- rms::cph(Surv(surviving_days,vital == 1) ~ gender + stages + risk_factor, data = clinical)
summary(fit_cox)
Survival1 <- function(x)Survival(365, x)
Survival2 <- function(x)Survival(730, x)
nomo <- nomogram(fit_cox, fun = list(Survival1, Survival2),
                 fun.at = c(0.05,  seq(0.1, 0.9, by = 0.05), 0.95),
                 funlabel = c("1 year survival", "2 year survival"))
plot(nomo)

the data to construct fit_cox was uploaded in the link below:

https://github.com/Datapioneer/Question.git

thank you!

When calling rms() you indicated stages wheras there is only a variable called ajcc_pathologic_stage

Yes, I just noticed it. But when I fit cox model with the corrected rms::cph() command, there was no error message, but when I ran the command "summary(fit_cox)", I got amessage like this :

Error in summary.rms(fit_cox) : adjustment values not defined here or with datadist for gender ajcc_pathologic_stage risk_factor

and then I kept running down to the "nomogram()" function, and I got a message like this:

Error in value.chk(at, i, NA, -nint, Limval, type.range = "full") :
variable gender does not have limits defined by datadist

Another question is there any problem with fitting the model with "coxph()" function? I always get the message of "Error in lims[[i]] : subscript out of bounds" when running nomogram.

Thank you.

Hi it might be late to answer, but add surv = T inside rms::cph(), and it should run fine then : like:

fit_cox <- rms::cph(Surv(surviving_days,vital == 1) ~ gender + stages + risk_factor, data = clinical, surv = T)

Log in to answer this question.