Marginal modelling of clustered survival data

Overview

A basic component for our modelling of multivariate survival data is that many models are build around marginals that on Cox form. The marginal Cox model can be fitted efficiently in the mets package, in particular the handling of strata and robust standard errors is optimized.

The basic models assumes that each subject has a marginal on Cox-form λg(k, i)(t)exp (XkiTβ). where g(k, i) gives the strata for the subject.

We here discuss and show how to get robust standard errors of

  • the regression parameters

  • the baseline

and how to do goodness of fit test using

  • cumulative residuals score test

First we generate some data from the Clayton-Oakes model, with 5 members in each cluster and a variance parameter at 2

 library(mets)
 options(warn=-1)
 set.seed(1000) # to control output in simulatins for p-values below.
 n <- 1000
 k <- 5
 theta <- 2
 data <- simClaytonOakes(n,k,theta,0.3,3)

The data is on has one subject per row.

  • time : time of event
  • status : 1 for event and 0 for censoring
  • x : x is a binary covariate
  • cluster : cluster

Now we fit the model and produce robust standard errors for both regression parameters and baseline.

First, recall that the baseline for strata g is asymptotically equivalent to with Pg(t) = ∫0tEg(s)dΛ̂g(s) the derivative of 0t1/S0, g(s)dNg wrt to β, and with the basic 0-mean processes, that are martingales in the iid setting, and I(t) is the derivative of the total score, (t, β)), with respect to β evaluated at time t.

The variance of the baseline of strata g is estimated by that can be computed using the particular structure of

This robust variance of the baseline and the iid decomposition for β is computed in mets as:

   out <- phreg(Surv(time,status)~x+cluster(cluster),data=data)
   summary(out)
#> 
#>     n events
#>  5000   4854
#> coeffients:
#>   Estimate     S.E.  dU^-1/2 P-value
#> x 0.287859 0.028177 0.028897       0
#> 
#> exp(coeffients):
#>   Estimate   2.5%  97.5%
#> x   1.3336 1.2619 1.4093
   # robust standard errors attached to output
   rob <- robust.phreg(out)

We can get the iid decomposition of the β̂ − β by

   # making iid decomposition of regression parameters
   betaiid <- IC(out)
   head(betaiid)
#>                x
#> [1,] -0.34616008
#> [2,] -1.44918926
#> [3,] -0.03898156
#> [4,]  0.42156050
#> [5,]  0.34253904
#> [6,] -0.07706668
   # robust standard errors
   crossprod(betaiid/NROW(betaiid))^.5
#>            x
#> x 0.02817714
   # same as 

We now look at the plot with robust standard errors

  bplot(rob,se=TRUE,robust=TRUE,col=3)

We can also make survival prediction with robust standard errors using the phreg.

  pp <-  predict(out,data[1:20,],se=TRUE,robust=TRUE)
  plot(pp,se=TRUE,whichx=1:10)

Finally, just to check that we can recover the model we also estimate the dependence parameter

tt <- twostageMLE(out,data=data)
summary(tt)
#> Dependence parameter for Clayton-Oakes model
#> Variance of Gamma distributed random effects
#> $estimates
#>                 Coef.         SE        z P-val Kendall tau        SE
#> dependence1 0.5316753 0.03497789 15.20032     0   0.2100093 0.0109146
#> 
#> $type
#> NULL
#> 
#> attr(,"class")
#> [1] "summary.mets.twostage"

Goodness of fit

The observed score process is given by where g is strata g(k, i). The observed score has the iid decomposition where βk is the iid decomposition of the score process for the true β and I(t) is the derivative of the total score, (t, β)), with respect to β evaluated at time t.

This observed score can be resampled given it is on iid form in terms of clusters.

Now using the cumulative score process for checking proportional hazards

gout <- gof(out)
gout
#> Cumulative score process test for Proportionality:
#>   Sup|U(t)|  pval
#> x  30.24353 0.401

The p-value reflects wheter the observed score process is consistent with the model.

  plot(gout)

Computational aspects

The score processes can be resampled as in Lin, Wei, Ying (1993) using the martingale structure, such that the observed score process is resampled by where gki are i.i.d. standard normals.

Based on the zero mean processes we more generally with clusters can resample the score process. For resampling of score process we need where g is strata. We write gk as gki and thus repeating gk within each cluster.

Computations are done using that therefore and summing the compensator part with the gki multipliers then gives for each strata g with

Cluster stratified Cox models

For clustered data it is possible to estimate the regression coefficient within clusters by using Cox’s partial likelihood stratified on clusters.

Note, here that the data is generated with a different subject specific structure, so we will not recover the β at 0.3 and the model will not be a proportional Cox model, we we would also expect to reject “proportionality” with the gof-test.

The model can be thought of as λg(k, i)(t)exp (XkiTβ) where λg(t) is some cluster specific baseline.

The regression coefficient β can be estimated by using the partial likelihood for clusters.

 out <- phreg(Surv(time,status)~x+strata(cluster),data=data)
 summary(out)
#> 
#>     n events
#>  5000   4854
#> coeffients:
#>   Estimate     S.E.  dU^-1/2 P-value
#> x 0.406307 0.032925 0.039226       0
#> 
#> exp(coeffients):
#>   Estimate   2.5%  97.5%
#> x   1.5013 1.4074 1.6013

SessionInfo

sessionInfo()
#> R version 4.4.2 (2024-10-31)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] mets_1.3.4     timereg_2.0.6  survival_3.7-0 rmarkdown_2.29
#> 
#> loaded via a namespace (and not attached):
#>  [1] cli_3.6.3           knitr_1.49          rlang_1.1.4        
#>  [4] xfun_0.49           jsonlite_1.8.9      listenv_0.9.1      
#>  [7] future.apply_1.11.3 buildtools_1.0.0    lava_1.8.0         
#> [10] htmltools_0.5.8.1   maketools_1.3.1     sys_3.4.3          
#> [13] sass_0.4.9          grid_4.4.2          evaluate_1.0.1     
#> [16] jquerylib_0.1.4     fastmap_1.2.0       mvtnorm_1.3-2      
#> [19] yaml_2.3.10         lifecycle_1.0.4     numDeriv_2016.8-1.1
#> [22] compiler_4.4.2      codetools_0.2-20    ucminf_1.2.2       
#> [25] Rcpp_1.0.13-1       future_1.34.0       lattice_0.22-6     
#> [28] digest_0.6.37       R6_2.5.1            parallelly_1.39.0  
#> [31] parallel_4.4.2      splines_4.4.2       bslib_0.8.0        
#> [34] Matrix_1.7-1        tools_4.4.2         globals_0.16.3     
#> [37] cachem_1.1.0