Tutorials › Competing Risks and Multi-State Models › Gray’s Test With Multiple Groups

Testing and Design · Tutorial 215 of 699

Gray’s Test With Multiple Groups

You will learn to construct and interpret the global Gray test for several groups, including its degrees of freedom, assumptions, and limits.

Advanced 12 min read

What You'll Learn

  • State the global null hypothesis of equal cumulative incidence functions across groups.
  • Form independent score contrasts and their covariance matrix.
  • Calculate the global quadratic statistic and its degrees of freedom.
  • Interpret a global result without claiming it identifies which groups differ.
  • Recognize when sparse data, weak follow-up support, or the chosen weights limit the test.

Why Use a Global Test?

With three or more groups, separate Gray tests for every pair do not provide a single answer to the question, “Is there evidence that the groups differ in target-cause cumulative incidence?” They also create multiple opportunities to flag a difference by chance. The global Gray test addresses the first question directly: it combines the group scores into one omnibus test of equality across all groups. A significant result indicates evidence of some group difference, but does not identify which groups differ.

The test is built from the Gray score and its estimated covariance. The earlier material on Gray’s score statistic and variance estimation establishes how to calculate those quantities for a specified weight function. Here the focus is how to combine them when there are \(K\geq 3\) groups, why the reference distribution has \(K-1\) degrees of freedom, and what the resulting test does and does not say.

Definition: For \(K\) groups and a chosen target cause, the global Gray null hypothesis is that the target-cause cumulative incidence functions are equal across all groups throughout the follow-up interval of interest: $$ H_0: F_{1,1}(t)=F_{1,2}(t)=\cdots=F_{1,K}(t) \quad \text{for all } t\in[0,\tau]. $$ The alternative is that at least one group’s function differs from another’s at some time in that interval.

Here \(F_{1,g}(t)\) denotes the cumulative incidence function for the target cause in group \(g\), and \(\tau\) is the end of the follow-up interval being assessed. The Gray score depends on the chosen weight function, so the test’s sensitivity to differences over time depends on that choice. The global test is not a test that every pair differs, nor is it a summary of the direction or size of all differences.

Scores, Contrasts, and the Test Statistic

Let \(U=(U_1,\ldots,U_K)^\mathsf{T}\) be the vector of Gray group scores under the null, and let \(V\) be its estimated covariance matrix. Each score aggregates the target-cause event contributions relative to their null expectations using Gray’s modified risk-set construction and the selected weight. The scores are dependent: a contribution to one group’s score is related to the contributions for the other groups. Consequently, the covariance terms matter; the scores cannot generally be tested as if they were independent.

Only \(K-1\) score contrasts are independent. For example, with three groups we can retain the first two scores as contrasts against the third, provided the score construction has the usual sum-to-zero constraint. More generally, choose a \((K-1)\times K\) contrast matrix \(A\) of full row rank that removes the common component of the group scores. Then define \(Z=AU\) and \(W=AVA^\mathsf{T}\). If \(W\) is nonsingular, the global statistic is:

$$ Q=Z^\mathsf{T}W^{-1}Z. $$

The matrix \(A\) must retain \(K-1\) independent comparisons among the groups. One possible choice compares each of the first \(K-1\) groups with group \(K\). A different full-rank contrast basis gives the same quadratic test when it spans the same contrast space and the covariance is transformed accordingly.

Theorem: Under the global null, independent subjects, suitable censoring conditions for valid Gray score and variance estimation, adequate follow-up support, and regularity conditions for the score’s asymptotic normal approximation, \(Q\) is approximately distributed as \(\chi^2_{K-1}\). The degrees of freedom are the number of independent group contrasts, not the number of groups and not the number of pairs.

The covariance estimate must have full rank on the contrast space for this form of the statistic to apply. If the scores and covariance are kept in their full \(K\)-dimensional form, the covariance is singular because the redundant common component supplies no additional contrast. The equivalent full-vector calculation uses the generalized inverse and its effective rank; simply inverting a singular matrix is not valid.

Why the Reference Distribution Has \(K-1\) Degrees of Freedom

The degree-of-freedom result follows from the asymptotic distribution of the independent score contrasts. Under the null and the stated regularity conditions, the contrast vector is approximately multivariate normal with mean zero and covariance \(W\). Standardizing by that covariance produces \(K-1\) approximately independent standard normal components.

$$ W^{-1/2}Z \ \dot{\sim}\ N_{K-1}(0,I_{K-1}), \qquad Q=Z^\mathsf{T}W^{-1}Z =\left(W^{-1/2}Z\right)^\mathsf{T}\left(W^{-1/2}Z\right) \ \dot{\sim}\ \chi^2_{K-1}. $$

The final equality uses the standard result that the sum of squares of \(K-1\) independent standard normal variables has a chi-square distribution with \(K-1\) degrees of freedom. This also explains why the number of pairwise comparisons, \(K(K-1)/2\), is not the degrees of freedom: those comparisons are redundant. For three groups, for example, knowing the differences between groups 1 and 2 and between groups 2 and 3 determines the difference between groups 1 and 3.

Worked Examples

Worked Example: Degrees of Freedom With Four Groups

Suppose a hypothetical study compares the target-cause cumulative incidence across four treatment groups. The Gray procedure supplies the four group scores and their covariance estimate. How many degrees of freedom does the global test use, and what does a statistic of \(6.40\) imply at the \(0.05\) significance level?

There are \(K=4\) groups, so the number of independent contrasts is \(K-1=3\). The test uses a \(\chi^2_3\) reference distribution. Its \(0.05\) upper-tail critical value is approximately \(7.815\).

Because \(6.40<7.815\), the statistic does not fall in the upper-tail rejection region. At the \(0.05\) level, we do not reject the null hypothesis of equal target-cause cumulative incidence functions. This conclusion is not proof that the functions are equal; it says this test did not provide sufficient evidence against equality at the chosen significance level.

Worked Example: A Three-Group Global Test

Consider a hypothetical trial with three groups, each containing 60 participants. By the end of follow-up, group A has 18 target-cause events, 14 competing events, and 28 censored participants; group B has 15, 17, and 28, respectively; group C has 12, 20, and 28. These counts describe the hypothetical data, but they are not enough by themselves to calculate Gray’s test: event times and the corresponding risk-set contributions are needed. Suppose the specified Gray procedure, applied to the event-time data, gives the score vector \(U=(3,-1,-2)^\mathsf{T}\) and the covariance matrix for the first two independent contrasts as shown below.

$$ Z= \begin{pmatrix} 3\\ -1 \end{pmatrix}, \qquad W= \begin{pmatrix} 4&1\\ 1&3 \end{pmatrix}. $$

The determinant of \(W\) is \(4(3)-1(1)=11\), so the inverse exists and is:

$$ W^{-1}=\frac{1}{11} \begin{pmatrix} 3&-1\\ -1&4 \end{pmatrix}. $$

Substituting into the quadratic statistic gives:

$$ Q=Z^\mathsf{T}W^{-1}Z =\frac{1}{11} \begin{pmatrix}3&-1\end{pmatrix} \begin{pmatrix}10\\-7\end{pmatrix} =\frac{30+7}{11} =\frac{37}{11} \approx 3.364. $$

There are \(3-1=2\) degrees of freedom. For \(\chi^2_2\), the upper-tail probability is \(\exp(-Q/2)\), so \(p=\exp(-37/22)\approx 0.186\). At \(\alpha=0.05\), this is not statistically significant evidence against the global null. The observed event counts alone cannot replace the score-and-covariance calculation because Gray’s test uses event timing and its modified risk sets.

Worked Example: A Significant Global Result

In another hypothetical three-group comparison, suppose the first two independent Gray score contrasts are \(Z=(3,-1)^\mathsf{T}\), and their estimated covariance is \(W=\operatorname{diag}(1,11/9)\). Assume the score and variance calculations are valid under the study’s design and censoring conditions.

Since \(W^{-1}=\operatorname{diag}(1,9/11)\), the statistic is:

$$ Q=Z^\mathsf{T}W^{-1}Z =3^2(1)+(-1)^2\left(\frac{9}{11}\right) =9+\frac{9}{11} =\frac{108}{11} \approx 9.818. $$

With \(K-1=2\) degrees of freedom, the p-value is:

$$ p=P(\chi^2_2\geq 9.818) =\exp(-9.818/2) \approx 0.00738. $$

Because \(0.00738<0.05\), reject the global null at the \(0.05\) level. The result is evidence that the target-cause cumulative incidence functions are not all equal over the assessed follow-up interval. It does not establish which groups differ, when their functions differ, or the magnitude of a clinically relevant difference.

What a Global Result Can—and Cannot—Show

The global test answers one focused question: whether the collection of group scores is sufficiently inconsistent with the null of equality to reject that null. A nonsignificant result is not evidence of equivalence. It can reflect genuinely similar functions, limited information, high score variability, or a test weight that is not sensitive to the pattern of differences present.

A significant result is likewise not a complete group comparison. It does not reveal which particular group pair accounts for the result. If pairwise Gray tests or other contrasts are then examined, the analysis must account for the fact that multiple comparisons were considered. Planned contrasts can also be useful when particular comparisons were specified in advance. In either case, report the comparisons and any multiplicity procedure rather than treating the global p-value as if it were a pairwise result.

QuestionGlobal Gray testPairwise Gray tests
Primary purposeTest whether all group functions are equalTest a specified pair of groups at a time
Degrees of freedom for \(K\) groups\(K-1\)One per pairwise test
What rejection establishesEvidence that not all groups are equalEvidence about the particular pair tested
Main cautionDoes not identify the differing groupsMany tests raise a multiplicity concern

Assumptions, Diagnostics, and Limitations

The chi-square approximation depends on more than the number of groups. Subjects should contribute independent information, the target and competing causes must be classified appropriately, and the censoring conditions must support valid estimation of the score and its covariance. There must also be adequate event information and follow-up support for the contrast covariance to be estimated reliably. In very small samples or with few target-cause events, the asymptotic reference distribution may be inaccurate.

Before interpreting the test, check that the group score and covariance calculation uses the same target cause, follow-up interval, and weight function throughout. Inspect the contrast covariance for singularity or near-singularity, and check that its rank is \(K-1\). A singular or unstable covariance can arise when the data contain too little information to distinguish some contrasts. The appropriate response is not to force an inverse; first investigate sparse events, group allocation, and follow-up support. Numerical checks should also confirm that the computed quadratic form is nonnegative up to negligible rounding error.

The test has further limits. Its score is a weighted aggregate over event times, so different time patterns can produce similar aggregate evidence, and changes in the weight can change sensitivity. A global rejection is not an estimate of the size of a risk difference and does not imply a causal effect of group assignment. As with any unadjusted group comparison, differences in observed groups should not be interpreted as causal without an appropriate design and assumptions.

Common Mistake

Wrong reasoning: “There are three groups, so the global test has three degrees of freedom; if it is significant, all three pairs must differ.” The first claim counts groups rather than independent contrasts, and the second confuses an omnibus rejection with pairwise conclusions.

Correction: With \(K\) groups and a full-rank contrast covariance, the global Gray statistic has \(K-1\) degrees of freedom. Rejection means only that the equality of all target-cause cumulative incidence functions is not supported by the data under the test’s assumptions and chosen weighting. Further comparisons are needed to describe which groups differ, with appropriate attention to multiplicity.

Key takeaway: Form \(K-1\) independent Gray score contrasts, use their estimated covariance in one quadratic statistic, and compare it with \(\chi^2_{K-1}\). The global test detects an overall departure from equality; it does not identify a differing pair or quantify the difference.

Check Your Understanding

Answer each question, then check the solutions below.

  1. For five groups, how many degrees of freedom does a full-rank global Gray test use, and how many pairwise comparisons are possible?
  2. A three-group global test has \(Q=4.80\). At \(\alpha=0.05\), use the \(\chi^2_2\) critical value \(5.991\) to state the decision.
  3. Why are three pairwise comparisons among three groups not three independent degrees of freedom?
  4. A global test is significant. Is it valid to conclude that every group pair differs? Explain.
  5. What should be investigated if the estimated covariance matrix for the independent contrasts is singular?

Solutions. (1) The degrees of freedom are \(5-1=4\); the number of pairs is \(5(4-1)/2=10\). The pairwise comparisons are not all independent. (2) Since \(4.80<5.991\), do not reject the global null at the \(0.05\) level. (3) For three groups, any two independent differences determine the third; for example, \((F_{1,1}-F_{1,2})+(F_{1,2}-F_{1,3})=F_{1,1}-F_{1,3}\). (4) No. Rejection supports a difference somewhere among the functions, not differences in every pair; pairwise analysis requires its own interpretation and multiplicity consideration. (5) Check the amount and distribution of event information, group allocation, follow-up support, and the score and covariance calculations. Do not invert a singular matrix as if it were full rank.

Clinical Biostats