I have created a mixed effects cox regression using coxme.
Q1) I would like to plot the coefficients of the fixed effects in an adjusted survival curve. However, it seems this functionality in packages like survminer is only possible for coxph objects without a frailty term.
Is there anyway that this could be calculated and plotted manually in R instead?
I have the below model for demonstration purposes:
library(survival)
library(coxme)
kidney <- data.frame(kidney)
coxme <- coxme(Surv(time, status) ~ age + sex + (1|disease),
data = kidney)
Q2) Additionally, is there anyway that this could be plotted for a time interaction (tt() in coxph)?
For instance with the model:
library(survival)
kidney <- data.frame(kidney)
coxph.me <- coxph(Surv(time, status) ~ age + sex + tt(sex) + frailty(disease),
data = kidney,
tt=function(x,t,...) x*t)
Thanks in advance
The most popular way to obtain adjusted survival curves from a model is g-computation, which requires a function to make predictions for survival probabilities at t given a vector of covariates and t. Unfortunately, the
coxmefunction does not naturally support such predictions, e.g. there is nopredict.coxmefunction included in the package.You can, however, use the
adjustedCurvespackage in conjunction with theriskRegressionpackage to get what you want if you switch fromcoxmeto a standardcoxphmodel with afrailty()term. Below I give an example on how this could be done. It is a little hacky because of a bug inriskRegressionbut it works just fine.If you need confidence intervals as well, you can obtain those using bootstrapping by changing the code a little bit (note that this may take a while, especially if you have lots of data).
None of this works with a
tt()term in the model formula though.