considered \[\begin{align*} U^{FG}_{n}(\beta) = \sum_{i=0}^{n} \int_0^{+\infty} \left( X_i- E_n(t,\beta) \right) w_i(t,X_i) dN_{1,i}(t) \text{ where } E_n(t,\beta)=\frac{\tilde S_1(t,\beta) }{\tilde S_0(t,\beta)}, \end{align*}\] with \(w_i(t,X_i) = \frac{G_c(t,X_i)}{G_c(T_i \wedge t,X_i)} I( C_i > T_i \wedge t )\) ,\(\tilde S_k(t,\beta) = \sum_{j=1}^n X_j^k \exp(X_j^T\beta) Y_{1,j}(t)\) for \(k=0,1\), and with with \(\tilde Y_{1,i}(t) = Y_{1,i}(t) w_i(t,X_i)\) for \(i=1,...,n\). \(w_i(t)\) needs to be replaced by an estimator of the censoring distribution, and since it does not depend on \(X\) the \(\hat w_i(t) = \frac{\hat G_c(t,X_i)}{\hat G_c(T_i \wedge t,X_i)} I(C_i > T_i \wedge t)\) where \(\hat G_c\) is the Kaplan-Meier estimator of the censoring distribution.
In this article we briefly introduce some functions for doing cumulative incidence regression, and how to augment the Fine-Gray estimator.
First we simulate some competing risks data using some utility functions.
We simulate data with two causes based on the Fine-Gray model: \[\begin{align} F_1(t,X) & = P(T\leq t, \epsilon=1|X)=( 1 - exp(-\Lambda_1(t) \exp(X^T \beta_1))) \\ F_2(t,X) & = P(T\leq t, \epsilon=2|X)= ( 1 - exp(-\Lambda_2(t) \exp(X^T \beta_2))) \cdot (1 - F_1(\infty,X)) \end{align}\] where the baselines are given as \(\Lambda_j(t) = \rho_j (1- exp(-t/\nu_j))\) for \(j=1,2\), and the \(X\) being two independent binomials. Alternatively, one can also replace the FG-model with a logistic link \(\mbox{expit}( \Lambda_j(t) + \exp(X^T \beta_j))\).
The advantage of the model is that it is easy to fit and to get standard errors, and that it is quite flexible essentially being a Cox-model. On the downside is that the coefficients are quite hard to interpret since they are the \(cloglog\) coefficients of \(1-F_1(t,X)\). Specifically, \[\begin{align} \log(-\log( 1-F_1(t,X_1+1,X_2))) - \log(-\log( 1-F_1(t,X_1,X_2))) & = \beta_1, \end{align}\] so the effect is \(\beta_1\) of \(X_1\) is on \(1-F_1(t,X)\) on the \(cloglog\) scale.
library(mets)
options(warn=-1)
set.seed(1000) # to control output in simulatins for p-values below.
<- 0.2; rho2 <- 10
rho1 <- 4000
n =c(0.0,-0.1,-0.5,0.3)
beta## beta1=c(0.0,-0.1); beta2=c(-0.5,0.3)
<- simul.cifs(n,rho1,rho2,beta,rc=0.5,rate=7)
dats dtable(dats,~status)
#>
#> status
#> 0 1 2
#> 1184 147 2669
dsort(dats) <- ~time
We have a look at the non-parametric cumulative incidence curves
par(mfrow=c(1,2))
<- cif(Event(time,status)~strata(Z1,Z2),dats,cause=1)
cifs1 plot(cifs1)
<- cif(Event(time,status)~strata(Z1,Z2),dats,cause=2)
cifs2 plot(cifs2)
Now fitting the Fine-Gray model
<- cifreg(Event(time,status)~Z1+Z2,data=dats,cause=1,propodds=NULL)
fg summary(fg)
#>
#> n events
#> 4000 147
#>
#> 4000 clusters
#> coeffients:
#> Estimate S.E. dU^-1/2 P-value
#> Z1 0.068822 0.081846 0.082637 0.4004
#> Z2 -0.368080 0.166064 0.167404 0.0267
#>
#> exp(coeffients):
#> Estimate 2.5% 97.5%
#> Z1 1.07125 0.91248 1.2576
#> Z2 0.69206 0.49979 0.9583
<- expand.grid(Z1=c(-1,1),Z2=0:1)
dd <- predict(fg,dd)
pfg plot(pfg,ylim=c(0,0.2))
The standard errors reported for the FG-estimator are based on the i.i.d decompostion (influence functions) of the estimator that we give later. A similar decompostion exist for the baseline and is needed when standard errors of predictions are computed. These are a bit harder to compute for all time-points simultaneously, but they can be obtained for specific timepoints jointly with the iid decomposition of the regression coefficients and then used to get standard errors for predictions.
We here plot the predictions with jittered confidence intervals for the predictions at time point 5
### predictions with CI based on iid decomposition of baseline and beta
<- cifreg(Event(time,status)~Z1+Z2,data=dats,cause=1,propodds=NULL,cox.prep=TRUE)
fg <- mets:::iid.baseline.cifreg(fg,time=5)
Biid <- FGprediid(Biid,dd)
pfgse
pfgse#> pred se-log lower upper
#> [1,] 0.08951308 0.1409136 0.06791108 0.11798651
#> [2,] 0.10202580 0.1328646 0.07863493 0.13237456
#> [3,] 0.06283755 0.1518146 0.04666534 0.08461436
#> [4,] 0.07176982 0.1561657 0.05284615 0.09746985
plot(pfg,ylim=c(0,0.2))
for (i in 1:4) lines(c(5,5)+i/10,pfgse[i,3:4],col=i,lwd=2)
The iid decompostions are stored inside Biid, in addition we note that the iid decompostions for \(\hat \beta - \beta_0\) are obtained by the command iid()
We compare with the cmprsk function but without running it to avoid dependencies:
<- 0
run if (run==1) {
library(cmprsk)
<- model.matrix(~Z1+Z2,dats)[,-1]
mm <- with(dats,crr(time,status,mm))
cr cbind(cr$coef,diag(cr$var)^.5,fg$coef,fg$se.coef,cr$coef-fg$coef,diag(cr$var)^.5-fg$se.coef)
}# [,1] [,2] [,3] [,4] [,5] [,6]
# Z1 0.06882201 0.08184642 0.06882199 0.08184642 1.398233e-08 -9.805955e-11
# Z2 -0.36807861 0.16606441 -0.36807951 0.16606444 9.045060e-07 -2.529264e-08
if (run==1) {
<- cifreg(Event(time,status)~Z1+Z2,data=dats,cause=1,propodds=NULL,beta=cr$coef,no.opt=TRUE)
fg0 cbind(diag(cr$var)^.5,fg0$se.coef,diag(cr$var)^.5-fg0$se.coef)
}# [,1] [,2] [,3]
# [1,] 0.08184642 0.08184642 -8.975096e-11
# [2,] 0.16606441 0.16606441 -1.091264e-10
Estimates and SE’s are slightly different.
We also remove all censorings from the data to compare the estimates with those based on coxph, and observe that the estimates as well as the standard errors agree
<- dtransform(dats,status=2,status==0)
datsnc dtable(datsnc,~status)
#>
#> status
#> 1 2
#> 147 3853
$id <- 1:n
datsnc$entry <- 0
datsnc<- max(dats$time)+1
max ## for cause 2 add risk interaval
<- subset(datsnc,status==2)
datsnc2 <- transform(datsnc2,entry=time)
datsnc2 <- transform(datsnc2,time=max)
datsnc2 <- rbind(datsnc,datsnc2)
datsncf #
<- cifreg(Event(time,status)~Z1+Z2,data=datsnc,cause=1,propodds=NULL)
cifnc <- coxph(Surv(entry,time,status==1)~Z1+Z2+cluster(id),datsncf,robust=TRUE)
cc cbind(cifnc$coef,cifnc$se.coef, cc$coef, diag(cc$var)^.5)
#> [,1] [,2] [,3] [,4]
#> Z1 0.06785579 0.08251841 0.06785579 0.08251841
#> Z2 -0.37911703 0.16716489 -0.37911703 0.16716489
cbind(cifnc$coef-cc$coef, diag(cc$var)^.5-cifnc$se.coef)
#> [,1] [,2]
#> Z1 1.859624e-15 1.665335e-16
#> Z2 3.452794e-14 -5.828671e-16
the cmprsk gives something slightly-slightly different
if (run==1) {
library(cmprsk)
<- model.matrix(~Z1+Z2,datsnc)[,-1]
mm <- with(datsnc,crr(time,status,mm))
cr cbind(cifnc$coef-cr$coef, diag(cr$var)^.5-cifnc$se.coef)
}# [,1] [,2]
# Z1 1.194188e-10 -6.742754e-11
# Z2 -8.828051e-07 -2.488335e-08
We can improve efficiency and avoid bias by allowing the censoring weights to depend on the covariates
<- cifreg(Event(time,status)~Z1+Z2,data=dats,cause=1,propodds=NULL,
fgcm cens.model=~strata(Z1,Z2))
summary(fgcm)
#>
#> n events
#> 4000 147
#>
#> 4000 clusters
#> coeffients:
#> Estimate S.E. dU^-1/2 P-value
#> Z1 0.069400 0.078569 0.083018 0.3771
#> Z2 -0.282263 0.159823 0.167928 0.0774
#>
#> exp(coeffients):
#> Estimate 2.5% 97.5%
#> Z1 1.07186 0.91889 1.2503
#> Z2 0.75408 0.55128 1.0315
summary(fg)
#>
#> n events
#> 4000 147
#>
#> 4000 clusters
#> coeffients:
#> Estimate S.E. dU^-1/2 P-value
#> Z1 0.068822 0.081846 0.082637 0.4004
#> Z2 -0.368080 0.166064 0.167404 0.0267
#>
#> exp(coeffients):
#> Estimate 2.5% 97.5%
#> Z1 1.07125 0.91248 1.2576
#> Z2 0.69206 0.49979 0.9583
We note that the standard errors are slightly smaller for the more efficient estimator.
The influence functions of the FG-estimator is given by ,
\[\begin{align*}
\phi_i^{FG} & = \int (X_i- e(t)) \tilde w_i(t) dM_{i1}(t,X_i) + \int \frac{q(t)}{\pi(t)} dM_{ic}(t), \\
& = \phi_i^{FG,1} + \phi_i^{FG,2},
\end{align*}\] where the first term is what would be achieved for a known censoring distribution, and the second term is due to the variability from the Kaplan-Meier estimator. Where \(M_{ic}(t) = N_{ic}(t) - \int_0^t Y_i(s) d\Lambda_c (s)\) with \(M_{ic}\) the standard censoring martingale.
The function \(q(t)\) that reflects that the censoring only affects the terms related to cause “2” jumps, can be written as (see Appendix B2) \[\begin{align*} q(t) & = E( H(t,X) I(T \leq t, \epsilon=2) I(C > T)/G_c(T)) = E( H(t,X) F_2(t,X) ), \end{align*}\] with \(H(t,X) = \int_t^{\infty} (X- e(s)) G(s) d \Lambda_1(s,X)\) and since \(\pi(t)=E(Y(t))=S(t) G_c(t)\).
In the case where the censoring weights are stratified (based on \(X\)) we get the influence functions related to the censoring term with \[\begin{align*} q(t,X) & = E( H(t,X) I(T \leq t, \epsilon=2) I(T < C)/G_c(T,X) | X) = H(t,X) F_2(t,X), \end{align*}\] so that the influence function becomes \[\begin{align*} \int (X-e(t)) w(t) dM_1(t,X) + \int H(t,X) \frac{F_2(t,X)}{S(t,X)} \frac{1}{G_c(t,X)} dM_c(t,X). \end{align*}\] with \(H(t,X) = \int_t^{\infty} (X- e(s)) G(s,X) d \Lambda_1(s,X)\).
Rather than using a larger censoring model we can also compute the augmentation term directly and then fit the FG-model based on this augmentation term and do a couple of iterations
<- FG_AugmentCifstrata(Event(time,status)~Z1+Z2+strata(Z1,Z2),data=dats,cause=1,E=fg$E)
fgaugS summary(fgaugS)
#>
#> n events
#> 4000 147
#>
#> 4000 clusters
#> coeffients:
#> Estimate S.E. dU^-1/2 P-value
#> Z1 0.067458 0.077405 0.082633 0.3835
#> Z2 -0.263816 0.155584 0.166147 0.0900
#>
#> exp(coeffients):
#> Estimate 2.5% 97.5%
#> Z1 1.06979 0.91920 1.245
#> Z2 0.76812 0.56623 1.042
<- FG_AugmentCifstrata(Event(time,status)~Z1+Z2+strata(Z1,Z2),data=dats,cause=1,E=fgaugS$E)
fgaugS2 summary(fgaugS2)
#>
#> n events
#> 4000 147
#>
#> 4000 clusters
#> coeffients:
#> Estimate S.E. dU^-1/2 P-value
#> Z1 0.067484 0.077405 0.082633 0.3833
#> Z2 -0.265099 0.155551 0.166160 0.0883
#>
#> exp(coeffients):
#> Estimate 2.5% 97.5%
#> Z1 1.06981 0.91922 1.2451
#> Z2 0.76713 0.56554 1.0406
<- FG_AugmentCifstrata(Event(time,status)~Z1+Z2+strata(Z1,Z2),data=dats,cause=1,E=fgaugS2$E)
fgaugS3 summary(fgaugS3)
#>
#> n events
#> 4000 147
#>
#> 4000 clusters
#> coeffients:
#> Estimate S.E. dU^-1/2 P-value
#> Z1 0.067484 0.077405 0.082633 0.3833
#> Z2 -0.265083 0.155551 0.166160 0.0884
#>
#> exp(coeffients):
#> Estimate 2.5% 97.5%
#> Z1 1.06981 0.91922 1.2451
#> Z2 0.76714 0.56555 1.0406
Again we note slightly smaller standard errors when augmenting the estimator.
The function compute the augmentation term for fixed \(E(t)\) based on the current \(\hat \beta\) \[\begin{align*} U_n^{A} = \sum_{i=1}^n \int_{0}^{+\infty} \frac{F_2(t,X_i)}{S(t,X_i)G_c(t,X_i)} H(t,X_i,E,G_c,\Lambda_1) dM_{ci}(t) \end{align*}\] using working models based on stratification to get \(F_1^s\) and \(F_2^s\) where the strata are given by \(strata()\) in the call. Then fits the FG model so solve the \[\begin{align*} U_n^{A}(\beta_p) + U^{FG}_{n}(\beta) = 0. \end{align*}\]
Then we may iterate to get a solution to the augmented score equation \[\begin{align*} U_n^{A}(\beta_\infty) + U^{FG}_{n}(\beta_\infty) = 0. \end{align*}\]
The censoring model here is one overall Kaplan-Meier.
The influence funtion for the augmented estimator is \[\begin{align*} \int (X-e(t)) w(t) dM_1(t,X) + \int H(t,X) \frac{F_2(t,X)}{S(t,X)} \frac{1}{G_c(t)} dM_c. \end{align*}\] and standard errors are based on this formula.
<- 0.2; rho2 <- 10
rho1 <- 4000
n =c(0.0,-0.1,-0.5,0.3)
beta<- simul.cifs(n,rho1,rho2,beta,rc=0.5,rate=7,type="logistic")
dats dtable(dats,~status)
#>
#> status
#> 0 1 2
#> 1668 159 2173
dsort(dats) <- ~time
The model where \[\begin{align*} \mbox{logit}(F_1(t,X)) & = \alpha(t) + X^T \beta \end{align*}\] that then leads to OR interpretation of the \(F_1\), can also be fitted easily, however, the standard errors are harder to compute and only approximative (assuming that the censoring weights are known) but this gives typically only a small error. In the \({{\bf timereg}}\)-package the model can be fitted using different estimators that are more efficient using different weights but this is much slower.
Fitting the model and getting OR’s
<- cifreg(Event(time,status)~Z1+Z2,data=dats,cause=1)
or summary(or)
#>
#> n events
#> 4000 159
#>
#> 4000 clusters
#> coeffients:
#> Estimate S.E. dU^-1/2 P-value
#> Z1 0.144583 0.082144 0.079903 0.0784
#> Z2 -0.126192 0.163767 0.159062 0.4410
#>
#> exp(coeffients):
#> Estimate 2.5% 97.5%
#> Z1 1.15556 0.98372 1.3574
#> Z2 0.88145 0.63944 1.2150
sessionInfo()
#> R version 4.1.1 (2021-08-10)
#> Platform: x86_64-apple-darwin20.4.0 (64-bit)
#> Running under: macOS Big Sur 11.5.2
#>
#> Matrix products: default
#> BLAS: /usr/local/Cellar/openblas/0.3.17/lib/libopenblasp-r0.3.17.dylib
#> LAPACK: /usr/local/Cellar/r/4.1.1/lib/R/lib/libRlapack.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] mets_1.2.9 lava_1.6.11 timereg_2.0.0 survival_3.2-13
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.7 highr_0.9 bslib_0.2.5.1
#> [4] compiler_4.1.1 jquerylib_0.1.4 tools_4.1.1
#> [7] digest_0.6.27 jsonlite_1.7.2 evaluate_0.14
#> [10] lattice_0.20-44 ucminf_1.1-4 rlang_0.4.11
#> [13] Matrix_1.3-4 yaml_2.2.1 parallel_4.1.1
#> [16] mvtnorm_1.1-2 xfun_0.25 fastmap_1.1.0
#> [19] stringr_1.4.0 knitr_1.33 sass_0.4.0
#> [22] globals_0.14.0 grid_4.1.1 listenv_0.8.0
#> [25] R6_2.5.1 future.apply_1.8.1 parallelly_1.27.0
#> [28] rmarkdown_2.10 magrittr_2.0.1 codetools_0.2-18
#> [31] htmltools_0.5.2 splines_4.1.1 future_1.22.1
#> [34] numDeriv_2016.8-1.1 stringi_1.7.4