logrank.test: Weighted log-rank test

View source: R/paket_nph_2-1_1.R

logrank.testR Documentation

Weighted log-rank test

Description

Calculates a weighted log-rank test for the comparison of two groups.

Usage

logrank.test(
  time,
  event,
  group,
  alternative = c("two.sided", "less", "greater"),
  rho = 0,
  gamma = 0,
  event_time_weights = NULL
)

Arguments

time

Vector of observed event/censored times

event

logical vector or numeric vector with entries 0 or 1, indicating if an event was observed (TRUE or 1) or the time is censored (FALSE or 0)

group

Vector of group allocations

alternative

Either of "two.sided","less" or "greater", specifies if two-sided or respective one-sided p-values are calculated. In any case the z test statistic of each included weighted log-rank test is based on the (weighted) sum of expected minus observed events in the group corresponding to the first factor level of group. Hence a small value of the test statistic corresponds to a lower (weighted average) hazard rate in the first group.

rho

Parameter to calculate weights in the rho-gamma family

gamma

Parameter to calculate weights in the rho-gamma family

event_time_weights

Optional vector of user defined weights. This weight vector needs to have one entry per event time (not per event, as multiple events may occur at the same time) and must be sorted by increasing event time.

Details

For a given sample, let \mathcal{D} be the set of unique event times. For a time-point t \in \mathcal{D}, let n_{t,ctr} and n_{t,trt} be the number of patients at risk in the control and treatment group and let d_{t,ctr} and d_{t,trt} be the respective number of events. The expected number of events in the control group is calculated under the least favorable configuration in H_0, λ_{ctr}(t) = λ_{trt}(t), as e_{t,ctr}=(d_{t,ctr}+d_{t,trt}) \frac{n_{t0}}{n_{t0}+n_{t1}}. The conditional variance of d_{t,ctr} is calculated from a hypergeometric distribution as var(d_{t,ctr})=\frac{n_{t0} n_{t1} (d_{t0}+d_{t1}) (n_{t0}+n_{t1} - d_{t0} - d_{t1})}{(n_{t0}+n_{t1})^2 (n_{t0}+n_{t1}-1)}. Further define a weighting function w(t). The weighted logrank test statistic for a comparison of two groups is

z=∑_{t \in \mathcal{D}} w(t) (d_{t,ctr}-e_{t,ctr}) / √{∑_{t \in \mathcal{D}} w(t)^2 var(d_{t,ctr})}

Under the the least favorable configuration in H_0, the test statistic is asymptotically standard normally distributed and large values of z are in favor of the alternative.

The function consider particular weights in the Fleming-Harrington ρ-γ family w(t)=\hat S(t-)^ρ (1-\hat S(t-))^γ. Here, \hat{S}(t)=∏_{s \in \mathcal{D}: s ≤q t} 1-\frac{d_{t,ctr}+d_{t,trt}}{n_{t,ctr}+n_{t,trt}} is the pooled sample Kaplan-Meier estimator. (Note: Prior to package version 2.1, S(t) was used in the definition of ρ-γ weights, this was changed to S(t-) with version 2.1.) Weights ρ=0, γ=0 correspond to the standard logrank test with constant weights w(t)=1. Choosing ρ=0, γ=1 puts more weight on late events, ρ=1, γ=0 puts more weight on early events and ρ=1, γ=1 puts most weight on events at intermediate time points.

Value

A list with elements:

D

A data frame event numbers, numbers at risk and expected number of events for each event time

test

A data frame containing the z and chi-squared statistic for the one-sided and two-sided test, respectively, of the null hypothesis of equal hazard functions in both groups and the p-value for the one-sided test.

var

The estimated variance of the sum of expected minus observed events in the first group.

Author(s)

Robin Ristl, robin.ristl@meduniwien.ac.at

References

Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.

Thomas R Fleming and David P Harrington. Counting processes and survival analysis. John Wiley & Sons, 2011

See Also

logrank.maxtest

Examples

A <- pop_pchaz(Tint = c(0, 90, 1500),
  lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365,
 lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365,
 lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365,
 p = c(0.8, 0.2), 
 timezero = FALSE, discrete_approximation = TRUE)
B <- pop_pchaz(Tint = c(0, 90, 1500),
  lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365,
 lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365,
 lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365,
 p = c(0.8, 0.2), 
 timezero = FALSE, discrete_approximation = TRUE)
dat <- sample_fun(A, B, r0 = 0.5, eventEnd = 30,
  lambdaRecr = 0.5, lambdaCens = 0.25 / 365,
 maxRecrCalendarTime = 2 * 365,
 maxCalendar = 4 * 365)
logrank.test(dat$y, dat$event, dat$group)



nph documentation built on May 17, 2022, 1:06 a.m.