Why tied event times need an explicit rule
When several participants have the same recorded event time, a calculation needs a consistent rule for deciding who is in the risk set and how many target events occurred. This is not a cosmetic software detail. If tied events are processed one at a time, the result can depend on an arbitrary ordering of records. Gray’s test instead evaluates the tied observations together at their common time.
The focus here is the arithmetic audit: identify the risk set immediately before each distinct time, count all target events at that time, and check the resulting group score contributions. These checks help detect incorrect event coding, accidental sequential processing, or discrepancies between hand calculations and software. They do not replace the covariance calculation required for a test statistic.
Gray’s score at a tied time
Gray’s test assesses equality of the cumulative incidence functions for the target cause across groups. Its risk set is a subdistribution risk set: a participant with a prior target event is removed, while a participant with a prior competing event may remain in the risk set with a censoring-adjusted weight. Thus, it is not simply the set of participants who have experienced no event.
For a standard unweighted calculation, use weight \(w(t)=1\). Write \(Y_g^*(t)\) for the Gray subdistribution risk total in group \(g\) immediately before time \(t\), and \(Y^*(t)=\sum_g Y_g^*(t)\). The score contribution for group \(g\) at that time is the observed number of target events minus its risk-set share of the total target events:
For another prespecified Gray-test weight, the time-specific score contribution is multiplied by \(w(t)\). A key tie rule is that all participants who have an event at \(t\) are included in the risk set just before \(t\). The target events at \(t\) are counted together as \(d_{gk}(t)\); tied competing events are not target events, but can contribute to later risk sets.
The score vector is not the whole test. Its covariance matrix accounts for the variability of the score, including the test’s risk-set and censoring structure. With \(G\) groups, a usual formulation uses \(G-1\) independent score components and compares the resulting quadratic statistic with a chi-square reference distribution having \(G-1\) degrees of freedom, subject to the test’s regularity conditions. In the examples below, the hand calculations audit score contributions, not a p-value.
Worked score calculation with tied target and competing events
Worked Example: Auditing Group Scores From a Small Dataset
Suppose a hypothetical study compares groups A and B for a target event, cause 1. There are four participants per group. Follow-up times and outcomes are shown below; the censoring time is after all event times considered.
| Group | Participant | Time | Outcome |
|---|---|---|---|
| A | A1 | 1 | Target event |
| A | A2 | 2 | Competing event |
| A | A3 | 2 | Target event |
| A | A4 | 3 | Target event |
| B | B1 | 1 | Competing event |
| B | B2 | 2 | Target event |
| B | B3 | 4 | Censored |
| B | B4 | 3 | Target event |
There is no censoring before time 3, so prior competing events have weight 1. Use the unweighted score, \(w(t)=1\). At time 1, both groups have four participants in the risk set. There is one target event, in group A, and a tied competing event in group B:
Thus \(d_k(1)=1\), and the score contributions are \(U_A(1)=1-(4/8)(1)=0.5\) and \(U_B(1)=0-(4/8)(1)=-0.5\). The competing event in B is not counted as a target event. It remains represented in B’s later subdistribution risk total.
At time 2, A1 has had a prior target event and is removed from the risk set. B1’s prior competing event remains represented with weight 1. The risk totals are therefore \(Y_A^*(2)=3\) and \(Y_B^*(2)=4\). There are two tied target events, one in each group, as well as a tied competing event in A. The target-event count is \(d_k(2)=2\), so:
The competing event in A at time 2 does not alter the risk set used for the score at time 2. It is represented in A’s risk total at later times. At time 3, A has its time-2 competing participant and its target-event participant represented, so \(Y_A^*(3)=2\). B has its time-1 competing participant, the participant censored at time 4, and its target-event participant represented, so \(Y_B^*(3)=3\). There are two target events at time 3:
Adding the group A contributions gives \(U_A=0.5+1/7+1/5=0.8429\). Group B’s total is \(U_B=-0.8429\). The totals sum to zero, as expected for the full set of group scores. These are score checks; a test statistic also requires the appropriate covariance estimate.
Why a tied batch cannot be ordered arbitrarily
The batch rule avoids making the answer depend on which participant happens to appear first in a data file. The following small calculation shows the problem with sequentially processing tied target events.
Worked Example: Detecting an Incorrect Sequential Tie Rule
At a single time \(t\), suppose the risk totals are \(Y_A^*(t)=Y_B^*(t)=2\), and one target event occurs in each group. The correct batch calculation has \(d_k(t)=2\), giving:
Now suppose software or hand work incorrectly processes group A’s target event first and removes that participant before evaluating group B’s tied event. The first contribution to A is \(1-(2/4)(1)=0.5\). For the second contribution, the mistaken risk totals are A: 1 and B: 2, so A receives \(0-(1/3)(1)=-1/3\). The resulting A score is \(0.5-1/3=0.1667\), rather than 0. If the records are processed in the opposite order, the erroneous result changes. That order dependence is a clear sign that tied events were not treated as a batch.
Checking fractional risk contributions
With censoring before a tied time, a prior competing event need not contribute a whole person to a later risk total. Its contribution depends on the censoring-survival ratio. The ratio should be applied to the prior competing event when assembling the later risk set; it does not turn that event into a target event or change the observed target-event count.
Worked Example: A Weighted Pseudo-Risk Total
At a hypothetical time \(t\), suppose group A has five participants still under observation and one participant with a prior competing event at \(u\). Let \(\widehat G(u-)=1\) and \(\widehat G(t-)=0.75\). The prior competitor contributes \(0.75/1=0.75\), so \(Y_A^*(t)=5.75\). Suppose group B’s corresponding total is 4.8, giving \(Y^*(t)=10.55\). If the tied target events at \(t\) consist of two in A and one in B, then \(d_k(t)=3\), and:
The group A share of the expected tied target events is fractional because its pseudo-risk total is fractional. The observed target-event count remains the integer 2. This calculation assumes the supplied censoring-survival estimates are the appropriate ones for the analysis; choosing or checking the censoring model is a separate issue.
A practical computation audit
A useful audit proceeds in time order, but processes each distinct time as one batch. For each time, check that the risk totals are determined from information just before that time, count only the target cause in \(d_k(t)\), and then update the risk-set status for subsequent times. A compact audit table makes discrepancies visible:
Confirm which event code is the target cause, which codes are competing causes, and which records are censored.
Combine records with the same analysis time. Do not break a tie by row order or by event type.
Remove prior target events and prior censoring; retain prior competing events with the required weights.
Use all tied target events together in \(d_k(t)\), then verify that group contributions sum to zero at that time.
Check group scores and risk totals before comparing covariance estimates, test statistics, or p-values, which depend on additional calculations.
For \(G\) groups, the score contributions at each time sum to zero because:
This identity is a simple but effective check. If the group score contributions do not sum to zero up to rounding, likely causes include a missing group, inconsistent risk totals, or an incorrect expected count. It is not, by itself, proof that the risk set or covariance estimate is correct.
Assumptions, diagnostics, and alternatives
The test requires independent observational units and a valid censoring adjustment under the censoring conditions appropriate to the analysis. Its large-sample chi-square calibration also relies on regularity conditions, including enough information for the covariance estimate to be usable. The arithmetic rules for ties do not repair violations of these assumptions. In particular, a correct batch calculation cannot correct informative censoring or an incorrectly specified target-event code.
Several diagnostics are practical. Compare the software’s distinct event times and tied target-event counts with a tabulation made directly from the data. Check the group risk totals immediately before representative tied times, especially after prior competing events or censoring. Confirm that a tied target event is included in the risk set at its own time, that tied competing events are not counted as target events, and that group score totals sum to zero. If reported score totals differ, check whether the software uses a non-unit time weight, a different censoring estimate, or a different convention for rounded times before concluding that there is an error.
Ties can arise because events truly occur simultaneously or because times are recorded only to a limited precision. If recorded days are used, two events on the same day are tied for this analysis unless a prespecified, defensible rule provides more precise ordering. Artificially adding tiny offsets to break ties creates an order that the data do not support and can alter scores. If the timestamp precision is questionable, investigate the recording process and assess whether the analysis is sensitive to reasonable time definitions.
Gray’s test is directed at differences in the target cause’s cumulative incidence, with competing events represented in its subdistribution risk sets. A cause-specific log-rank analysis uses a different risk-set construction and addresses a different testing target; it is not a substitute for a tied-time Gray calculation. Directly estimating and plotting group cumulative incidence functions can help describe the pattern, but does not supply the same formal score test. The score audit is therefore useful both for validating software and for clarifying what data features contribute to the test.
Common mistakes
- Processing a tie sequentially. The mistaken reasoning is that one tied event can be removed before calculating the next. The correction is to form risk totals just before the shared time and evaluate all target events at that time together.
- Counting a competing event as a target event. A competing event is not part of \(d_k(t)\). It can affect a later pseudo-risk total, subject to the censoring weight.
- Removing every competing event permanently. That produces a cause-specific risk set, not the Gray subdistribution risk set. Retain prior competing events in the required weighted form.
- Treating a score as the test statistic. Group score totals alone do not provide a p-value. The covariance estimate is also required.
- Breaking ties with arbitrary offsets. This can make results depend on invented ordering. Use the recorded times and the batch rule unless the study provides a justified finer time scale.
Check Your Understanding
Answer each question, then compare your reasoning with the brief solutions.
- At a tied time, \(Y_A^*=6\), \(Y_B^*=4\), and target-event counts are 1 in A and 2 in B. Calculate the score contribution for each group.
- Why does a competing event tied with a target event not enter the target-event count at that time?
- With no censoring before a later time, what weight does a prior competing event contribute to the Gray risk total?
- At one time, computed group score contributions sum to 0.12 rather than zero. Name two items to check.
- Why is a hand-calculated group score total not enough to report a Gray-test p-value?
Solutions. (1) The total risk is 10 and the target count is 3. Thus \(U_A=1-(6/10)(3)=-0.8\) and \(U_B=2-(4/10)(3)=0.8\). (2) Its cause is not the target cause; it may contribute to later risk totals, but it is not counted in \(d_k(t)\). (3) Its weight is 1 when the relevant censoring-survival ratio is 1. (4) Check that all groups are included and that the risk totals add to the stated overall total; also check event coding and the target count. (5) A p-value requires the score covariance estimate and the corresponding test statistic, not the score alone.