Skip to contents

aalen_additive() fits Aalen's additive hazards model, in which the hazard is a sum of covariate effects that change over time: $$h(t \mid x) = \beta_0(t) + \beta_1(t) x_1 + \cdots + \beta_p(t) x_p.$$ Nothing is assumed about the shape of the \(\beta_j(t)\), so the model suits effects that grow, fade, or change sign over follow-up. What's estimated is the cumulative regression function \(B_j(t) = \int_0^t \beta_j(s) ds\) of each term.

Usage

aalen_additive(
  formula,
  data,
  weights,
  subset,
  na.action = stats::na.omit,
  nmin,
  test = c("aalen", "nrisk"),
  qrtol = 1e-07,
  conf_level = 0.95
)

Arguments

formula

A formula with a right-censored or counting-process Surv() response on the left and the covariates on the right, such as Surv(time, status) ~ age + sex. Factors are coded with treatment contrasts. The model always has an intercept, \(\beta_0(t)\).

data

A data frame holding the variables in formula.

weights

Optional case weights, a column of data or a numeric vector.

subset

An optional expression selecting the rows of data to use.

na.action

What to do with rows that have missing values. The default drops them.

nmin

The smallest number at risk (the sum of the weights of those at risk) for an event time to be used. The default is three times the number of covariate columns.

test

The weights of the tests: "aalen" (the default) or "nrisk".

qrtol

The tolerance for deciding that the covariates at risk are collinear. The default is 1e-7.

conf_level

The confidence level, between 0 and 1. The default is 0.95.

Value

An aalen_additive object. Use as.data.frame() for the table of tests, cumulative_coefficients() for \(B_j(t)\) with its confidence limits, and predict() for survival and cumulative hazard curves. coef() and vcov() give the scaled statistics (estimate in the table) and their variance.

The object also holds times, n_risk, and increments (one row per event used, so tied events have a row each), test_statistic and test_var (the unscaled statistics and their variance), wald_test (the chi-square test of the covariates: statistic, df, p_value), n, n_event, and n_times (the number of distinct event times used).

Details

At each event time, the increments \(dB(t)\) are the least squares fit of the event to the covariates of the subjects at risk, weighted by the case weights. The cumulative coefficients add these up over time. Event times with fewer than nmin subjects at risk (by weight), or at which the covariates of those at risk are collinear, are left out, since the fit is unstable there.

The table gives a test of each term. The statistic is a weighted sum of its increments, \(U_j = \sum_t w_j(t) dB_j(t)\), with variance \(\sum_t w_j(t)^2 dB_j(t)^2\). With test = "aalen" (the default), \(w_j(t)\) is the number at risk divided by the variance factor of the term in the regression at \(t\). With test = "nrisk", it's the number at risk. estimate is \(U_j\) scaled to the size of an increment: divided by the sum of the weights for "aalen", and by the number of events used for "nrisk". slope is the slope of a weighted least squares line through the origin fitted to the cumulative weighted increments, an average of \(\beta_j(t)\) over time. A chi-square test of all the covariates together takes the covariance of the statistics into account.

Examples

lung <- data.frame(
  time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567, 144,
    613, 707, 61, 88),
  status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
  age = c(74, 68, 56, 57, 60, 74, 68, 71, 53, 61, 57, 68, 68, 60, 57, 67, 70, 63, 56, 57),
  sex = c(1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1)
)

fit <- aalen_additive(Surv(time, status) ~ age + sex, data = lung)
fit
#> <aalen_additive> Surv(time, status) ~ age + sex
#> Aalen test weights. n = 20, events = 18, event times used = 15
#> 
#>                slope  estimate std_error statistic p_value
#> Intercept  0.0184023  0.311098   0.20308    1.5319  0.1255
#> age       -0.0001859 -0.003067   0.00314   -0.9767  0.3287
#> sex       -0.0010190 -0.013134   0.03907   -0.3362  0.7368
#> 
#> Chi-square test of the covariates: 1.27 on 2 df, p = 0.53

# The cumulative effect of sex over time
coefs <- cumulative_coefficients(fit)
coefs[coefs$term == "sex", ]
#>    term time n_risk n_event     estimate   std_error     conf_low    conf_high
#> 31  sex   61     20       1 -0.003319597 0.003319597 -0.009825888  0.003186694
#> 32  sex   71     19       1 -0.047226569 0.044032283 -0.133528257  0.039075119
#> 33  sex   88     18       1 -0.065050837 0.047503120 -0.158155242  0.028053568
#> 34  sex  144     17       1 -0.182279573 0.126487640 -0.430190793  0.065631646
#> 35  sex  166     16       1 -0.249716340 0.143341692 -0.530660894  0.031228213
#> 36  sex  170     15       1 -0.281951935 0.146921660 -0.569913098  0.006009227
#> 37  sex  210     14       1 -0.319654479 0.151682089 -0.616945910 -0.022363048
#> 38  sex  218     13       1 -0.326903620 0.151855214 -0.624534371 -0.029272870
#> 39  sex  306     12       1 -0.533298969 0.256240212 -1.035520556 -0.031077383
#> 40  sex  310     11       1 -0.270961307 0.366715278 -0.989710044  0.447787431
#> 41  sex  361     10       1  0.027649804 0.472915099 -0.899246757  0.954546366
#> 42  sex  455      9       1 -0.171944927 0.513309602 -1.178013260  0.834123406
#> 43  sex  567      8       1 -0.226375307 0.516187383 -1.238083986  0.785333372
#> 44  sex  613      7       1 -0.511691292 0.589792019 -1.667662407  0.644279823
#> 45  sex  654      6       1 -0.011691292 0.773210596 -1.527156212  1.503773628

# Survival curves for two new subjects
newdata <- data.frame(age = c(55, 70), sex = c(1, 2))
predict(fit, newdata = newdata, type = "survival", times = c(100, 200))
#>   subject time  estimate  std_error  conf_low conf_high
#> 1       1  100 0.7059027 0.20340020 0.4738166 1.0000000
#> 2       1  200 0.5282209 0.28171851 0.3040999 0.9175184
#> 3       2  100 1.0000000 0.01572860 0.9949333 1.0000000
#> 4       2  200 1.0000000 0.02177698 0.9897606 1.0000000