Dear all, I have the following problem:
I want to plot the "effetc" of a continuous variable in a cox regression model.
The code below is an example.
Per default, the median (?) of a continuous variable is selected. However, I want to change the reference value (48.80065 in this example) to any other value (e.g. 40 or 60 in this example).
How can I do this?
Thank you so much!
library(rms)
n <- 1000
set.seed(731)
age <- 50 + 12*rnorm(n)
label(age) <- "Age"
sex <- factor(sample(c('Male','Female'), n,
rep=TRUE, prob=c(.6, .4)))
cens <- 15*runif(n)
h <- .02*exp(.04*(age-50)+.8*(sex=='Female'))
dt <- -log(runif(n))/h
label(dt) <- 'Follow-up Time'
e <- ifelse(dt <= cens,1,0)
dt <- pmin(dt, cens)
units(dt) <- "Year"
dd <- datadist(age, sex)
options(datadist='dd')
dd # showing the reference value??
S <- Surv(dt,e)
f <- cph(S ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
plot(Predict(f, age, sex)) # plot age effect, 2 curves for 2 sexes