From Cohort Records to an Andersen–Gill Fit
A cohort with repeated events contributes more than one event time for some people, so its data cannot be reduced to a single “time to first event” without changing the question. The Andersen–Gill (AG) model represents a subject’s recurrent events as a counting process and relates the event intensity at each time to covariates. The practical analysis therefore depends on getting three things right: which subjects are at risk at each event time, which covariate values apply then, and which records belong to the same subject.
The analysis below uses total follow-up time as its clock. At an event time, a subject who has had a previous event remains at risk if follow-up continues; the event does not automatically remove that subject. The AG model uses a common covariate effect across recurrences rather than giving each event order its own effect.
For a subject followed from entry to exit, a common data representation uses intervals \((\text{start},\text{stop}]\). Each row records a period during which covariates are constant; an event indicator marks whether an event occurred at the row’s stop time. Split a subject’s follow-up at each event and at any time a covariate changes. Multiple rows for one person are not independent subjects. All of that person’s event and interval records retain the same subject identifier.
The standard partial-likelihood analysis assumes correctly identified event times and risk intervals, covariate values known just before each event, and censoring or loss to follow-up that is noninformative for the event process conditional on the modeled history and covariates. The proportional-intensity specification requires the covariate effect to be common over time and event order, unless the model explicitly includes interactions or time-varying effects. The baseline intensity is left unspecified. Tied event times require an appropriate tied-event method; the examples below have distinct event times.
Worked Cohort: Six Subjects and Six Events
Worked Example: Fitting a Binary Treatment Effect
Suppose a hypothetical cohort contains six subjects followed on the total-time scale. A treatment indicator \(Z_i\) is fixed at baseline. Subjects A, B, and C have \(Z_i=1\); D, E, and F have \(Z_i=0\). A and the other subjects remain under observation through time 7, with administrative censoring after the last event. The event history is:
| Subject | Treatment \(Z_i\) | Event times |
|---|---|---|
| A | 1 | 2, 5 |
| B | 1 | 3 |
| C | 1 | 4 |
| D | 0 | 6 |
| E | 0 | 7 |
| F | 0 | None |
The six distinct event times are 2, 3, 4, 5, 6, and 7. There is no censoring before the final event, so all six subjects are at risk at each event time. A remains at risk after the event at time 2 and has a second event at time 5. The model is \(\lambda_i(t)=Y_i(t)\lambda_0(t)\exp(\beta Z_i)\); its partial likelihood compares the covariate value for each event subject with the values in that event’s risk set.
At every event time, the risk-set denominator is \(3e^\beta+3\), because three subjects are treated and three are untreated. Four events occur in treated subjects (A twice, B once, and C once), and two occur in untreated subjects (D and E). Ignoring factors that do not depend on \(\beta\), the partial likelihood is
The log partial likelihood is \(\ell(\beta)=4\beta-6\log(3e^\beta+3)\). Differentiating gives the score
Set the score to zero and write \(q=e^\beta\):
Thus, under this fitted model, the estimated event intensity for a treated subject is \(e^{\hat\beta}=2\) times the intensity for an untreated subject at the same time and with the same modeled history. This is an intensity ratio, not a ratio of the subjects’ total event counts, and it does not establish that treatment caused the difference. The calculation estimates a common effect across recurrences; it does not estimate a separate treatment effect for first and later events.
Constructing Event-Time Records and Risk Sets
Worked Example: Entry, Censoring, and Event-Time Contributions
Consider a second hypothetical cohort with treatment coded \(Z=1\) for A and C and \(Z=0\) for B and D. A enters at time 0, has events at 2 and 6, and is censored at 8. B enters at 0, has events at 1 and 4, and is censored at 5. C enters at 3, has an event at 7, and is censored at 9. D enters at 0, has no event, and is censored at 9. The intervals below use the convention that an event at time \(t\) is included at the right endpoint of \((\text{start},\text{stop}]\).
| Subject | Start–stop intervals and event indicators | \(Z\) |
|---|---|---|
| A | (0, 2] event; (2, 6] event; (6, 8] censored | 1 |
| B | (0, 1] event; (1, 4] event; (4, 5] censored | 0 |
| C | (3, 7] event; (7, 9] censored | 1 |
| D | (0, 9] censored | 0 |
C is not in the risk set before entry at time 3. B remains at risk after the event at time 1, until censoring at 5. For the five ordered event times, the risk sets and partial-likelihood contributions are as follows. Write \(q=e^\beta\).
- At time 1, B has the event and \(R(1)=\{A,B,D\}\), giving contribution \(1/(2q+1)\).
- At time 2, A has the event and \(R(2)=\{A,B,D\}\), giving contribution \(q/(2q+1)\).
- At time 4, B has the event and \(R(4)=\{A,B,C,D\}\), giving contribution \(1/(2q+2)\).
- At time 6, A has the event and \(R(6)=\{A,C,D\}\), giving contribution \(q/(2q+1)\).
- At time 7, C has the event and \(R(7)=\{A,C,D\}\), giving contribution \(q/(2q+1)\).
For example, at time 4 the risk set includes C, who entered at 3, and B, who has already had an event but is still under observation. At \(\beta=0\), each subject has weight \(e^{\beta Z}=1\), so the five contributions multiply to
The full partial likelihood, apart from factors independent of \(\beta\), is \(q^3/\{(2q+1)^4(2q+2)\}\). This calculation illustrates why risk-set membership must follow each subject’s actual entry, event, and censoring times rather than being copied from the first-event record. It also shows that a subject with a prior event remains eligible for later risk sets in this AG analysis.
Covariate Coding and Subject-Level Clustering
Worked Example: A Covariate That Changes During Follow-Up
Suppose a hypothetical cohort has three subjects, A, B, and C. Their exposure \(X_i(t)\) is binary and may change over time. All enter at 0. B has an event at 4 and is censored at 5; C has an event at 6 and is censored at 8; A is censored at 8. Exposure values immediately before time 4 are A=1, B=0, and C=1. At time 6, A has changed to 0 and C remains at 1. The data must split A’s record at the exposure-change time, so the value used at each event is the value in force just before that event.
At time 4, \(R(4)=\{A,B,C\}\). With \(q=e^\beta\), B’s event contribution is \(1/(2q+1)\), because the two exposed subjects have weight \(q\) and B has weight 1. At time 6, B is no longer under observation, so \(R(6)=\{A,C\}\); C’s event contribution is \(q/(q+1)\). At \(\beta=\log(2)\), these contributions are \(1/(2(2)+1)=1/5\) and \(2/(2+1)=2/3\), with product \(2/15\). These are contributions to the partial likelihood at a specified coefficient, not a fitted estimate from these two events.
Each subject’s intervals and event records share a subject identifier. For robust inference, the cluster is the person, not the interval or event: all of A’s rows form one cluster, all of B’s rows a second, and all of C’s rows a third. Treating repeated rows as independent clusters would break the within-subject grouping needed for a subject-level sandwich variance. The fitted coefficient itself is obtained from the partial likelihood; clustering concerns the variance calculation, not a change to the coefficient’s basic intensity-ratio interpretation.
Checking the Fit and Comparing the Approach
Before interpreting an AG estimate, check the data representation and the model’s scientific plausibility. Useful checks include confirming that event indicators match the source event history, that no subject appears in a risk set before entry or after exit, and that covariates are updated at their actual change times. Plot or summarize observed event counts over follow-up and inspect whether fitted covariate effects appear stable over time. A treatment-by-time term or residual-based diagnostic can help reveal departures from a constant effect, but any such extension changes the model being fit.
Also examine whether event order appears important. The basic AG model imposes a common covariate effect for every recurrence and does not require a subject to have experienced the previous event order before entering a risk set. If the event intensity after a first recurrence differs systematically from that after later recurrences, this common-effect structure may be too restrictive. Recurrent-event alternatives encode different risk-set or marginal estimands; the choice should follow the scientific question, not merely which model gives a preferred result.
| Approach | Risk-set emphasis | What to consider |
|---|---|---|
| Andersen–Gill | Subjects remain at risk for further events while observed | Common covariate effect across event orders; total-time clock |
| PWP models | Risk sets depend on having reached a specified event order | Useful when event-order conditioning is central |
| WLW models | Separate marginal event-order outcomes and risk sets | Targets a different marginal formulation and requires attention to dependence |
| Marginal event-rate summaries | Compare event counts relative to accumulated follow-up | Directly summarize rates but do not provide the same conditional intensity model |
The AG model is not automatically appropriate just because the data contain repeated events. It can obscure heterogeneity between subjects, may be sensitive to informative censoring, and can be inadequate if event history changes the effect in a way not represented in the model. A robust variance can accommodate some within-subject dependence in inference, but it does not repair an incorrectly defined risk set, informative censoring, confounding, or a scientifically inappropriate intensity model.
Common Mistakes and Practical Limits
- Dropping events after the first. In AG data, each recurrence contributes an event record, and prior events do not by themselves remove a subject from later risk sets.
- Counting rows as people. Multiple intervals and events from one subject remain one subject cluster for robust variance estimation.
- Using the wrong covariate value. An event’s covariate vector must be the value just before that event, not a later value or an overall subject average.
- Confusing a rate ratio with a cumulative event-count ratio. The exponentiated coefficient compares conditional intensities at a given time under the model; it does not directly state how many events each person will experience over follow-up.
- Assuming robust standard errors fix every problem. Clustering addresses variance dependence at the subject level; it does not correct bias from the wrong estimand, misspecified covariates, or informative observation.
A sound report states the time scale, entry and censoring rules, event and covariate coding, the AG intensity model, the common-effect assumption, and whether inference uses subject-clustered robust standard errors. Include the estimate and its exponentiated intensity ratio with units or context. Do not imply a causal treatment effect unless the study design and assumptions support that interpretation.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- A subject has events at times 2 and 5 and is observed through time 8. Is the subject in the AG risk set just before time 5?
- In a binary-covariate AG model, \(\hat\beta=\log(1.5)\). State the estimated effect in context without describing it as a cumulative event-count ratio.
- A participant enters at time 3 and has an event at time 6. Should that participant be included in the risk set at time 2? Explain.
- A data file has four rows for one person, each representing a follow-up interval. How many subject clusters does that person contribute to robust variance estimation?
Solutions. (1) Yes. The prior event does not remove the subject from the risk set while follow-up continues. (2) The fitted conditional event intensity is estimated to be 1.5 times as high for a one-unit increase in the covariate, holding other modeled covariates and time fixed. (3) No. The person has not entered observation by time 2, so \(Y_i(2)=0\). (4) One. The four rows all belong to the same subject cluster.