The log-rank test compares event counts with their conditional expectations under equal group hazard functions, using the individuals currently in each risk set. Assume the usual independent censoring conditions and independent strata. At pooled event time , let be the group numbers at risk, , and let be the event counts with total . Under the null hypothesis, conditioning on the risk counts and total events gives the hypergeometric distribution
Thus the null expected A count and its conditional variance are
When there is only one person at risk, the event allocation is deterministic and its variance is zero. The unstandardized log-rank statistic is , with variance estimate . Under standard large-sample conditions, is approximately standard normal under the null; the test detects systematic group differences in event rates. It is particularly effective for proportional-hazards alternatives, while crossing effects can cancel in the score.
For a stratified log-rank statistic, construct these risk sets and observed-minus-expected differences separately within each stratum , then sum:
This allows different baseline hazard functions between strata and avoids comparing an event with individuals in another stratum. The null is equal A and B hazards within each stratum, together with a censoring mechanism that does not invalidate the within-risk-set comparison.
In a paired stratum, both individuals initially form the risk set. A first event while both are still observed gives one nontrivial event allocation. After either individual leaves, every subsequent event is certain to belong to the only remaining group and has observed count equal to expected count. Therefore each pair supplies at most one informative table. A pair supplies none if the first exit is censoring before either observed event, if neither has an event during their joint follow-up, or if both fail simultaneously so that the tied event allocation is fixed. An event-censoring tie needs a specified convention; with events processed before same-time censoring, the other individual remains at risk for that event and the pair is informative. The untied continuous-time case avoids this ambiguity.
If A has the informative first event, the table at that time is
The phrase in the second column refers only to this event time; it does not mean that B can never fail. The expected A count is , so this table contributes to , with variance . An informative B-first pair contributes . All other tables contribute zero. Therefore the requested unnormalized score is
A positive score means more observed early events on A. There is no need to standardize it to answer the question.
To obtain an exact conditional law, put . Under the within-pair equal-hazard null, conditional on an event while both are at risk, either subject supplies it with probability . Equivalently, before the pair's first exit, the cause-specific event intensities for A and B are equal; integration over the common period of joint observation gives equal probabilities for the two informative outcomes. This argument requires noninformative observation of the failure process, not just equality of unadjusted marginal survival curves. Different independent pairs then have independent fair signs when informative. Conditioning on the set of informative pairs gives independent Bernoulli outcomes with probability ; conditioning only on their count mixes identical binomial laws and gives the same result:
This proves the paired log-rank reduction to a sign test. The conditional mass function is , , so an exact two-sided p-value sums the masses for with . If , there is no information for a treatment comparison. Failure-time distances beyond their ordering play no role in this paired score.
Under the null hypothesis of equal survival distributions, the two groups have the same event hazard. Conditional on the current risk set and one event, the event is in A with probability and in B with probability . Consequently, whenever both groups are represented,
Thus a weighted sum of differences in estimated hazard increments is centered under the null. Its sign reflects which group has more events relative to its numbers at risk. The weights may depend on event time and the preceding risk sets, but must not be chosen after seeing which group failed; otherwise this conditional-centering argument fails. Positive weights emphasize selected time regions without reversing an increment's direction. Such tests can have weak power against crossing hazards whose positive and negative contributions cancel.
Let , so . Its conditional null variance is . Since the unweighted hazard difference is , the conditional variance of its weighted contribution is . Successive centered contributions form martingale differences. Their variance contributions add, providing a variance standardization for the test.
With the specified log-rank weight, put . Then
Therefore the displayed sum is exactly the unstandardized log-rank statistic
Its two-sided large-sample log-rank test uses when and information is sufficient. If one group has no remaining subjects at some event time, its event contributes zero information. Use the final observed-minus-expected expression to define the contribution as zero; the original divided expression has an undefined and the log-rank weight becomes zero there. Thus strict positivity of the proposed weights implicitly restricts the comparison to event times when both groups are at risk. Independent censoring and a valid conditional common-hazard model are required throughout.
At each event time within a stratum, let be the group risk sets and let be the total number of observed failures. Under the null of equal hazard functions, the expected A count is . The log-rank statistic adds observed minus expected A counts over event times; the stratified log-rank statistic first makes these comparisons within each patient stratum, then adds across patients. Let be the sum of the corresponding null conditional variances. The standardized statistic has an approximate standard normal distribution under the null, and its square has an approximate one-degree-of-freedom chi-squared distribution. Compare it with the appropriate quantile for a two-sided test, under the usual independent censoring and exchangeability assumptions.
The log-rank test compares survival experience through the allocation of events within the successive risk sets. Its null is equal hazard functions between the groups over follow-up, with independent individuals and noninformative censoring within groups. At each distinct event time , let be the numbers at risk immediately before that time, and let be event counts. Under the null, conditional on the total , the expected number of A events is .
The signed log-rank statistic is the observed-minus-expected score
A positive score indicates relatively more A events than expected, hence a higher event hazard for A; B's score is its negative. Censoring times do not produce score terms, but remove people from all later risk sets.
At each event time the conditional null allocation is hypergeometric, as if the events were sampled without replacement from the risk set. Its variance gives the score-increment variance, with the finite-population correction for ties. Summing these conditional variances gives , since distinct-time martingale score increments have zero cross covariance under the null. For sufficiently many informative events, is approximately standard normal and approximately chi-squared with one degree of freedom. In the no-tie case, each variance contribution is . A time at which only one group remains at risk contributes no comparative information.
The numerical parts below report signed-score and variance contributions after day 160. They cannot be added as separate chi-squared statistics to the earlier follow-up: add the scores and variances first, and standardize once for the complete dataset. The log-rank test is particularly effective for proportional hazards alternatives; crossing hazards can produce cancelling score contributions.
is the number in group still observed and event-free immediately before event time : its group-specific risk set size. Set . Under the common hazard function and conditional on exactly one event at that time, each at-risk individual has the same infinitesimal event probability. Therefore
The indicator records whether the event came from group 1, while is its conditional expectation under equal hazards. Thus is the observed-minus-expected group-1 event count at that time. Under the null these are martingale differences, with conditional variance
The log-rank statistic has null mean zero. Its predictable variance estimate is , so the equal-hazards test uses
Use a two-sided large-sample log-rank test if no direction was prespecified; and adequate information are needed. The variance is the no-ties form. A positive indicates more group-1 events than expected. Independent censoring conditional on the model is required for these at-risk event intensities to describe the data.
Under the proportional hazards model, the total instantaneous group- rate is . Conditioning on the next event cancels the baseline hazard, giving
Keep defined using its null probability , as in the question. Its conditional expectation under the alternative is
It is zero at , as required, and has the sign of when both groups remain at risk. Replacing inside the definition of with the alternative probability would give a different residual, whose mean would instead be zero under that alternative.
At event time , let be the two risk set sizes, , and let be the event counts with . Under the null hypothesis of equal hazards, conditioning on the risk set and total number of events gives a hypergeometric distribution, so
and
The log-rank statistic and its estimated null variance are
Under the null, is asymptotically standard normal, or is asymptotically chi-squared with one degree of freedom.
Summing the observed-minus-expected contributions gives the unstandardized log-rank statistic
Under the null it is centered at zero. A two-sided log-rank test compares its magnitude with the square root of its null variance.