# [R] Can mice() handle crr()? Fine-Gray model

Therneau, Terry M., Ph.D. therneau at mayo.edu
Mon Jan 23 15:46:31 CET 2017

```Look at the finegray command within the survival package; the competing risks vignette has
coverage of it.  The command creates an expanded data set with case weights, such that
coxph() on the new data set = the Fine Gray model for the original data.  Anything that
works with coxph is valid on the new data.  Caveat -- I don't know mice() well at all: the
dat1 data set below has multiple observations per subject, should the mice() command be
cognizant of this?

Terry Therneau

library(survival)
library(mice)

test1 <- data.frame (time=c(4,3,1,1,2,2,3,5,2,4,5,1,
4,3,1,1,2,2,3,5,2,4,5,1),
status=c(1,1,1,0,2,2,0,0,1,1,2,0,
1,1,1,0,2,2,0,0,1,1,2,0),
x=c(0,2,1,1,NA,NA,0,1,1,2,0,1,
0,2,1,1,NA,NA,0,1,1,2,0,1),
sex=c(0,0,0,NA,1,1,1,1,NA,1,0,0,
0,0,0,NA,1,1,1,1,NA,1,0,0)))

# Endpoint 1, simple, then with mice
fit0 <- copxh(Surv(time, status==1) ~ sex + x, test1)
dat0 <- mice(test1, m=10)
mfit0 <- with(dat0, coxph(Surv(time, status==1) ~ sex + x))
summary(pool(mfit0))

# Endpoint 1, Fine-Gray model
fg1 <- finegray(Surv(time, factor(status)) ~ ., data=test1, etype=1)
fit1 <- coxph(Surv(fgstart, fgstop, fgstatus) ~ sex + x, data=fg1,
weight= fgwt)

dat1 <- mice(fg1, m=10)
mfit1 <- with(dat1, coxph(Surv(fgstart, fgstop, fgstatus) ~ sex + x,
weight=fgwt))

On 01/23/2017 05:00 AM, r-help-request at r-project.org wrote:
> Here is an example:
>
>
> # example
>
> library(survival)
> library(mice)
> library(cmprsk)
>
> test1 <- as.data.frame(list(time=c(4,3,1,1,2,2,3,5,2,4,5,1,
> 4,3,1,1,2,2,3,5,2,4,5,1),
>                              status=c(1,1,1,0,2,2,0,0,1,1,2,0,
> 1,1,1,0,2,2,0,0,1,1,2,0),
>                              x=c(0,2,1,1,NA,NA,0,1,1,2,0,1,
> 0,2,1,1,NA,NA,0,1,1,2,0,1),
>                              sex=c(0,0,0,NA,1,1,1,1,NA,1,0,0,
> 0,0,0,NA,1,1,1,1,NA,1,0,0)))
>
> dat <- mice(test1,m=10)
>
> #Cox regression: cause 1
>
> models.cox1 <- with(dat,coxph(Surv(time, status==1) ~ x +sex
> ))
>
> summary(pool(models.cox1))
>
> #Cox regression: cause 1 or 2
>
> models.cox <- with(dat,coxph(Surv(time, status==1 | status==2) ~ x +sex
> ))
> models.cox
> summary(pool(models.cox))
>
>
> # crr()
>
> #Fine-Gray model
>
> models.FG<- with(dat,crr(ftime=time, fstatus=status,  cov1=test1[,c(
> "x","sex")], failcode=1, cencode=0, variance=TRUE))
>
> summary(pool(models.FG))
>
> #Error in pool(models.FG) : Object has no vcov() method.
>
> models.FG
>
>
>
>
> -- Andreu Ferrero Gregori

```