A nonzero contribution occurs when a failure, rather than a censoring, is the earlier observation while both members remain at risk. By the paired log-rank reduction to a sign test, the two possible contributions are for an earlier A failure and for an earlier B failure. Under the exchangeable null and the usual independent censoring assumptions they are equally likely, conditional on being informative. Hence
Once the first member leaves the risk set, the second member's later observation adds no group-comparison information within this stratum.
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.
Keeping the event-free A individual under observation through day 193 leaves them in the risk set at both later B events. Now the calculations are
Event dayVariance
165221
180120
191110
Therefore
The negative score now indicates lower A event hazard, relative to B, in the contribution after day 160. The observed event counts have not changed. The change is in what events A was expected to contribute: its additional event-free exposure makes the two later B events informative comparisons, producing negative A score terms. No conclusion about the complete study's significance follows from this late contribution without the earlier scores and variances.
At day 165 there are two A and two B individuals at risk. The event is in A, with expected A count , so its score contribution is and its variance contribution is . The remaining A individual is censored at 173 and leaves the risk set before either later event. The risk-set calculations are
Event dayVariance
165221
180020000
191010000
Thus
The positive score indicates higher A event hazard in this late contribution. Although B has more observed events, its two events occur with no A individual at risk, so those times do not compare the groups. This is why raw event totals alone are insufficient for the log-rank test.
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.
Use one row per consecutive at-risk episode, retaining a patient identifier for dependence and an episode number for event order. In calendar time, the intervals are ; status is one if the row ends in a headache and zero if it ends in censoring. Patient 001 contributes
PatientNext-event episodeStartStopEvent
0011024.810
001224.833.110
001333.140.210
001440.251.910
001551.960.000
The fifth episode is censored, not a fifth observed headache. All rows retain . This start-stop recurrent-event data layout corresponds to the counting-process intensity in survival analysis
where indicates that the patient is currently observed and eligible for a headache. Fit the regression coefficient by Cox partial likelihood using the resulting risk sets, and estimate the baseline cumulative hazard nonparametrically, for example by the Breslow estimator. Patient rows are portions of one history, not new independent patients.
The second episode starts only after the first headache, at 24.8; its row is absent from every risk set before that time. More generally, episode starts at the observed end of episode . The left-open, right-closed interval convention assigns an event at a shared boundary only to the interval ending there. Thus the first event is counted once, and the second cannot be counted before the first. Preserving the episode entry times and patient history enforces the ordering; entering every recurrence as a new record starting at treatment time zero would not do so.
For second and subsequent episodes, subtract the preceding headache time from both calendar endpoints. The new clock is the age since the start of that headache, not the age since recovery ended. Keeping the recovery restriction from part (c) therefore gives
PatientNext-event episodeGap startGap stopEvent
0011024.810
001238.310
001337.110
0014311.710
001538.100
For example, the second stop is , while its entry is . Thus subsequent rows begin at gap age three, not zero. The first row retains time since treatment started. Keep the patient and episode labels, and preferably the original calendar endpoints as auxiliary fields: gap ages in different episodes are not chronological treatment times. The value 7.1 for episode three being smaller than 8.3 for episode two does not reverse their occurrence order. This gap-time recurrent-event model forms risk sets on the episode-age scale while preserving each episode's historical eligibility.
Add a stratum indicator that is “First” for the first episode and “Later” for every subsequent episode, including the final censored episode:
PatientNext-event episodeGap startGap stopEventStratum
0011024.810First
001238.310Later
001337.110Later
0014311.710Later
001538.100Later
A Stratified Cox model then uses distinct baseline hazards and , with a common treatment coefficient unless an interaction is explicitly desired. Form separate risk sets within the two strata and multiply their partial likelihoods. There is no need to force every later event number to have its own baseline when the stated aim is only first versus subsequent headaches. This is a first-event versus recurrent-event baseline stratification.
Begin by defining the scientific target: prediction for a new patient, or estimation of adjusted covariate effects. Check event definitions, follow-up origins, right-censoring codes and any delayed entry. The analysis assumes independent patients and censoring that is noninformative conditional on modeled covariates. For fixed explanatory variables , the Cox proportional-hazards model is
with an unrestricted baseline hazard and coefficients constant over time. Report as the conditional hazard ratio for a one-unit change in the coded variable, not as a risk ratio or automatically a causal effect.
For untied event times, fit the coefficients by maximizing the Cox partial likelihood
The baseline cancels within each event risk set. Use an appropriate tied-event method, such as an Efron approximation or an exact method for a genuinely discrete event scale; the Breslow approximation for tied event times is another explicit approximation. Numerical score/information methods fit the model, and inverse information gives conventional covariance estimates for independent subjects. Report coefficient estimates, hazard ratios, uncertainty and the coding that makes their interpretation meaningful. After fitting, the Breslow estimator gives , from which provides predicted survival.
Adequacy is broader than significance of coefficients. Inspect influential observations, deviance residuals and data errors. Cox–Snell residuals should have approximately unit-exponential survival under a well-fitting model, retaining the original censoring indicators; a cumulative-hazard plot of these residuals should be near the 45-degree line. This is an overall diagnostic, not a substitute for the functional-form and proportionality checks below. For prediction, assess held-out discrimination and survival prediction calibration at prespecified time horizons with methods accounting for censoring. A high concordance index alone does not establish good calibration or correct hazard structure.
Use bootstrap or held-out cross-validation that repeats the complete modeling procedure, including imputation, variable selection and tuning. Validation of only the final fitted coefficients understates overfitting from earlier decisions. Report any substantive lack of fit rather than presenting a single time-independent hazard ratio when the data do not support that representation.
For a counting process adapted to its observed history , a predictable counting-process intensity specifies
or more generally is a local martingale. In survival analysis, let record failures and record the risk set, including subjects at their own observation time. Under independent right censoring and a common hazard function , the aggregate intensity is , where and .
Writing , the conditional increment equation is . Replacing by the observed increment gives the Nelson–Aalen estimator
where ranges over the distinct observed event times. Censored observations remove subjects from subsequent risk sets but do not produce hazard jumps.
For these data the Nelson–Aalen estimator gives
Thus the six fitted cumulative hazards sum to , the number of observed failures.
The event-count identity for Nelson–Aalen cumulative hazards follows by exchanging the finite sums. With everyone entering at time zero,
This includes each failure subject in its own risk set. A delayed-entry dataset requires a different risk indicator and is not covered by this particular identity.
Under a constant hazard survival model, . Imposing the same identity gives the events divided by exposure estimator
Its fitted cumulative hazards at the six times are , again summing to four. It is also the maximum-likelihood estimate under independent right censoring, since the parameter-dependent likelihood is . This is a sensible estimate if the exponential survival model is appropriate, but four failures give little precision. The event-count identity by itself does not validate constant hazard; the large final jump in the Nelson–Aalen estimator also reflects a risk set of one, rather than by itself proving an increasing hazard.
For a proper continuous event time, the survival function is . The assumed invertibility of the cumulative hazard function gives, for ,
Therefore
This is the cumulative hazard probability transformation; it applies also conditionally on a subject's covariates, using that subject's correctly specified cumulative hazard function.
The fitted transformed times are Cox–Snell residuals. They retain their event/right censoring indicators, so a right-censored residual represents an exponential observation known only to exceed its displayed value. Under the fitted model and independent right censoring, calculate the Kaplan–Meier estimator of residual survival and compare it with , or calculate the residual Nelson–Aalen estimator and compare its cumulative hazard with the diagonal . Systematic departures reveal model inadequacy; sparse extreme residual risk sets and parameter estimation require caution. Treating all censored residuals as observed event times would invalidate this diagnostic.
Without right censoring, the residual mean should be approximately one. With right censoring, use the modified Cox–Snell residual
For a true unit-rate exponential distribution, the memoryless property gives . Thus an event keeps its known transformed time, while a censored observation is replaced by the conditional expected event time. Under independent right censoring, iterated expectation makes the mean of these adjusted values one when the true hazards are used, and approximately one when fitted hazards are used. These mean-imputed values do not themselves have an exponential distribution, so the survival-curve diagnostic should still use the original censored residual dataset. Moreover fitting equations can force the adjusted sample mean to one, making its mean alone a weak diagnostic.
For the proposed mixture of a finite right censoring time and no right censoring, and
Consequently
When right censoring has positive probability this choice is unique; if , no correction is needed and any has the same effect. Its independence from is the content of exponential memorylessness: the expected extra lifetime after any right censoring time is one. Conditioning on an arbitrary independent right censoring time proves the same correction beyond this special two-point mixture.
Conditional on an event and the immediately preceding history, probabilities are proportional to the three instantaneous hazards. Put . The two zero-covariate subjects each have weight one, and the one-covariate subject has weight . The common baseline hazard cancels. Thus
Each individual with zero covariate has probability ; the first boxed probability is their combined probability. Conditioning on an event at a specified continuous time can be understood by the limiting conditional event probabilities in a short interval.
The hazard-weighted covariate mean is , so the Schoenfeld function at the true coefficient is
Multiplying by the two conditional probabilities gives
This verifies the score-centering property directly for this risk set.
For an event at from subject , with covariate vector , define the Schoenfeld function
The second term is the hazard-weighted mean covariate in the risk set just before the event. The Schoenfeld residual is this function evaluated at the fitted coefficient, . Calculate one residual vector per event, using every at-risk subject, including those who will subsequently be censored. There is no ordinary event residual assigned at a right censoring time.
The Cox partial likelihood score function is . At the true constant coefficient in a Cox proportional-hazards model, the conditional event subject is selected with weights proportional to , so each Schoenfeld function has conditional mean zero. If the coefficient varies with time, that centering changes. Plot residuals against event time or a transformation of it, smooth them, and investigate departures from zero. Scaled Schoenfeld residuals account for the risk-set covariate variance and can display departures in coefficient units; score function tests based on residual-time association provide a formal check. Risk-set composition affects unscaled residual variance, and the total residual score function can be zero by fitting even when a time trend is present.
Use the Aalen–Johansen estimator of the cumulative incidence function, updating the overall Kaplan–Meier estimator for either event:
Right censoring changes subsequent risk sets, not the survival function by itself. Starting with the given estimates at , the complete calculation is
The middle event is of the competing type: it decreases overall survival while leaving the disease cumulative incidence function unchanged at that instant. The event-free intervals leave every estimate and risk set unchanged.
At the final time, both the event subject and the subject censored at that time are in the just-before risk set, so its denominator is eight. This is the usual event-before-censoring convention for recorded ties. After the event and right censoring, six subjects remain at risk. Consequently
The nine numbered source items are the inputs to this single calculation, not nine further questions.