harrelfe / rms

Regression Modeling Strategies
https://hbiostat.org/R/rms
Other
170 stars 48 forks source link

rexVar in survival model (cph) #138

Open lijiaqi-github opened 8 months ago

lijiaqi-github commented 8 months ago

Dear Prof. Harrell,

I am trying to assess the prediction improvement after adding a new biomarker, and trying to implement an analysis you recommended using rexVar function "Relative Explained Variation".

However, I met a error after running this function (Error in A %*% B : non-conformable arguments. I made a simple example to reappear this error. Did I make a mistake in coding?

n <- 1000   
set.seed(1234) 
age                   <- rnorm(n, 50, 10)
blood.pressure <- rnorm(n, 120, 15)
cholesterol        <- rnorm(n, 200, 25)
time           <- runif(n, 1, 15)
status         <- round(age/100,0)
d <- data.table(age,blood.pressure,cholesterol,time,status)

model_M1 <-
    cph(
        Surv(time, status) ~ rcs(age, 3) * rcs(blood.pressure, 3),
        x = TRUE,
        y = TRUE,
        data = d
    )
#  error also occurs in the following model
# model_M1 <-
#     cph(
#         Surv(time, status) ~ age + blood.pressure,
#         x = TRUE,
#         y = TRUE,
#         data = d
#     )

g <- bootcov(model_M1, B=20)
rexVar(g, data=d)
lijiaqi-github commented 8 months ago

This issue has been solved by Professor Harrell, Thank you for your quick response.