the kaplan-meier estimator - myweb

33
Kaplan-Meier estimate: Derivation Kaplan-Meier estimate: Example The Kaplan-Meier Estimator Patrick Breheny September 10 Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 1 / 33

Upload: others

Post on 20-Mar-2022

7 views

Category:

Documents


0 download

TRANSCRIPT

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

The Kaplan-Meier Estimator

Patrick Breheny

September 10

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 1 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

IntroductionMaximizing the nonparametric likelihood

Introduction

• The likelihood construction techniques that we introduced lastweek can be used to estimate the survival/hazard/distributionfunctions for any parametric model of survival time• As I have alluded to in the past, however, the distributions ofsurvival times are often difficult to parameterize• Our goal for today is to develop nonparametric estimates forthese distributions, with a particular emphasis on the survivalfunction S(t)

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 2 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

IntroductionMaximizing the nonparametric likelihood

Empirical survival function

• In the absence of censoring, estimating S(t) would bestraightforward• We could simply use the empirical survival function

S(t) = #{i : ti > t}n

• With censored observations, however, we don’t always knowwhether Ti > t or not

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 3 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

IntroductionMaximizing the nonparametric likelihood

Nonparametric likelihood

• As we discussed last week, likelihood provides a natural wayto proceed with inference in the presence of censoring• The likelihood of a survival function S given observed,

right-censored data is

L(S|Data) =n∏

i=1P(Ti = ti)diP(Ti > ti)1−di

=n∏

i=1{S(t−i )− S(ti)}diS(ti)1−di

• This expression is a bit different from the likelihoods we sawlast week

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 4 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

IntroductionMaximizing the nonparametric likelihood

Nonparametric likelihood (cont’d)

• In particular, it is not the likelihood of a parameter, but of ageneric survival function S• The set of possible values we must consider is not just aninterval of parameter values, but rather the entire set of allpossible survival functions• This is the basic idea of nonparametric statistics: rather thanspecify a parametric form for S(·|θ) and carry out inferenceconcerning θ, we adopt procedures that deal directly with Sitself

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 5 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

IntroductionMaximizing the nonparametric likelihood

Estimating S

• For today, we will focus on the question of estimating S• A natural estimate is to choose the value of S that maximizesL(S); this is the nonparametric maximum likelihood estimator• In other words, we must determine, out of the set of allpossible survival functions, which function maximizes L(S)

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 6 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

IntroductionMaximizing the nonparametric likelihood

Estimating S: First steps

• This might sound daunting, but it turns out to be easier thanyou would think• Let’s begin by making two observations that greatly restrictthe possible values of S that we must consider◦ In order to maximize the likelihood, S must put positive point

mass at any time t at which a subject was observed to fail(otherwise S(t−i )− S(ti) would be zero)

◦ In order to maximize the likelihood, S cannot put anyprobability at times other than those at which subjects wereobserved to fail (redistributing that probability to next failuretime would always increase the likelihood)

• Thus, we really only need to determine how much point massto put at each observed failure time

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 7 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

IntroductionMaximizing the nonparametric likelihood

Rewriting in terms of observed failure times

• Since the observed failure times are so critical here, let’srewrite the problem in terms of the observed failure times0 = t0 < t1 < t2 < · · · < tJ < tJ+1 =∞, and let

dj ≡ # of failures at time tjnj ≡ # at risk at time t−jcj ≡ # censored during the interval [tj , tj+1)

• In terms of this new notation, we can rewrite the earlierlikelihood as

L(S) =J∏

j=1{S(t−j )− S(tj)}djS(tj)cj

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 8 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

IntroductionMaximizing the nonparametric likelihood

Solving for λ

• Next, let’s rewrite the likelihood in terms of the hazardcomponents, λ1, . . . , λJ

• Doing so yields

L(λ) =∏j

λdj

j

j−1∏k=1

(1− λk)dj

j∏k=1

(1− λk)cj

=

∏j

λdj

j (1− λj)nj−dj

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 9 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

IntroductionMaximizing the nonparametric likelihood

Solving for λ (cont’d)

• Thus, the joint likelihood for λ consists of j separatecomponents in which λj appears only in the jth component• Furthermore, each component is equivalent to a binomiallikelihood, so

λj = dj/nj

and

S(t) =∏tj≤t

(1− λj)

=∏tj≤t

nj − dj

nj

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 10 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

IntroductionMaximizing the nonparametric likelihood

Kaplan-Meier estimator

• The estimator on the previous slide was originally proposed byKaplan and Meier in 1958, and is known as the Kaplan-Meierestimator (or product limit estimator, which is the nameKaplan and Meier proposed)• This approach has come to be – by far – the most commonway of estimating and summarizing survival curves• The approach is so widespread, in fact, that Kaplan & Meier’soriginal paper is the most highly cited paper in the history ofstatistics, and the 11th most highly cited paper in all ofscience

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 11 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

GVHD study

• To illustrate how Kaplan-Meier estimation works, let’s apply itto a study involving graft-versus-host disease (GVHD) in bonemarrow transplant recipients• The patients in the study have a condition called severeaplastic anemia, in which the bone marrow produces aninsufficient number of new blood cells• These patients were given a bone marrow transplant from acompatible family member• A serious complication of bone marrow transplantation isGVHD, in which the immune cells produced by the new bonemarrow recognize the recipient as a foreign body and mountan attack

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 12 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

GVHD study (cont’d)

• To ward off GVHD, the recipients were randomized to receiveone of two drug combinations:◦ Methotrexate (MTX)◦ Methotrexate and cyclosporine (MTX + CSP)

• The goal of the study is to determine whether treatmentaffected the occurrence of GVHD and if so, which treatmentis superior

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 13 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Data (by subject)

• Like elsewhere in statistics, survival data is typically organizedwith each individual subject occupying a row and the outcomeand various covariates occupying the columns of the data set• One difference, however, is that in survival analysis, twocolumns are required to denote the outcome (ti and di):

Group Time StatusMTX+CSP 3 NoMTX+CSP 8 YesMTX+CSP 10 YesMTX+CSP 12 NoMTX+CSP 16 Yes

. . .

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 14 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Data (by time)

As we saw in the derivation of the KM estimator, however, for thepurposes of analysis it is often helpful to re-express the data interms of the observed failure times:

Therapy Time GVHDMTX+CSP 3 NoMTX+CSP 8 YesMTX+CSP 10 YesMTX+CSP 12 NoMTX+CSP 16 Yes

. . .

t n(t) d(t)0 32 03 32 04 31 08 31 19 30 0

10 30 116 28 1

. . .

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 15 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

MTX alone group

In the MTX alone group,

Therapy Time GVHDMTX 9 YesMTX 11 YesMTX 12 YesMTX 20 YesMTX 20 YesMTX 22 YesMTX 25 YesMTX 25 YesMTX 25 NoMTX 28 YesMTX 28 Yes

. . .

t n(t) d(t)0 32 09 32 1

11 31 112 30 120 29 222 27 125 26 228 23 2

. . .

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 16 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

S(t): MTX + CSP

t n(t) d(t)0 32 08 31 1

10 30 116 28 1

. . .

t n(t)−d(t)n(t) S(t)

0 1 18 30/31 .968

10 29/30 .93516 27/28 .902

. . .

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 17 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

S(t): MTX alone

In the MTX group,

t n(t) d(t)0 32 09 32 1

11 31 112 30 120 29 222 27 125 26 228 23 2

. . .

t n(t)−d(t)n(t) S(t)

0 1 19 31/32 .969

11 30/31 .93812 29/30 .90620 27/29 .84422 26/27 .81225 24/26 .75028 21/23 .685

. . .

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 18 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Kaplan-Meier curve: GVHDThe result of all these calculations is usually summarized in a plotcalled a Kaplan-Meier curve:

0 20 40 60 80

0.0

0.2

0.4

0.6

0.8

1.0

Time on study (Days)

Pro

babi

lity

(GV

HD

−fr

ee)

MTX MTX+CSP

32 29 18 16 MTX32 26 25 25 MTX+CSP

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 19 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Summary statistics

• Summary statistics for time-to-event data are typically derivedfrom the Kaplan-Meier estimates• For example, in this study we might report estimates of theprobability of remaining GVHD-free at 60 days of 84% in theMTX+CSP group and 52% in the MTX alone group• This can be obtained simply by reading the Kaplan-Meiercurve “vertically”• One can also read the Kaplan-Meier curve “horizontally” toobtain estimates of quantiles

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 20 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Median survival times

• One quantile of particular interest is the median; i.e., the timeat which the survival function drops below 0.5• In the case where death is the outcome, this is known as the

median survival time and is almost always reported (if it canbe estimated)• For our GVHD example, the median time to event cannot beestimated since S(t) never reaches 0.5; to see what the idea,though, let’s briefly turn to data from a clinical trial of acancer drug called Avastin

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 21 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Kaplan-Meier curve: Avastin study

n engl j med

350;23

www.nejm.org june

3, 2004

bevacizumab plus combination chemotherapy for metastatic colorectal cancer

2339

treatment

The median duration of therapy was 27.6 weeks inthe group given IFL plus placebo and 40.4 weeksin the group given IFL plus bevacizumab. The per-centage of the planned dose of irinotecan that wasgiven was similar in the two groups (78 percent inthe group given IFL plus placebo and 73 percent inthe group given IFL plus bevacizumab).

As of April 2003, 33 patients in the group givenIFL plus placebo and 71 in the group given IFL plusbevacizumab were still taking their assigned initialtherapy. The rates of use of second-line therapiesthat may have affected survival, such as oxaliplatinor metastasectomy, were well balanced betweenthe two groups. In both groups, approximately 50percent of patients received some form of second-line therapy; 25 percent of all patients received ox-aliplatin, and less than 2 percent of patients under-went metastasectomy.

efficacy

The median duration of overall survival, the primaryend point, was significantly longer in the groupgiven IFL plus bevacizumab than in the group givenIFL plus placebo (20.3 months vs. 15.6 months),which corresponds to a hazard ratio for death of0.66 (P<0.001) (Table 3 and Fig. 1), or a reductionof 34 percent in the risk of death in the bevacizu-mab group. The one-year survival rate was 74.3 per-cent in the group given IFL plus bevacizumab and63.4 percent in the group given IFL plus placebo(P<0.001). In the subgroup of patients who re-ceived second-line treatment with oxaliplatin, themedian duration of overall survival was 25.1 monthsin the group given IFL plus bevacizumab and 22.2months in the group given IFL plus placebo.

The addition of bevacizumab to IFL was associ-ated with increases in the median duration of pro-gression-free survival (10.6 months vs. 6.2 months;hazard ratio for progression, 0.54, for the compar-ison with the group given IFL plus placebo;P<0.001); response rate (44.8 percent vs. 34.8 per-cent; P=0.004); and the median duration of re-sponse (10.4 months vs. 7.1 months; hazard ratiofor progression, 0.62; P=0.001) (Table 3). Figure 2shows the Kaplan–Meier estimates of progression-free survival. Treatment effects were consistentacross prespecified subgroups, including those de-fined according to age, sex, race, ECOG perfor-mance status, location of the primary tumor, pres-ence or absence of prior adjuvant therapy, duration

of metastatic disease, number of metastatic sites,years since the diagnosis of colorectal cancer, pres-ence or absence of prior radiotherapy, baselinetumor burden, and serum concentrations of albu-min, alkaline phosphatase, and lactate dehydroge-nase (data not shown).

Figure 1. Kaplan–Meier Estimates of Survival.

The median duration of survival (indicated by the dotted lines) was 20.3 months in the group given irinotecan, fluorouracil, and leucovorin (IFL) plus bevacizumab, as compared with 15.6 months in the group given IFL plus pla-cebo, corresponding to a hazard ratio for death of 0.66 (P<0.001).

15.6 20.3

100

Ove

rall

Surv

ival

(%) 80

60

40

20

00 10 20 30 40

IFL+bevacizumab

IFL+placebo

Months

No. at RiskIFL+bevacizumabIFL+placebo

73 51

20 12

1 0

0 0

178 139

320 292

362 363

402 411

Figure 2. Kaplan–Meier Estimates of Progression-free Survival.

The median duration of progression-free survival (indicated by the dotted lines) was 10.6 months in the group given irinotecan, fluorouracil, and leuco-vorin (IFL) plus bevacizumab, as compared with 6.2 months in the group giv-en IFL plus placebo, corresponding to a hazard ratio for progression of 0.54 (P<0.001).

6.2 10.6100Pr

ogre

ssio

n-fr

ee S

urvi

val (

%)

80

60

40

20

00 10 20 30

IFL+bevacizumab

IFL+placebo

Months

No. at RiskIFL+bevacizumabIFL+placebo

6 8

0 0

36 17

143 73

269 225

402 411

The New England Journal of Medicine Downloaded from nejm.org at UNIV OF KENTUCKY on April 24, 2012. For personal use only. No other uses without permission.

Copyright © 2004 Massachusetts Medical Society. All rights reserved.

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 22 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

The survival package

• Finally, let’s discuss the R functions for constructing theKaplan-Meier estimate and plotting KM curves• In this course, we will make extensive use of the survival

package in R• The package is bundled by default with R, meaning that youdo not have to install it, although you will have to load it withlibrary(survival)

before you can use it

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 23 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Surv objects

The survival package has a construct called a Surv object tohandle survival outcomes, which are one entity but with twocomponents (ti and di):

> S <- with(Data, Surv(Time, Status))> class(S)[1] "Surv"> head(S)[1] 3+ 8 10 12+ 16 17> head(S[,1])[1] 3 8 10 12 16 17> head(S[,2])[1] 0 1 1 0 1 1

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 24 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

survfit

• The function in survival for constructing Kaplan-Meierestimates is called survfit:fit <- survfit(S ~ Data$Group)

where S is a Surv object• S does not have to be constructed ahead of time; this alsoworks (and is probably better coding practice):fit <- survfit(Surv(Time, Status) ~ Group, Data)

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 25 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Summarizing the survfit object

By printing the object, we get a rough summary of each group,although the summary revolves around the median, which in ourcase cannot be estimated:

> fitn events median 0.95LCL 0.95UCL

Group=CSP 32 15 NA 35 NAGroup=CSP+MTX 32 5 NA NA NA

Provided they can be estimated, we would see the median survivaltime in each group, along with upper and lower 95% confidenceinterval bounds (we’ll discuss how those are calculated in the nextlecture)

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 26 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Summarizing the survfit object (cont’d)

To find out more about the KM estimates at specific times, we canuse the summary function:

> summary(fit, time=40)Group=CSP

time n.risk n.event survival std.err 95%LCL 95%UCL40.000 18.000 13.000 0.587 0.088 0.437 0.788

Group=CSP+MTXtime n.risk n.event survival std.err 95%LCL 95%UCL

40.000 25.000 5.0000 0.8353 0.0674 0.7131 0.9784

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 27 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

plot.survfit

• Once the Kaplan-Meier curve has been estimated, it can beplotted in a straightforward manner:plot(fit)

• Some useful options to be aware of are◦ mark.time: Marks the times at which observations were

censored (default: TRUE)◦ xmax: Maximum time at which to plot S(t)◦ xscale: Set this to 365.25 to get curves displayed in years

instead of days, and so on

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 28 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Some limitations of the survival package

• The survival package is very mature, well-maintained, andwell-developed software with expansive support for almost allof the models we will discuss in this course• However, it is also old (originally written in S then ported toR) and has a few shortcomings that make it sometimesinconvenient to work with in practice:◦ Its plots are rather . . . basic◦ The internal data structure of a survfit object is

inconvenient to work with

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 29 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Option #1: Wrapper functions

• One option is just to write a wrapper function that calls /works with the functions in survival to improve theappearance of plots, add options, etc.• For example, I’m providing (in fun.R) the Plot() and

nrisk() functions:Plot(fit)nrisk(fit)

which I used to make the plot on slide 19; note that you mayneed to adjust the margins to avoid the number at riskconflicting with the legend• I’ve also provided median(fit) to return the median survivaltimes

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 30 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

Option #2: Other packages

• Another option is to use a different package for plotting• Several exist, but I’ll discuss one called survminer, which isfocused on constructing survival plots using ggplot2◦ If you’ve used ggplot2 before, you’ll likely find its usage

straightforward◦ If not, you may prefer option #1

• The package has lots and lots of options; I’ll only cover itsmost basic usage – for more information, check outhttps://rpkgs.datanovia.com/survminer/index.html

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 31 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

ggsurvplot()

ggsurvplot(fit, Data, risk.table=TRUE)

+

++

++

0.00

0.25

0.50

0.75

1.00

0 20 40 60Time

Sur

viva

l pro

babi

lity

Strata + +Group=MTX Group=MTX+CSP

32 29 18 1632 26 25 25Group=MTX+CSP

Group=MTX

0 20 40 60Time

Str

ata

Number at risk

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 32 / 33

Kaplan-Meier estimate: DerivationKaplan-Meier estimate: Example

GVHD dataR: survivalR: Other options

surv_summary()

Other useful functions survminer provides are surv_median()and surv_summary(), which organizes the survfit object into adata.frame, as opposed to a list of objects that need to becross-referenced with each other:

surv_summary(fit, Data)

time n.risk n.event n.censor surv std.err upper lower strata Group

9 32 1 0 0.969 0.032 1.000 0.910 Group=MTX MTX11 31 1 0 0.938 0.046 1.000 0.857 Group=MTX MTX12 30 1 0 0.906 0.057 1.000 0.811 Group=MTX MTX20 29 2 0 0.844 0.076 0.979 0.727 Group=MTX MTX22 27 1 0 0.812 0.085 0.960 0.688 Group=MTX MTX

. . .

Next time, we’ll discuss confidence bands for Kaplan-Meier curves

Patrick Breheny University of Iowa Survival Data Analysis (BIOS 7210) 33 / 33