Academy

Basic concepts, risk-time and timescales

Lesson 1 of 19 · 10 min · part of Survival analysis

Survival analysis is what you reach for when the outcome is not whether something happened but when — and when, for some people, it has not happened yet.

That second clause is the whole subject. If everyone in the study had reached the event you could use ordinary regression on the time. You cannot, because studies end, people move away, and some outcomes never arrive. The methods here exist to use those incomplete observations rather than discard them.

Twelve people, followed

Here is a small study, drawn twice.

A dot is a death, a bar is a patient lost to follow-up,an arrow is a patient still followed when the study closed.On the calendar06121824Study closesCalendar months since the study openedLined up at each patient's own entry: time since entry0481216Months since each patient entered
Twelve patients enter the study as they are recruited, so on the calendar their follow-up starts at different times (top). Six end in a death. Four are lost to follow-up and two are still being followed when the study closes at month 24: all six are censored, and each was at risk up to the moment its line ends. Lined up at each patient's own entry (bottom), the same twelve lines start at zero: that is the clock a survival analysis counts on, time since entry. Added up they make 92 months, or 7.7 person-years, of time at risk.

Each line is one person's follow-up. It starts when they entered the study and runs until something ends it: a death, a loss to follow-up (the person moved, or stopped attending), or the closing date of the study. Only the death is the event. The other six lines end with the event not having happened yet, and what you know about those people is a floor and not a value: they survived at least this long. That is censoring, and it is the reason survival analysis exists.

The top panel is the calendar, where recruitment is spread over ten months. The bottom panel lines the same twelve people up at their own entry. That is the clock the methods count on: time since entry. Everything that follows is a calculation on the lines in the bottom panel.

Risk-time, not people

The unit of analysis is not the person. It is the time each person was at risk: the interval during which they were being observed and the event could have been recorded. Someone followed for six months and someone followed for six years contribute very differently to a rate, and a method that counts them equally is answering a different question from the one you asked.

A worked example you can do by hand. Two clinics each record 15 deaths over the same calendar years. Clinic A followed its patients for 1,500 person-years altogether; clinic B, whose patients joined later or left earlier, for 1,000.

  • Clinic A: 15 deaths in 1,500 person-years is 0.010 a year, or 10 per 1,000 person-years.
  • Clinic B: 15 deaths in 1,000 person-years is 0.015 a year, or 15 per 1,000 person-years.

The same number of deaths, and clinic B's patients are dying 50% faster. Counting deaths per patient cannot see that, and a rate (events divided by time at risk) can. Every method in this course is built on it, which is why the denominator is person-years and never people.

What a censored person adds

A censored person adds time. Everyone in the bottom panel was at risk from entry until their line ends, so the six censored people count in the denominator for as long as they were watched. Leave them out and you throw away the information, and you keep the same six deaths over much less time, which overstates the rate. The listing below shows both.

Three decisions before any estimate

Every analysis in this course starts by settling three things, and the figure shows each of them:

  • What counts as the event. Here it is death. A loss to follow-up, or the study closing, is not the event, so those people are censored.
  • When the clock starts. Here, at entry, which is why every line in the bottom panel starts at zero.
  • Who is at risk, and when. A person is at risk from entry until their line ends, and no longer.

Get one wrong and every command afterwards runs perfectly and answers a different question. The third lesson shows how to tell the software all three in a line.

Choosing the timescale

Before anything is estimated you have to say what t means, and it is a modelling decision rather than a data-entry one:

  • time since randomisation (or enrolment) — the default in a trial, because the intervention starts the clock, and the one the bottom panel uses
  • time since diagnosis — usually right in an observational cancer study
  • attained age — often right when the outcome is strongly age-driven, and frequently the one people forget to consider

The same dataset analysed on two timescales gives two different answers, and both can be correct. The wrong one is the one you did not choose deliberately.

Run it

The listing below holds these twelve people as data, so it runs as it stands, with nothing to download. It adds up the events and the time at risk and gives the rate, then repeats it with the censored people left out. Change a number and run it again: lengthen a censored patient's follow-up and the deaths stay at six while the person-years grow.

What to take from this

  • A survival analysis counts time at risk, and an incomplete observation still contributes the time it was watched.
  • A rate is events over person-time. A count of events over a count of people cannot tell 1,500 person-years from 1,000.
  • The timescale is a decision you make first, and it changes the answer.

The next lesson takes the assumption behind censoring apart: what happens when leaving the study is itself a sign of how a person was doing.

LISTING 1.1 · STATABasic concepts, risk-time and timescalesRun in your own Statasurvival-analysis-01.do
* Twelve patients, invented for this lesson. months is
* how long each was followed. died is 1 if the follow-up
* ended in a death, and 0 if it ended without one (the
* patient was lost, or the study closed): censored.
clear
input id months died
 1  2 1
 2  3 0
 3  4 1
 4  4 1
 5  5 0
 6  6 1
 7  8 0
 8  9 1
 9 10 0
10 12 1
11 14 0
12 15 0
end

* Time at risk, in years, added up over everybody: censored
* patients count up to the moment they left.
generate years = months / 12
quietly summarize years
local py = r(sum)
quietly summarize died
local events = r(sum)
display "events " `events' ", person-years " %5.2f `py'
display "per person-year " %5.2f (`events' / `py')
display "per 1000 person-years " %6.0f (1000 * `events' / `py')

* Leave the censored patients out and the same six deaths sit
* over far less time: a different, and wrong, rate.
quietly summarize years if died == 1
local py_d = r(sum)
display "dropping the censored: " %6.0f (1000 * `events' / `py_d')
LISTING 1.1 · RBasic concepts, risk-time and timescalesRun in your own Rsurvival-analysis-01.R
# Twelve patients, invented for this lesson. months is
# how long each was followed. died is 1 if the follow-up
# ended in a death, and 0 if it ended without one (the
# patient was lost, or the study closed): censored.
d <- data.frame(
  id = 1:12,
  months = c(2, 3, 4, 4, 5, 6, 8, 9, 10, 12, 14, 15),
  died = c(1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0)
)

# Time at risk, in years, added up over everybody: censored
# patients count up to the moment they left.
events <- sum(d$died)
py <- sum(d$months) / 12
c(
  events = events,
  person_years = py,
  per_person_year = events / py,
  per_1000py = 1000 * events / py
)

# Leave the censored patients out and the same six deaths sit
# over far less time: a different, and wrong, rate.
1000 * events / (sum(d$months[d$died == 1]) / 12)
Academy