A error in drawing nomogram for multivariate cox regression with rms package
1
0
Entering edit mode
2.3 years ago
Dude • 0

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 • 2.0k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
2.3 years ago
Dude • 0

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!

ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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)

ADD REPLY

Login before adding your answer.

Traffic: 2658 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6