I'm wondering whether the pool()
function from R's mice
package correctly pools shared frailty models fitted on multiply imputed datasets using coxme()
. See the following example:
# needed to tidy the coxme object
install.packages("remotes"); remotes::install_github("junkka/ehahelper")
# assuming the following packages are installed
library(survival)
library(coxme)
library(mice)
library(eha)
library(ehahelper)
set.seed(1234)
# prepare the dataframe by adding a cluster id
df <- stanford2
df$cid <- round(df$id / 10) + 1
head(df)
# impute, fit and pool
imp <- mice(df, print = FALSE)
fit <- with(imp, coxme(Surv(time, status) ~ age + t5 + (1 | cid)))
fit1 <- pool(fit)
# check the p values
summary(fit1, exponentiate = TRUE, conf.int = TRUE)
# term estimate std.error statistic df p.value 2.5 % 97.5 %
#1 age 1.029322 0.01064437 2.7150698 0.4995043 0.3856764 1.769147e-01 5.988783e+00
#2 t5 1.182635 0.18427536 0.9102967 0.4442556 0.6418694 1.210586e-26 1.155330e+26
The p values and confidence intervals seem overly large, and I suspect that pool()
might not handle multiple coxme
objects correctly (i.e. performs "Wald tests" with adjusted degrees of freedom). If I fill the pooled parameter estimates into a "template" coxme
object and let the summary()
function calculate the usual z and p values then the results look more sensible to me:
# create a template fit (e.g. by fitting the same frailty model on complete cases)
fit0 <- coxme(Surv(time, status) ~ age + t5 + (1 | cid), data = df)
# copy parameter estimates from the pooled fit into the template fit object
vec <- fit1$pooled$estimate
names(vec) <- fit1$pooled$term
fit0$coefficients <- vec
# the same for the pooled estimates of the variances
vec <- fit1$pooled$t
names(vec) <- fit1$pooled$term
fit0$variance <- diag(vec)
# check the p values again, and compare with those above
summary(fit0)
# coef exp(coef) se(coef) z p
#age 0.0289002 1.029322 0.01064437 2.72 0.0066
#t5 0.1677452 1.182635 0.18427536 0.91 0.3600
Questions:
- Is it correct to perform Wald tests with pooled estimates and pooled standard errors?
- If not, what would be the correct way to pool
coxme
objects? Does anyone know of an R function or some code snippet to achieve this?
Thank you for your inputs!