library(rms)
library(survival)
data(cancer)
myformula <- Surv(time, status) ~ ph.karno + ph.ecog + rcs(age, 3)*sex
model <- cph(myformula , data = lung )
myHR <- rcsHR( var2values = 40:80
, model = model , data = lung , var1 ="sex", var2="age"
, ci=TRUE , conf = 0.95 , ci.method = "delta")
plotINT(myHR , ylab = "HR of male VS female" , xlab = "Age")
Run the code above in your browser using DataLab