The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
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[@]metanet.ch.

AURMC Estimator

library(AURMC)

Estimator

Each patient is observed until their time of censoring \(C\) or death \(T\). Let \(X = \min(T, C)\) denote the observation time, and \(\delta = \mathbb{I}(T \leq C)\) the status indicator. While under observation, measurements are recorded for a process \(\{D(t), 0 < t < \tau\}\). For example, \(D(t)\) may take the value 1 while a patient is in the hospital, and 0 otherwise. Define the target estimand: \[ \mu = \int_{0}^{\tau} \mathbb{E}\{D(t)\}dt, \] which is the area under the curve (AUC) up to the truncation time \(\tau\). A consistent estimator for \(\mu\) is given by:

\[ \begin{gathered} \hat{\mu} = \int_{0}^{\tau} \hat{S}(t-) \frac{\bar{D}(t)}{\bar{Y}(t)}dt, \\ \bar{D}(t) = \frac{1}{n}\sum_{i=1}^{n}D_{i}(t)\mathbb{I}(X_{i} \geq t), \\ \bar{Y}(t) = \frac{1}{n}\sum_{i=1}^{n}\mathbb{I}(X_{i} \geq t). \end{gathered} \]

Here \(\hat{S}(t-)\) is the Kaplan-Meier survival probability immediately before time \(t\), \(\bar{D}(t)\) is the mean value of the measurement among subjects remaining at risk, and \(\bar{Y}(t)\) is the proportion of the sample remaining at risk. Thus a subject with a terminal event at \(t\) is included in both the risk set and the survival probability relevant to time \(t\). At an observed event time \(t_j\), \(\hat{S}(t_j-) = \prod_{t_k < t_j}\{1 - d_k/Y_k\}\). This convention matters for tied or discrete event times; it agrees with \(Y_i(t)=\mathbb{I}(X_i \geq t)\).

Choosing the truncation time

Choose \(\tau\) before examining the treatment contrast, using clinical relevance and follow-up that is plausibly supported in every arm. Heavy censoring near \(\tau\) can leave a sparse risk set and make large-sample Wald intervals optimistic. Inspect nar or y from TabRMC() near \(\tau\) and, when late follow-up is sparse, report sensitivity analyses at substantively defensible earlier truncation times. There is no universal minimum risk-set threshold; an appropriate choice depends on the design, censoring pattern, and intended estimand.

Method of integration

Let \(\hat{E}(t) = \hat{S}(t-) \bar{D}(t) / \bar{Y}(t)\) denote the estimated value of \(\mathbb{E}\{D(t)\}\) at time \(t\). Partition the interval \([0, \tau)\) as: \[ 0 = t_{0} \leq t_{1} < \cdots < t_{K} \leq t_{K+1} = \tau, \] where \(\{t_{k}: 1 \leq k \leq K\}\) are the times at which the value of \(\hat{E}(t)\) changes. \(\hat{\mu}\) may be calculated in several ways, all of which provide consistent estimation. The left sum is: \[ \hat{\mu}_{\text{left}} = \sum_{k=1}^{K+1}\hat{E}(t_{k-1})\cdot(t_{k} - t_{k-1}). \] The right sum is: \[ \hat{\mu}_{\text{right}} = \sum_{k=1}^{K + 1}\hat{E}(t_{k}) \cdot (t_{k} - t_{k-1}). \] Lastly, the trapezoidal sum is: \[ \hat{\mu}_{\text{trapezoid}} = \sum_{k=1}^{K+1}\left\{\frac{\hat{E}(t_{k-1}) + \hat{E}(t_{k})}{2}\right\} \cdot (t_{k} - t_{k-1}). \]

Example

Consider the following data for a single subject:

data <- data.frame(
  idx = c(1, 1, 1, 1, 1, 1),
  time = c(0, 1, 2, 3, 4, 5),
  status = c(1, 1, 1, 1, 1, 0),
  value = c(5, 4, 3, 2, 1, 0)
)
show(data)
#>   idx time status value
#> 1   1    0      1     5
#> 2   1    1      1     4
#> 3   1    2      1     3
#> 4   1    3      1     2
#> 5   1    4      1     1
#> 6   1    5      0     0

The value of the repeated measure curve can be tabulated as:

tab <- AURMC::TabRMC(data)
show(tab)
#>   time nar y haz surv d exp
#> 1    0   1 1   0    1 5   5
#> 2    1   1 1   0    1 4   4
#> 3    2   1 1   0    1 3   3
#> 4    3   1 1   0    1 2   2
#> 5    4   1 1   0    1 1   1
#> 6    5   1 1   0    1 0   0

Here nar is the number at risk at the beginning of the interval, y is \(\bar{Y}(t)\), haz is the hazard of death, surv is the left-limit survival probability \(\hat{S}(t-)\), d is \(\bar{D}(t)\), and exp is \(\hat{E}(t) = \hat{S}(t-) \bar{D}(t) / \bar{Y}(t)\).

The AUC can be calculated as:

# Left sum.
left <- AURMC::AURMC(data, int_method = "left")
cat("Left sum:\n")
#> Left sum:
show(left)
#>       method tau auc se lower upper p
#> 1 asymptotic   5  15  0    15    15 0

# Right sum.
right <- AURMC::AURMC(data, int_method = "right")
cat("Right sum:\n")
#> Right sum:
show(right)
#>       method tau auc se lower upper p
#> 1 asymptotic   5  10  0    10    10 0

# Trapezoidal sum.
trapezoid <- AURMC::AURMC(data, int_method = "trapezoid")
cat("Trapezoidal sum:\n")
#> Trapezoidal sum:
show(trapezoid)
#>       method tau  auc se lower upper p
#> 1 asymptotic   5 12.5  0  12.5  12.5 0

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.