Solution (source code)

= Solution

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 $k+1$ starts at the observed end of episode $k$. 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. \b[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.