Using the bshazard()
, I can plot a hazard curve as follows:
# Model Fit
fit <- bshazard(Surv(enter, exit, event) ~ 1, df)
# Plot
df_surv <- data.frame(time = fit$time, hazard = fit$hazard,
lower.ci = fit$lower.ci, upper.ci = fit$upper.ci)
ggplot(df_surv, aes(x = time, y = hazard)) +
geom_line() +
geom_ribbon(aes(ymin = lower.ci, ymax = upper.ci), alpha = 0.5)
How do I get a similar plot using a coxme
model like the following?
fit <- coxme(Surv(exit, event) ~ sex + (1 | id), df)