2
$\begingroup$

The problem: I am hoping to visualise interaction effects between a continuous and a dichotomous variable from a cox proportional hazard regression. When graphing this with different packages (visreg and rms:ggplot(Predict()), I got bafflingly different looking graphs. What did I miss in these two approaches that generated this disagreement?

Also when I am plotting for hazard ratio (with fun=exp), I am not getting the reference point with the narrowed confidence band as suggested in this discussion ( Different prediction plot from survival coxph and rms cph) (what did I miss here?).

Example:

# Load libs library(survival) library(rms) library(visreg) # Regular survival survobj <- with(lung, Surv(time,status)) # Prepare the variables lung$sex <- factor(lung$sex, levels=1:2, labels=c("Male", "Female")) label(lung$sex) <- "Sex" label(lung$age)<- "Age" # The rms survival ddist <- datadist(lung) options(datadist="ddist") rms_surv_fit <- cph(survobj~rcs(age, 4)*sex, data=lung, x=T, y=T) p <- Predict(rms_surv_fit, age=seq(50, 70, times=20), sex=c("Male", "Female"), fun=exp) ggplot(Predict(rms_surv_fit, age , sex)) 

Gives this plot Gives this plot

To plot the hazard ratio (where I am expecting a reference point)

ggplot(Predict(rms_surv_fit, age , sex, fun=exp)) 

Hazard ratio plot

# visreg coxph_fit <-coxph(survobj~rcs(age, 4)*sex, data=lung) visreg(coxph_fit, 'age', by='sex', overlay=T, partial=F, band=T, ylim=c(-3, 3) ) 

Gives very different graphs compared to above two:

which graphed the following (very different lines as well as confidence intervals

I came across suggestions that the meaning of above conditional plot is likely questionable since baseline hazard is not estimated - a contrast plot is herhaps more appropriate as graphed below:

I came across suggestions that the meaning of above conditional plot is likely questionable since baseline hazard is not estimated; Thus a contrast plot is graphed as below:

visreg(coxph_fit, 'age', by='sex', overlay=T, partial=F, type='contrast' ) 
$\endgroup$

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.