How to plot hazard function for coxme object?

125 Views Asked by At

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)

this

How do I get a similar plot using a coxme model like the following?

fit <- coxme(Surv(exit, event) ~ sex + (1 | id), df)
0

There are 0 best solutions below