Tutorials › Competing Risks and Multi-State Models › Gray’s Test Versus Log-Rank Testing

Testing and Design · Tutorial 221 of 699

Gray’s Test Versus Log-Rank Testing

Learn what Gray’s test and the cause-specific log-rank test each compare, how competing events affect their risk sets, and how to interpret their results without treating them as interchangeable.

Advanced 10 min read

What You'll Learn

  • State the null hypothesis for Gray’s test and for the cause-specific log-rank test.
  • Explain how a prior competing event affects each test’s risk set.
  • Calculate a tied-event cause-specific log-rank score and variance.
  • Interpret Gray-test and log-rank results in terms of their distinct estimands.
  • Identify censoring and follow-up conditions that can undermine either comparison.

One Data Set, Two Different Questions

When comparing groups in a competing-risks study, the test choice depends on the scientific question. If the question concerns the probability of experiencing a particular event type by time \(t\), the relevant quantity is its cumulative incidence function (CIF). If the question concerns the instantaneous rate of that event among people who are still event-free, the relevant quantity is its cause-specific hazard. Gray’s test and the cause-specific log-rank test address these different targets.

The distinction matters because a competing event changes who remains at risk for a future event of interest. A person who has already experienced a competing event can no longer have the target event as their first event. That fact is handled differently by the two procedures: the cause-specific log-rank test removes that person from its risk set, whereas Gray’s test uses a modified risk set to test equality of the target-event CIFs.

Definition: For target cause \(k\) in group \(g\), the cumulative incidence function is \(F_{kg}(t)=P(T\leq t,J=k\mid g)\), the probability of having experienced cause \(k\) by time \(t\) as the first event. The cause-specific hazard is the instantaneous rate of cause \(k\) at time \(t\), conditional on having experienced no event just before \(t\). Gray’s test assesses equality of the target-cause CIFs across groups; the cause-specific log-rank test assesses equality of the target-cause hazards across groups.

Null Hypotheses and Risk Sets

For two groups, the null hypothesis for Gray’s test is \(H_0:F_{k1}(t)=F_{k0}(t)\) for every time \(t\) in the comparison period. Its alternative is that the CIFs differ at one or more times. The test is a score-type comparison based on modified risk sets and a variance estimate that accounts for the competing-risks and censoring structure. The usual large-sample reference distribution for its one-degree-of-freedom statistic is chi-square under the null.

In the absence of censoring, Gray’s modified risk set at time \(t\) includes people who are still event-free just before \(t\), together with people who previously experienced a competing event. The latter remain represented because their competing event contributes to the probability of the target event being observed as the first event. With censoring, the modified contributions for prior competing events are weighted using the censoring distribution; the exact implementation should be checked when censoring patterns differ between groups.

The cause-specific log-rank test instead compares the target-cause hazards. At each target-event time, its ordinary risk set consists of people still free of every event just before that time. A prior competing event removes a person from this risk set, just as a prior target event does. This construction tests a cause-specific hazard comparison; it does not turn a competing event into an observed target event or estimate a latent time to the target event in a world where competing events were eliminated.

Both tests require independent subjects and suitable independent right censoring for the relevant group comparisons. Follow-up must also be adequate over the time range being compared. In particular, informative loss to follow-up can distort estimated incidence and risk-set comparisons. A log-rank test does not require proportional hazards for the mathematical validity of its null test, although its power is often greatest for alternatives that produce a consistent hazard difference. Neither test, by itself, establishes a causal effect of group membership.

Worked Example: The Same Tied Events, Different Risk Sets

Worked Example: The Same Tied Events, Different Risk Sets

Consider a hypothetical study with 10 people in each of two groups, labelled 1 and 0. The target event occurs in two people in group 1 at time 1, in two people in group 0 at time 3, and in two people in group 0 at time 4. Between times 1 and 3, four additional people in group 1 experience a competing event. There is no censoring, and there are no other events before time 4. Thus the cause-specific log-rank risk-set counts just before the three target-event times are \((Y_1,Y_0)=(10,10),(4,10),(4,8)\).

For the log-rank test, let \(d_j\) be the total number of tied target events at time \(j\), and let \(O_{1j}\) be the number of those events in group 1. The score contribution is \(O_{1j}-d_jY_{1j}/Y_j\), where \(Y_j=Y_{1j}+Y_{0j}\). Here \(d_j=2\) at each time, and the group 1 observed counts are 2, 0, and 0. Therefore,

$$ U_{LR}=(2-2\cdot 10/20)+(0-2\cdot 4/14)+(0-2\cdot 4/12) =1-\frac{4}{7}-\frac{2}{3} =-\frac{5}{21}\approx -0.2381. $$

For tied target events, the usual log-rank variance contribution at a time is \(\frac{d_jY_{1j}Y_{0j}}{Y_j^2}\frac{Y_j-d_j}{Y_j-1}\). The second factor is the finite-population correction for the tied failures. Applying it at each event time gives

$$ \begin{aligned} V_{LR} &=\frac{2(10)(10)}{20^2}\frac{18}{19} +\frac{2(4)(10)}{14^2}\frac{12}{13} +\frac{2(4)(8)}{12^2}\frac{10}{11}\\ &\approx 0.4737+0.3768+0.4040 =1.2545. \end{aligned} $$

The one-degree-of-freedom statistic is

$$ X^2=\frac{U_{LR}^2}{V_{LR}} =\frac{(-5/21)^2}{1.2545} \approx 0.0452. $$

Against a chi-square distribution with one degree of freedom, this gives an approximate two-sided \(p\)-value of 0.832. At conventional significance levels, this is not evidence against equality of the cause-specific hazards. It is not evidence that the hazards are identical.

The risk sets for Gray’s test differ. Just before time 3, group 1 has four people still event-free and four people who previously experienced the competing event. With no censoring, all eight contribute to its modified risk set; group 0 has 10. Just before time 4, group 1 again has eight represented, while group 0 has eight still event-free. Gray’s test uses its own score and variance calculation on these modified sets; the log-rank variance above is not a valid substitute for Gray’s variance.

The CIFs also show why the scientific questions differ. Group 1’s target-event CIF reaches \(2/10=0.20\) at time 1 and remains 0.20 through time 4. Group 0 has no target event at time 1. Its CIF reaches \(2/10=0.20\) at time 3, then increases by \((8/10)(2/8)=0.20\) at time 4, reaching 0.40. This descriptive difference does not determine a Gray-test \(p\)-value; that requires Gray’s score and variance calculation. It does show that the cumulative probabilities and the cause-specific hazard comparison are not the same summary.

Interpreting Results in Their Own Terms

A Gray-test result concerns whether the target-event CIFs differ over time. For example, suppose a hypothetical analysis reports Gray’s test statistic \(X^2=4.60\) with one degree of freedom. Its large-sample \(p\)-value is approximately 0.032. If the prespecified significance level is 0.05, this is evidence against equality of the target-cause CIFs. It does not state that there is a 3.2% probability that the null hypothesis is true, nor does it by itself identify when or how the CIFs differ.

A log-rank result concerns equality of the target cause-specific hazards. A non-small log-rank \(p\)-value does not rule out a difference in CIFs: groups can have similar target cause-specific hazards but different competing-event experience, which changes the chance of remaining event-free and hence the target-event CIF. Conversely, evidence of a CIF difference is not automatically evidence that the target cause-specific hazards differ in the same way.

The tests are related to different summaries of the observed event process, not interchangeable versions of one test. The following comparison is a useful decision aid.

FeatureGray’s testCause-specific log-rank test
Primary targetEquality of target-cause CIFsEquality of target-cause hazards
Prior competing eventRemains represented in the modified risk set, with censoring adjustment as neededRemoved from the event-free risk set
Typical interpretationEvidence that the observed probability of target cause by time differsEvidence that the instantaneous target-event rate among event-free people differs
What it does not establish aloneA causal effect or the time and shape of every differenceA CIF difference, a latent failure-time contrast, or a causal effect

Worked Example: Matching a Question to a Test

Suppose investigators ask whether the probability of first experiencing disease-related hospitalization by 18 months differs between two treatment groups, while death before hospitalization is a competing event. This is a question about \(F_{k g}(18)\), and a comparison of the target-event CIFs over follow-up aligns with that question. Gray’s test is the corresponding omnibus test of equality of those CIF curves.

If instead the question is whether the instantaneous rate of hospitalization differs among participants who are still alive and have not yet been hospitalized, the target is the cause-specific hazard. The cause-specific log-rank test aligns with that question. Participants who die leave its event-free risk set at death.

The test choice does not change the underlying observed data or make one scientific question more important than the other. It determines which group contrast is assessed. If both questions are scientifically important, the analyses should be reported as distinct, prespecified comparisons, with their estimands named explicitly.

Deriving the Tied-Event Log-Rank Variance

The finite-population correction used in the example follows from the tied-event allocation under the null. At an event time, suppose \(d\) target failures are selected from \(Y\) people at risk, of whom \(Y_1\) are in group 1. Under the null, the number \(O_1\) of group 1 failures has a hypergeometric distribution. Its variance is

$$ \operatorname{Var}(O_1) =d\frac{Y_1}{Y}\left(1-\frac{Y_1}{Y}\right)\frac{Y-d}{Y-1} =\frac{dY_1Y_0}{Y^2}\frac{Y-d}{Y-1}, $$

where \(Y_0=Y-Y_1\). The correction \((Y-d)/(Y-1)\) accounts for sampling \(d\) failures without replacement from the risk set. When \(d=1\), it equals 1; when \(d>1\), omitting it overstates the usual tied-event variance. Summing these contributions gives the variance for the log-rank score in the example, subject to the standard handling of tied target events.

Worked Example: Detecting a Tied-Event Calculation Error

At a target-event time, suppose \(Y_1=4\), \(Y_0=10\), and \(d=2\). Then \(Y=14\). The no-correction expression is \(dY_1Y_0/Y^2=80/196\approx0.4082\), but the tied-event variance is

$$ \frac{2(4)(10)}{14^2}\frac{14-2}{14-1} =\frac{80}{196}\frac{12}{13} \approx 0.3768. $$

Thus 0.4082 is not the standard tied-event contribution for this risk set. The distinction changes the total variance, test statistic, and \(p\)-value. Before reporting a log-rank calculation with ties, check whether the chosen implementation uses this correction or explicitly state the alternative approximation being used.

Diagnostics, Limitations, and Common Mistakes

Check the group-specific numbers at each target-event time before interpreting either test. Risk sets must be counted immediately before the time, with prior competing events removed from the cause-specific log-rank set and treated according to the modified-risk-set rule for Gray’s test. Tied target failures require the corresponding tie handling. Compare follow-up and censoring patterns across groups: sparse late risk sets, substantial differential loss to follow-up, or incorrect event-type coding can make the nominal calibration unreliable or the conclusion unstable.

A common mistake is to treat competing events as ordinary independent censoring and then claim that the log-rank test compares the probability of the target event. The correction is to name the estimand: the cause-specific log-rank test compares target-event hazards among those still event-free, while Gray’s test compares target-event CIFs. Another mistake is to use the cause-specific risk-set counts in Gray’s variance calculation, or Gray’s modified counts in the standard log-rank formula. These are different procedures with different score and variance constructions.

Neither omnibus test gives a complete description of the difference. A \(p\)-value alone does not show the size, direction, or timing of a group contrast. Report the test alongside estimated CIFs or cause-specific hazard summaries appropriate to the question, confidence intervals where relevant, and the event counts and follow-up context needed to assess stability. If censoring assumptions are doubtful, consider sensitivity analyses and explain their assumptions rather than relying on a nominal test result alone.

Key takeaway: Use Gray’s test when the target is equality of cumulative incidence functions, and the cause-specific log-rank test when the target is equality of cause-specific hazards. A prior competing event is retained in Gray’s modified risk set but removes a person from the cause-specific log-rank risk set; the resulting tests and interpretations are not interchangeable.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. State the null hypothesis for Gray’s test and for the cause-specific log-rank test.
  2. At a target-event time, there are 6 people in group 1 still event-free and 3 people in group 1 who previously experienced a competing event. With no censoring, how many are represented in Gray’s modified risk set, and how many are in the cause-specific log-rank risk set?
  3. For a tied target-event time with \(Y_1=5\), \(Y_0=7\), and \(d=2\), calculate the tied-event log-rank variance contribution.
  4. Why can equal cause-specific hazards coexist with different target-event CIFs?

Solutions. (1) Gray’s null is equality of the target-cause CIFs at every comparison time; the log-rank null is equality of the target cause-specific hazards. (2) Gray’s modified set represents all 9 people, while the cause-specific log-rank set contains only the 6 still event-free. (3) Here \(Y=12\), so the contribution is \(\{2(5)(7)/12^2\}\{(12-2)/(12-1)\}=(70/144)(10/11)\approx0.4419\). (4) Different competing-event rates can change how many people remain event-free and able to experience the target event, changing the target CIF even if the target cause-specific hazards are equal.

Clinical Biostats