The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Introduction to CoxAalenCR

Shikhar Tyagi, Arvind Pandey, Bhupendra Singh, Vrijesh Tripathi

2026-08-20

Overview

The CoxAalenCR package implements the additive-multiplicative Cox-Aalen subdistribution hazard regression model for competing risks data as developed by Li and Long (2019). The package offers:

  1. Flexible covariate modeling: Time-varying non-parametric additive effects via Aalen’s model (Aalen, 1980) and constant multiplicative effects via a Cox proportional hazard model.
  2. Covariate-adjusted censoring weights: Inverse probability of censoring weighting (IPCW) using both Kaplan-Meier weights (Fine and Gray, 1999) and covariate-dependent Cox censoring weights (He et al., 2016; Li and Long, 2019).
  3. Cumulative Incidence Function (CIF) prediction: Pointwise standard errors and confidence intervals based on asymptotic influence functions.
  4. Goodness-of-fit testing: Supremum and Cramer-von Mises resampling tests for evaluating constant vs. time-varying covariate effects.
  5. Monte Carlo simulation: Data generation matching the exact simulation setups in Li and Long (2019).

Model Specification

Let \(T_i = \min(\tilde{T}_i, C_i)\) be the observed time, \(\Delta_i = I(\tilde{T}_i \le C_i)\) the censoring indicator, and \(\varepsilon_i \in \{1, 2\}\) the cause of failure. The subdistribution hazard for cause 1 (the event of interest) is:

\[\lambda_1(t; X, Z) = (\alpha^T(t)X) \exp(\beta^T Z)\]

where: - \(X\) is a \(q \times 1\) vector of additive covariates with time-varying effects \(\alpha(t)\), - \(Z\) is a \(p \times 1\) vector of multiplicative covariates with constant effects \(\beta\).

The cumulative incidence function (CIF) for cause 1 is:

\[F_1(t; X, Z) = 1 - \exp\left\{-\int_0^t (\alpha^T(u)X) \exp(\beta^T Z) du\right\}\]

Simulating Competing Risks Data

We simulate a dataset under the Cox censoring scenario with 20% censoring:

set.seed(123)
dat <- simulate_coxaalen(
  n = 150,
  p = 0.3,
  alpha = 1.0,
  beta1 = 1.0,
  beta2 = 1.0,
  censoring = "cox",
  cens_rate = 0.20
)
head(dat)
#>          time status         X         Z         W
#> 1 0.003154266      2 0.2875775 0.8474532 0.8474532
#> 2 0.745514750      1 0.7883051 0.4975273 0.4975273
#> 3 0.457827643      1 0.4089769 0.3879090 0.3879090
#> 4 0.004339406      1 0.8830174 0.2464490 0.2464490
#> 5 0.410499488      1 0.9404673 0.1110965 0.1110965
#> 6 0.563480914      1 0.0455565 0.3899944 0.3899944
table(dat$status)
#> 
#>  0  1  2 
#> 26 88 36

Model Fitting

Formula Interface

The package provides a formula interface where additive and multiplicative covariates are separated by |:

fit <- cox_aalen(
  formula = survival::Surv(time, status) ~ X | Z,
  data = dat,
  W = ~ W,
  weight_type = "cox"
)
summary(fit)
#> =================================================================
#>  Cox-Aalen Subdistribution Hazard Model for Competing Risks
#> =================================================================
#>  Weight type             : cox 
#>  Sample size (n)         : 150 
#>  Additive covariates     : 2 
#>  Multiplicative covariates: 1 
#>  Max follow-up time (tau): 4.8139 
#>  Convergence             : TRUE (in 3 iterations) 
#> 
#> ----- Multiplicative Coefficients (beta) ------------------------
#>   Estimate StdErr z_value p_value
#> Z   0.3845 0.3836  1.0025  0.3161
#> 
#> ----- Cumulative Additive Coefficients A(t) (selected quantiles) -
#>         (Intercept)      X
#> t=0         -0.0075 0.0260
#> t=0.084      0.0060 0.2684
#> t=0.328      0.0450 0.5370
#> t=0.888      0.0808 1.0385
#> t=4.814      0.4216 1.8449
#> 
#> ----- Censoring Model Coefficients (gamma) ----------------------
#>   Estimate StdErr
#> W   1.3803 0.7234

Parameter Inference

# Multiplicative coefficient
coef(fit)
#>         Z 
#> 0.3845289

# Variance-covariance matrix
vcov(fit)
#>           Z
#> Z 0.1471294

# 95% Confidence interval
confint(fit)
#>        2.5 %   97.5 %
#> Z -0.3672634 1.136321

Goodness-of-Fit Test for Time-Varying Effects

We can test whether the effect of covariate \(X\) is indeed time-varying using the supremum test:

set.seed(123)
test_res <- time_varying_test(fit, B = 100)
print(test_res)
#> Goodness-of-Fit Test for Time-Varying Covariate Effects
#> Resampling iterations (B): 100 
#> 
#>     Covariate Sup_Stat p_value_sup CvM_Stat p_value_cvm
#> 1 (Intercept)   0.3806        0.01   0.0910        0.04
#> 2           X   0.7037        0.04   0.6132        0.02
#> 
#> Note: Low p-values (< 0.05) reject constant effects in favor of time-varying effects.

CIF Prediction

We predict cumulative incidence functions for subjects with different covariate values:

new_profiles <- data.frame(
  X = c(0.2, 0.8),
  Z = c(0.5, 0.5)
)

pred <- predict(fit, newdata = new_profiles, se.fit = TRUE)

# Plot predicted CIF curves
plot_cif(fit, newdata = cbind(1, new_profiles$X), newZ = matrix(new_profiles$Z, ncol = 1))

Cumulative Additive Coefficient Paths

plot_cumulative_coef(fit)

Real Data Application: Tamoxifen Breast Cancer Study

The package includes the clinical trial dataset of 641 women aged 50 or older with early breast cancer:

data(tamoxifen)
head(tamoxifen)
#>    time status  age pathsize treatment
#> 1  0.87      2 78.7     1.11         1
#> 2  8.38      0 61.4     0.10         1
#> 3  2.20      2 69.7     2.06         1
#> 4 10.52      0 72.1     0.32         1
#> 5  9.41      0 70.1     0.51         0
#> 6  9.40      0 65.5     0.10         0
table(tamoxifen$status)
#> 
#>   0   1   2 
#> 490  52  99

# Fit Cox-Aalen model with age and treatment in additive part and pathsize in multiplicative part
fit_tam <- cox_aalen(
  formula = survival::Surv(time, status) ~ age + treatment | pathsize,
  data = tamoxifen,
  W = ~ age,
  weight_type = "cox"
)
summary(fit_tam)
#> =================================================================
#>  Cox-Aalen Subdistribution Hazard Model for Competing Risks
#> =================================================================
#>  Weight type             : cox 
#>  Sample size (n)         : 641 
#>  Additive covariates     : 3 
#>  Multiplicative covariates: 1 
#>  Max follow-up time (tau): 10.38 
#>  Convergence             : TRUE (in 3 iterations) 
#> 
#> ----- Multiplicative Coefficients (beta) ------------------------
#>          Estimate StdErr z_value p_value
#> pathsize   0.0572  0.148  0.3868  0.6989
#> 
#> ----- Cumulative Additive Coefficients A(t) (selected quantiles) -
#>         (Intercept)    age treatment
#> t=0.87       0.0015  0e+00    0.0029
#> t=3.67       0.0344 -1e-04   -0.0060
#> t=5.81      -0.0141  9e-04   -0.0048
#> t=8.56       0.0431  8e-04   -0.0203
#> t=10.38      0.2092  0e+00   -0.0497
#> 
#> ----- Censoring Model Coefficients (gamma) ----------------------
#>     Estimate StdErr
#> age   -8e-04 0.0053

References

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.