Under proportional hazards, the power of the two-group log-rank test depends on the data only through the total number of events (Schoenfeld, 1981). The number of events needed to detect a hazard ratio \(HR\) is $$d = \frac{(z_{1 - \alpha / s} + z_{\mathrm{power}})^2}{p (1 - p) (\log HR)^2},$$ where \(s\) is the number of sides of the test and \(p\) the fraction of subjects in one group. A hazard ratio and its inverse need the same number of events.
Usage
logrank_n_events(
hazard_ratio,
power = 0.8,
alpha = 0.05,
allocation = 0.5,
sides = 2
)
logrank_power(
hazard_ratio,
n_events,
alpha = 0.05,
allocation = 0.5,
sides = 2
)
logrank_sample_size(
hazard_ratio,
prob_event,
power = 0.8,
alpha = 0.05,
allocation = 0.5,
sides = 2
)Arguments
- hazard_ratio
The hazard ratio to detect, positive and not 1.
- power
The target power, between 0 and 1. The default is
0.8.- alpha
The significance level, between 0 and 1. The default is
0.05.- allocation
The fraction of subjects in one of the groups, between 0 and 1. The default,
0.5, is a balanced design, which needs the fewest events.- sides
2(the default) for a two-sided test or1for a one-sided test.- n_events
The total number of events, across both groups.
- prob_event
The probability that a subject has the event during the study, greater than 0 and at most 1.
Value
logrank_n_events() and logrank_sample_size() give a whole number (an integer).
logrank_power() gives the power, between 0 and 1.
Details
logrank_n_events() gives \(d\), rounded up. logrank_power() inverts the formula, giving
the power \(\Phi(\sqrt{d p (1 - p)} |\log HR| - z_{1 - \alpha / s})\) reached with n_events
events. logrank_sample_size() divides \(d\) by the probability that a subject has the event
during follow-up, then rounds up, giving the number of subjects to enroll.
References
Schoenfeld, D. A. (1981). The asymptotic properties of nonparametric tests for comparing survival distributions. Biometrika, 68(1), 316-319.
Examples
# Events needed to detect a halving of the hazard with 80% power
logrank_n_events(hazard_ratio = 0.5)
#> [1] 66
logrank_n_events(hazard_ratio = 0.5, power = 0.9, allocation = 1 / 3)
#> [1] 99
# The power reached with 60 events
logrank_power(hazard_ratio = 0.5, n_events = 60)
#> [1] 0.7656462
# Subjects to enroll when 40% of them are expected to have the event
logrank_sample_size(hazard_ratio = 0.5, prob_event = 0.4, power = 0.9)
#> [1] 219