Adjusted Survival Curves Analysis
Adjusted Survival Curves Analysis
Jan 2015
1 Introduction
Suppose we want to investigate to what extent some factor inuences survival, as an example
we might compare the experience of diabetic patients who are using metformin versus those on
injected insulin as their primary treatment modality. There is some evidence that metformin
has a positive inuence, particularly in cancers, but the ascertainment is confounded by the fact
that it is a rst line therapy: the patients on metformin will on average be younger and have
had a diabetes diagnosis for a shorter amount of time than those using insulin. Young people
live longer is not a particularly novel observation.
The ideal way to test this is with a controlled clinical trial. This is of course not always
possible, and assessments using available data that includes and adjusts for such confounders is
also needed. There is extensive literature and debate on this topic in the areas of modeling
and testing. The subtopic of how to create honest survival curve estimates in the presence of
confounders is less well known, and is the focus of this note.
Assume that we have an eect of interest, treatment say, and a set of possible confounding
variables. Creation a pair of adjusted survival curves has two parts: denition of a reference
population for the confounders, and then the computation of estimated curves for that popula-
tion. There are important choices in both steps. The rst, denition of a target, is often not
explicitly stated but can be critical. If an outcome diers with age, myocardial infarction say,
and two treatments also had age dependent ecacy, then the comparison will depend greatly on
whether we are talking about a population of young, middle aged, or older subjects.
The computational step has two main approaches. The rst, sometimes known as marginal
analysis, rst reweights the data such that each subgroup's weighted distribution matches that
of our population target. An immediate consequence is that all subgroups will be balanced
with respect to the confounding variables. We can then proceed with a simple analysis of
survival using the reformulated data, ignoring the confounders. The second approach seeks to
understand and model the eect of each confounder, with this we can then correct for them. From
a comprehensive overall model we can obtain predicted survival curves for any conguration of
variables, and from these get predicted overall curves for the reference population. This is often
called the conditional approach since we are using conditional survival curves given covariates
x.
A third but more minor choice is division of the covariates x into eects of interest vs.
confounders. For instance, we might want to see separate curves for two treatments, each
adjusted for age and sex. The reference population will describe the age and sex distribution.
1
1.0
3.38 − 4.71
Survival
0.4
0 2 4 6 8 10 12 14
Figure 1: Survival of 7874 residents of Olmsted County, broken into three cohorts based on FLC
value.
For simplicity we will use x to describe all the confounding variables and use c for the control
variable(s), e.g. treatment. The set c might be empty, producing a single overall curve, but this
is the uncommon case. As shown below, our two methods dier essentially in the order in which
the two necessary operations are done, balancing and survival curve creation.
2
5059 6069 7079 80+
FLC < 3.38 2585 (47) 1690 (30) 969 (17) 314 ( 6)
FLC 3.384.71 442 (29) 446 (29) 423 (28) 215 (14)
FLC > 4.71 121 (16) 187 (25) 224 (30) 224 (30)
Table 1: Comparison of the age distributions (percents) for each of the three groups.
a small portion (< 1%) of the total blood and marrow hematapoetic cell population in normal
patients. The normal human repertoire is estimated to contain over 108 unique immunoglobulins,
conferring a broad range of immune protection. In multiple myeloma, the most common form
of plasma cell malignancy, almost all of the circulating antigen will be identical, the product
of a single malignant clone. An electrophoresis examination of circulating immunoglobulins
will exhibit a spike corresponding to this unique molecule. This anomaly is used both as a
diagnostic method and in monitoring the course of the disease under treatment.
The presence of a similar, albeit much smaller, spike in normal patients has been a long
term research interest of the Mayo Clinic hematology research group [5]. In 1995 Dr Robert
Kyle undertook a population based study of this, and collected serum samples on 19,261 of the
24,539 residents of Olmsted County, Minnesota, aged 50 years or more [4]. In 2010 Dr. Angela
Dispenzieri assayed a sub fraction of the immunoglobulins, the free light chain (FLC), on 15,748
of these subjects who had sucient remaining sera from the original sample collection. All
studies took place under the oversight of the appropriate Institutional Review Boards, which
ensure rigorous safety and ethical standards in research.
A subset of the Dispenzieri study is available in the survival package as data set flchain.
Because the original study assayed nearly the entire population, there is concern that some
portions of the anonymized data could be linked to actual subjects by a diligent searcher, and
so only a subset of the study has been made available as a measure to strengthen anonymity.
It was randomly selected from the whole within sex and age group strata so as to preserve the
age/sex structure. The data set contains 3 subjects whose blood sample was obtained on the
day of their death. It is rather odd to think of a sample obtained on the nal day as predicting
death, or indeed for any results obtained during a patient's nal mortality cascade. There are
also a few patients with no follow-up beyond the clinic visit at which the assay occurred. We
have chosen in this analysis to exclude the handful of subjects with less than 7 days of follow-up,
leaving 7840 observations.
Figure 1 shows the survival curves for three subgroups of the patients: those whose total free
light chain (FLC) is in the upper 10% of all values found in the full study, those in the 7089th
percentile, and the remainder. There is a clear survival eect. Average free light chain amounts
rise with age, however, at least in part because it is eliminated through the kidneys and renal
function declines with age. Table 1 shows the age distribution for each of the three groups. In
the highest decile of FLC (group 3) over half the subjects are age 70 or older compared to only
23% in those below the 70th percentile. How much of the survival dierence is truly associated
with FLC and how much is simply an artifact of age? (The cut points are arbitrary, but we have
chosen to mimic the original study and retain them. Division into three groups is a convenient
number to illustrate the methods in this vignette, but we do not make any claim that such a
categorization is optimal or even sensible statistical practice.) The R code for gure 1 is shown
below.
3
> fdata <- flchain[flchain$futime >=7,]
> fdata$age2 <- cut(fdata$age, c(0,54, 59,64, 69,74,79, 89, 110),
labels = c(paste(c(50,55,60,65,70,75,80),
c(54,59,64,69,74,79,89), sep='-'), "90+"))
> fdata$group <- factor(1+ 1*(fdata$[Link] >7) + 1*(fdata$[Link] >9),
levels=1:3,
labels=c("FLC < 3.38", "3.38 - 4.71", "FLC > 4.71"))
> sfit1 <- survfit(Surv(futime, death) ~ group, fdata)
> plot(sfit1, [Link]=F, col=c(1,2,4), lty=1, lwd=2,
xscale=365.25, xlab="Years from Sample",
ylab="Survival")
> text(c(11.1, 10.5, 7.5)*365.25, c(.88, .57, .4),
c("FLC < 3.38", "3.38 - 4.71", "FLC > 4.71"), col=c(1,2,4))
3 Reference populations
There are a few populations that are commonly used as the reference group.
1. Empirical. The overall distribution of confounders x in the data set as a whole. For this
study we would use the observed age/sex distribution, ignoring FLC group. This is also
called the sample or data distribution.
3. Internal reference. A particular subset of the data is chosen as the reference, and other
subsets are then aligned with it.
4 Marginal approach
4.1 Selection
One approach for balancing is to select a subset of the data such that its distribution matches
the referent for each level of c, i.e., for each curve that we wish to obtain. As an example we
take a case-control like approach to the FLC data, with FLC high as the cases since it is the
smallest group. Table 2 shows a detailed distribution of the data with respect to age and sex.
The balanced subset has all 32 females aged 5054 from the high FLC group, a random sample of
32 out of the 738 females in the age 5054 low FLC group, and 32 out of 110 for the middle FLC.
Continue this for all age/sex subsets. We cannot quite compute a true case-control estimate for
4
Females
Age
FLC group 5054 5559 6064 6569 7074 7579 8089 90+
Low 738 638 490 442 376 254 224 24
Med 110 94 88 104 116 108 125 21
High 32 30 45 43 48 46 103 32
Males
Low 658 553 427 331 227 112 64 2
Med 111 127 124 130 110 90 63 6
High 26 33 39 61 66 65 74 15
Table 2: Detailed age and sex distribution for the study population
this data since there are not enough controls in the female 90+ category to be able to select
one unique control for each case, and likewise in the male 80-89 and 90+ age groups. To get
around this we will sample with replacement in these strata.
5
1.0
0.8
0.6
Survival
0.4
0 2 4 6 8 10 12 14
Figure 2: Survival curves from a case-control sample are shown as solid lines, dashed lines are
curves for the unweighted data set (as found in gure 1).
bty='n', lwd=2)
The survival curves for the subset data are shown in gure 2. The curve for the high risk group
is unchanged, since by denition all of those subjects were retained. We see that adjustment
for age and sex has reduced the apparent survival dierence between the groups by about half,
but a clinically important eect for high FLC values remains. The curve for group 1 has moved
more than that for group 2 since the age/sex adjustment is more severe for that group.
In actual practice, case-control designs arise when matching and selection can occur before
data collection, leading to a substantial decrease in the amount of data that needs to be gathered
and a consequent cost or time savings. When a data set is already in hand it has two major
disadvantages. The rst is that the approach wastes data; throwing away information in order to
achieve balance is always a bad idea. Second is that though it returns an unbiased comparison,
the result is for a very odd reference population.
One advantage of matched subsets is that standard variance calculations for the curves are
correct; the values provided by the usual Kaplan-Meier program need no further processing. We
can also use the usual statistical tests to check for dierences between the curves.
6
Call:
survdiff(formula = Surv(futime, death) ~ group, data = data2)
4.2 Reweighting
A more natural way to adjust the data distribution is by weighting. Let π(a, s), a = age group,
s = sex be a target population age/sex distribution for our graph, and p(a, s, i) the observed
probability of each age/sex/group combination in the data. Both π and p sum to 1. Then if
each observation in the data set is given a case weight of
π(a, s)
wasi = (1)
p(a, s, i)
the weighted age/sex distribution for each of the groups will equal the target distribution π. An
obvious advantage of this approach is that the resulting curves represent a tangible and well
dened group.
As an example, we will rst adjust our curves to match the age/sex distribution of the 2000
US population, a common reference target in epidemiology studies. The uspop2 data set is found
in later releases of the survival package in R. It is an array of counts with dimensions of age, sex,
and calendar year. We only want ages of 50 and over, and the population data set has collapsed
ages of 100 and over into a single category. We create a table tab100 of observed age/sex counts
within group for our own data, using the same upper age threshold. New weights are the values
π/p = [Link]/tab100.
> refpop <- uspop2[[Link](50:100),c("female", "male"), "2000"]
> [Link] <- refpop/sum(refpop)
> age100 <- factor(ifelse(fdata$age >100, 100, fdata$age), levels=50:100)
> tab100 <- with(fdata, table(age100, sex, group))/ nrow(fdata)
> [Link] <- rep([Link], 3)/ tab100 #new weights by age,sex, group
> range([Link])
[1] 0.7751761 Inf
There are innite weights! This is because the US population has coverage at all ages, but our
data set does not have representatives in every age/sex/FLC group combination; there are for
instance no 95 year old males in in the data set. Let us repeat the process, collapsing the US
population from single years into the 8 age groups used previously in table 2. Merging the per
age/sex/group weights found in the 3-dimensional array [Link] into the data set as per-subject
weights uses matrix subscripts, a useful but less known feature of R.
7
0.12
f
m
f
0.10
m
f
m
f
m
0.08
f
Fraction of population
m
f f
m m f
f f
f
0.06
m f f
m
m f
0.04
m
m m
m
0.02
f
f
m
m
0.00
Age group
Figure 3: Population totals for the US reference (red) and for the observed data set (black).
> temp <- [Link](cut(50:100, c(49, 54, 59, 64, 69, 74, 79, 89, 110)+.5))
> [Link]<- tapply(refpop, list(temp[row(refpop)], col(refpop)), sum)/sum(refpop)
> tab2 <- with(fdata, table(age2, sex, group))/ nrow(fdata)
> [Link] <- rep([Link], 3)/ tab2
> range([Link])
[1] 1.113898 34.002834
> index <- with(fdata, cbind([Link](age2), [Link](sex),
[Link](group)))
> fdata$uswt <- [Link][index]
> sfit3a <-survfit(Surv(futime, death) ~ group, data=fdata, weight=uswt)
A more common choice is to use the overall age/sex distribution of the sample itself as our
target distribution π, i.e., the empirical distribution. Since FLC data set is population based
and has excellent coverage of the county, this will not dier greatly from the US population in
this case, as is displayed in gure 3.
8
xaxt='n')
> axis(1, 1:8, levels(fdata$age2))
> tab2 <- with(fdata, table(age2, sex, group))/nrow(fdata)
> tab3 <- with(fdata, table(group)) / nrow(fdata)
> rwt <- rep(tab1,3)/tab2
> fdata$rwt <- rwt[index] # add per subject weights to the data set
> sfit3 <- survfit(Surv(futime, death) ~ group, data=fdata, weight=rwt)
> temp <- rwt[,1,] #show female data
> temp <- temp %*% diag(1/apply(temp,2,min))
> round(temp, 1) #show female data
age2 [,1] [,2] [,3]
50-54 1.0 2.2 11.4
55-59 1.0 2.2 10.6
60-64 1.1 2.0 5.8
65-69 1.1 1.6 5.7
70-74 1.2 1.3 4.7
75-79 1.3 1.0 3.7
80-89 1.7 1.0 1.8
90+ 2.7 1.0 1.0
The calculation of weights is shown above, and nishes with a table of the weights for the
females. The table was scaled so as to have a minimum weight of 1 in each column for simpler
reading. We see that for the low FLC group there are larger weights for the older ages, whereas
the high FLC group requires substantial weights for the youngest ages in order to achieve balance.
The resulting survival curve is shown in gure 4. The distance between the adjusted curves is
similar to the results from subset selection, which is as expected since both approaches are
correcting for the same bias, but results are now for an overall population distribution that
matches Olmsted County. The curves estimate what the results would have looked like, had
each of the FLC groups contained the full distribution of ages.
Estimation based on reweighted data is a common theme in survey sampling. Correct stan-
dard errors for the curves are readily computed using methods from that literature, and are
available in some software packages. In R the svykm routine in the survey package handles
both this simple case and more complex sampling schemes. Tests of the curves can be done
using a weighted Cox model; the robust variance produced by coxph is identical to the standard
Horvitz-Thompsen variance estimate used in survey sampling [1]. The robust score test from
9
1.0
0.8
0.6
Survival
0.4
0 2 4 6 8 10 12 14
Figure 4: Survival curves for the three groups using reweighted data are shown with solid lines,
the original unweighted analysis as dashed lines. The heavier solid line adjusts to the Olmsted
population and the lighter one to the US population.
coxph corresponds to a log-rank test corrected for weighting. (In the example below the svykm
function is only run if the survey package is already loaded, as the variance calculation is very
slow for this large data set.)
Note: including the cluster term in the coxph call causes it to treat the weights as resampling
values and thus use the proper survey sampling style variance. The default without that term
10
would be to treat the case weights as replication counts. This same alternate variance estimate
is also called for when there are correlated observations; many users will be more familiar with
the cluster statement in that context.
Inverse probability weighting Notice that when using the overall population as the target
distribution π we can use Bayes rule to rewrite the weights as
This last is precisely the probability estimated by a logistic regression model, leading to
inverse probability weighting as an alternate label for this approach. We can reproduce the
weights calculated just above with three logistic regression models.
> options([Link]="[Link]")
> gg <- [Link](fdata$group)
> lfit1 <- glm(I(gg==1) ~ factor(age2) * sex, data=fdata,
family="binomial")
> lfit2 <- glm(I(gg==2) ~ factor(age2) * sex, data=fdata,
family="binomial")
> lfit3 <- glm(I(gg==3) ~ factor(age2) * sex, data=fdata,
family="binomial")
> temp <- ifelse(gg==1, predict(lfit1, type='response'),
ifelse(gg==2, predict(lfit2, type='response'),
predict(lfit3, type='response')))
> [Link](1/temp, fdata$rwt)
[1] TRUE
If there were only 2 groups then only a single regression model is needed since P(group 2) =
1 - P(group 1). Note the setting of [Link], which causes the predicted vector to have the
same length as the original data even when there are missing values. This simplies merging the
derived weights with the original data set.
An advantage of the regression framework is that one can easily accommodate more variables
by using a model with additive terms and only a few selected interactions, and the model can
contain continuous as well as categorical predictors. The disadvantage is that such models are
often used without the necessary work to check their validity. For instance models with age +
sex could have been used above. This makes the assumption that the odds of being a member of
group 1 is linear in age and with the same slope for males and females; ditto for the models for
group 2 and group 3. How well does this work? Since the goal of reweighting is to standardize
the ages, a reasonable check is to compute and plot the reweighted age distribution for each c
group.
Figure 5 shows the result. The reweighted age distribution is not perfectly balanced, i.e.,
the `1', `2' and `3' symbols do no exactly overlay one another, but in this case the simple linear
model has done an excellent job. We emphasize that whenever the reweighting is based on a
simplied model then such a check is obligatory. It is quite common that a simple model is
11
3
25
+2
20
1
+
Weighted frequency (%)
3
1 3
2
+
15
1 1+
2
2 12
3 +
2 12
10
1
3 + +3
3
5
23
1+
Age group
Figure 5: The re-weighted age distribution using logistic regression with continuous age, for
females, FLC groups 13. The target distribution is shown as a +. The original unadjusted
distribution is shown as dashed lines.
not sucient and the resulting weight adjustment is inadequate. Like a duct tape auto repair,
proceeding forward as though the underlying problem has been addressed is then most unwise.
12
> c1 <- with(temp[temp$gg==1,], tapply(lwt, age2, sum))
> c2 <- with(temp[temp$gg==2,], tapply(lwt, age2, sum))
> c3 <- with(temp[temp$gg==3,], tapply(lwt, age2, sum))
> xtemp <- outer(1:8, c(-.1, 0, .1), "+") #avoid overplotting
> ytemp <- 100* cbind(c1/sum(c1), c2/sum(c2), c3/sum(c3))
> matplot(xtemp, ytemp, col=c(1,2,4),
xlab="Age group", ylab="Weighted frequency (%)", xaxt='n')
> ztab <- table(fdata$age2)
> points(1:8, 100*ztab/sum(ztab), pch='+', cex=1.5, lty=2)
> # Add the unadjusted
> temp <- tab2[,1,]
> temp <- scale(temp, center=F, scale=colSums(temp))
> matlines(1:8, 100*temp, pch='o', col=c(1,2,4), lty=2)
> axis(1, 1:8, levels(fdata$age2))
Rescaled weights As the weights were dened in equation 1, the sum of weights for each of
the groups is 7845, the number of observations in the data set. Since the number of subjects
in group 3 is one seventh of that in group 1, the average weight in group 3 is much larger. An
alternative is to dene weights in terms of the within group distribution rather than the overall
distribution, leading to the rescaled weights w∗
π(a, s)
w∗ = (2)
p(a, s|i)
P(group = i)
= (3)
P(group = i|age = a, sex = s)
Each group's weights are rescaled by the overall prevalence of the group. In its simplest form,
the weights in each group are scaled to add up to the number of subjects in the group.
13
5 Conditional method
In the marginal approach we rst balance the data set and then compute results on the adjusted
data. In the conditional approach we rst compute a predicted survival curve for each subject
that accounts for c group, age and sex, and then take a weighted average of the curves to get an
overall estimate for each c group. For both methods a central consideration is the population of
interest, which drives the weights. Modeling has not removed the question of who these curves
should represent, it has simply changed the order of operation between the weighting step and
the survival curves step.
5.1 Stratication
Our rst approach is to subset the data into homogeneous age/sex strata, compute survival
curves within each strata, and then combine results. We will use the same age/sex combinations
as before. The interpretation of these groups is dierent, however. In the marginal approach it
was important to nd age/sex groups for which the probability of membership within each FLC
group was constant within the strata (independent of age and sex, within strata), in this case
it is important that the survival for each FLC group is constant in each age/sex stratum. Ho-
mogeneity of membership within each stratum and homogeneity of survival within each stratum
may lead to dierent partitions for some data sets.
Computing curves for all the combinations is easy.
14
1.0
0.8
0.6
Survival
0.4
0.2
0.0
0 2 4 6 8 10 12 14
Figure 6: Estimated curves from a stratied model, along with those from the uncorrected t as
dashed lines.
> xtime <- seq(0, 14, length=57)*365.25 #four points/year for 14 years
> smat <- matrix(0, nrow=57, ncol=3) # survival curves
> serr <- smat #matrix of standard errors
> pi <- with(fdata, table(age2, sex))/nrow(fdata) #overall dist
> for (i in 1:3) {
temp <- allfit[1:16 + (i-1)*16] #curves for group i
for (j in 1:16) {
stemp <- summary(temp[j], times=xtime, extend=T)
smat[,i] <- smat[,i] + pi[j]*stemp$surv
serr[,i] <- serr[,i] + pi[j]*stemp$[Link]^2
}
}
> serr <- sqrt(serr)
> plot(sfit1, lty=2, col=c(1,2,4), xscale=365.25,
xlab="Years from sample", ylab="Survival")
> matlines(xtime, smat, type='l', lwd=2, col=c(1,2,4),lty=1)
Figure 6 shows the resulting averaged curves. Overlaid are the curves for the unadjusted model.
15
Very careful comparison of these curves with the weighted estimate shows that they have almost
identical spread, with just a tiny amount of downward shift.
There are two major disadvantages to the stratied curves. The rst is that when the original
data set is small or the number of confounders is large, it is not always feasible to stratify into
a large enough set of groups that each will be homogeneous. The second is a technical aspect of
the standard error estimate. Since the curves are formed from disjoint sets of observations they
are independent and the variance of the weighted average is then a weighted sum of variances.
However, when a Kaplan-Meier curve drops to zero the usual standard error estimate at that
point involves 0/0 and becomes undened, leading to the NaN (not a number) value in R. Thus
the overall standard error becomes undened if any of the component curves falls to zero. In the
above example this happens at about the half way point of the graph. (Other software packages
carry forward the se value from the last no-zero point on the curve, but the statistical validity
of this is uncertain.)
To test for overall dierence between the curves we can use a stratied test statistic, which
is a sum of the test statistics computed within each subgroup. The most common choice is the
stratied log-rank statistic which is shown below. The score test from a stratied Cox model
would give the same result.
5.2 Modeling
The other approach for conditional estimation is to model the risks due to the confounders.
Though we have left it till last, this is usually the rst (and most often the only) approach used
by most data analysts.
Let's start with the very simplest method: a stratied Cox model.
16
1.0
0.8
0.6
Survival
0.4
FLC low
FLC med
FLC high
0.2
0.0
0 2 4 6 8 10 12 14
Figure 7: Curves for the three groups, adjusted for age and sex via a risk model. Dotted lines
show the curves from marginal adjustment. Solid curves are for the simple risk model cfit4a.
This is a very fast and easy way to produce a set of curves, but it has three problems. First
is the assumption that this simple model adequately accounts for the eects of age and sex on
survival. That is, it assumes that the eect of age on mortality is linear, the sex dierence
is constant across all ages, and that the coecients for both are identical for the three FLC
groups. The second problem with this approach is that it produces the predicted curve for
a single hypothetical subject of age 64.3 years and sex 0, the means of the covariates, under
each of the 3 FLC scenarios. However, we are interested in the adjusted survival of a cohort
of subjects in each range of FLC, and the survival of an average subject is not the average
survival of a cohort. The third and most serious issue is that it is not clear exactly what these
adjusted curves represent exactly who is this subject with a sex of 0? Multiple authors
have commented on this problem, see Thomsen et al [8], Nieto and Coresh [6] or chapter 10 of
Therneau and Grambsh [7] for examples. Even worse is a Cox model that treated the FLC group
as a covariate, since that will impose an additional constraint of proportional hazards across the
3 FLC groups.
We can address this last problem problem by doing a proper average. A Cox model t can
produce the predicted curves for any age/sex combination. The key idea is to produce a predicted
survival curve for every subject of some hypothetical population, and then take the average of
these curves. The most straightforward approach is to retrieve the predicted individual curves
17
for all 7845 subjects in the data set, assuming each of the three FLC strata one by one, and take
a simple average for each strata. For this particular data set that is a bit slow since it involves
7845 curves. However there are only 98 unique age/sex pairs in the data, it is sucient to obtain
the 98 * 3 FLC groups unique curves and take a weighted average. We will make use of the
survexp function, which is designed for just this purpose. Start by creating a data set which
has one row for each age/sex combination along with its count. Then replicate it into 3 copies,
assigning one copy to each of the three FLC strata.
18
3
0.4
2
0.3
1
Deaths
crate
0.2
0
0.1
−1
−2
0.0
0 2 4 6 8 10 12 14 −2 −1 0 1 2 3
Figure 8: Left panel: comparison of Cox model based adjustment (solid) with the curves based
on marginal adjustment (dashed). The Cox model curves without (black) and with (red) an
age*sex interaction term overlay. Right panel: plot of the predicted relative risks from a Cox
model crate versus population values from the Minnesota rate table.
19
So why are the modeling results so dierent than either reweighting or stratication? Suspi-
cion rst falls on the use of a simple linear model for age and sex, so start by tting a slightly
more rened model that allows for a dierent slope for the two sexes, but is still linear in age.
In this particular data set an external check on the t is also available via the Minnesota death
rate tables, which are included with the survival package as [Link]. This is an array that
contains daily death rates by age, sex, and calendar year.
> par(mfrow=c(1,2))
> cfit4b <- coxph(Surv(futime, death) ~ age*sex + strata(group),
fdata)
> sfit4b <- survexp(~group, data=tdata3, ratetable=cfit4b, weights=count)
> plot(sfit4b, fun='event', xscale=365.25,
xlab="Years from sample", ylab="Deaths")
> lines(sfit3, [Link]=FALSE, fun='event', xscale=365.25, lty=2)
> lines(sfit4a, fun='event', xscale=365.25, col=2)
> temp <- median(fdata$[Link])
> mrate <- [Link][[Link](uage),, [Link](temp)]
> crate <- predict(cfit4b, newdata=tdata, reference='sample', type='lp')
> crate <- matrix(crate, ncol=2)[,2:1] # mrate has males then females, match it
> # crate contains estimated log(hazards) relative to a baseline,
> # and mrate absolute hazards, make both relative to a 70 year old
> for (i in 1:2) {
mrate[,i] <- log(mrate[,i]/ mrate[21,2])
crate[,i] <- crate[,i] - crate[21,2]
}
> matplot(mrate, crate, col=2:1, type='l')
> abline(0, 1, lty=2, col=4)
The resulting curves are shown in the left panel of gure 8 and reveal that addition of an
interaction term did not change the predictions, and that the Cox model result for the highest
risk group is distinctly dierent predicted survival for the highest FLC group is distinctly dierent
when using model based prediction. The right hand panel of the gure shows that though there
are slight dierences with the Minnesota values, linearity of the age eect is very well supported.
So where exactly does the model go wrong? Since this is such a large data set we have the luxury
of looking at subsets. This would be a very large number of curves to plot age by sex by FLC
= 48 so an overlay of the observed and expected curves by group would be too confusing.
Instead we will summarize each of the groups according to their observed and predicted number
of events.
20
low F low M med F med M high F high M
50-54 0.9 1.0 1.0 1.0 2.3 2.5
55-59 1.1 0.9 1.6 0.9 1.8 1.6
60-64 0.9 0.8 1.0 1.0 1.5 1.0
65-69 0.8 0.9 0.9 1.1 1.5 1.3
70-74 0.8 1.0 0.8 0.9 1.1 1.2
75-79 1.2 1.0 1.1 1.2 0.8 1.1
80-89 1.2 1.1 1.0 0.9 0.7 0.9
90+ 1.3 0.8 1.0 1.6 1.1 0.9
The excess risks, dened as the observed/expected number of deaths, are mostly modest ranging
from .8 to 1.2. The primary exception exception is the high FLC group for ages 5059 which
has values of 1.6 to 2.5; the Cox model t has greatly overestimated the survival for the age
5054 and 5559 groups. Since this is also the age category with the highest count in the data
set, this overestimation will have a large impact on the overall curve for high FLC subset, which
is exactly where the the deviation in gure 8 is observed to lie. There is also mild evidence for
a linear trend in age for the low FLC females, in the other direction. Altogether this suggests
that the model might need to have a dierent age coecient for each of the three FLC groups.
The model with separate age coecients for each FLC group gives a major improvement in
goodness of t, but adding separate sex coecients per group or further interactions does not
add importantly beyond that.
1
1 There are certain TV shows that make one dumber just by watching them; adding stars to the output has
the same eect on statisticians.
21
0.5
0.4
0.3
Deaths
0.2
0.1
0.0
0 2 4 6 8 10 12 14
Figure 9: Adjusted survival for the 3 FLC groups based on the improved Cox model t. Dashed
lines show the predictions from the marginal model.
22
A recheck of the observed/expected values now shows a much more random pattern, though
some excess remains in the upper right corner. The updated survival curves are shown in gure
9 and now are in closer concordance with the marginal t.
One problem with the model based estimate is that standard errors for the curves are complex.
Standard errors of the individual curves for each age/sex/FLC combination are a standard
output of the survt function, but the collection of curves is correlated since they all depend
on a common estimate of the model's coecient vector β. Curves with disparate ages are anti-
correlated (an increase in the age coecient of the model would raise one and lower the other)
whereas those for close ages are positively correlated. A proper variance for the unweighted
average has been derived by Gail and Byar [3], but this has not been implemented in any of the
standard packages, nor extended to the weighted case. A bootstrap estimate would appear to
be the most feasible.
6 Conclusions
When two populations need to be adjusted and one is much larger than the other, the balanced
subset method has been popular. It is most often seen in the context of a case-control study,
with cases as the rarer group and a set of matched controls selected from the larger one. This
method has the advantage that the usual standard error estimates from a standard package are
appropriate, so no further work is required. However, in the general situation it leads to a correct
answer but for the wrong problem, i.e., not for a population in which we are interested.
The population reweighted estimate is exible, has a readily available variance in some sta-
tistical packages (but not all), and the result is directly interpretable. It is the method we
recommend in general. The approach can be extended to a large number of balancing factors
by using a regression model to derive the weights. Exploration and checking of said model for
23
adequacy is an important step in this case. The biggest downside to the method arises when
there is a subset which is rare in the data sample but frequent in the adjusting population. In
this case subjects in that subset will be assigned large weights, and the resulting curves will have
high variance.
The stratied method is closely related to reweighting (not shown). It does not do well if the
sample size is small, however.
Risk set modeling is a very exible method, but is also the one where it is easiest to go
wrong by using an inadequate model, and variance estimation is also dicult. To the extent
that the tted model is relevant, it allows for interpolation and extrapolation to a reference
population with a dierent distribution of covariates than the one in the training data. It may
be applicable in cases such as rare subsets where population reweighting is problematic, with
the understanding that one is depending heavily on extrapolation in this case, which is always
dangerous.
For all continuous covariates in the model, the empirical distribution is used as the refer-
ence.
For all categorical adjusters, a uniform distribution over the categories is used.
Figure 10 shows the t from such a model. Not surprisingly, the predicted death rate is
very high: 1/4 of our population is over 80 years old! The authors do not nd such a prediction
particularly useful since we don't ever expect to see a population like this (it's sort of like planning
for the zombie apocalypse), but for those enamored of type 3 tests this shows how to create the
corresponding curves.
> # there is a spurious warning from the model below: R creates 3 unneeded
> # columns in the X matrix
> cfit6 <- coxph(Surv(futime, death) ~ strata(group):age2 + sex, fdata)
> saspop <- with(fdata, [Link](age2= levels(age2), sex= levels(sex),
group = levels(group)))
> sfit6 <- survexp(~group, data=saspop, ratetable=cfit6)
> plot(sfit6, fun='event', xscale=365.25, [Link]=FALSE, lty=1, col=c(1,2,4),
xlab="Years from sample", ylab="Deaths")
> lines(sfit5, fun='event', xscale=365.25, lty=2, col=c(1,2,4))
24
0.6
0.5
0.4
Deaths
0.3
0.2
0.1
0.0
0 2 4 6 8 10 12 14
Figure 10: Adjusted survival for the 3 FLC groups based on a t with categorical age, and
predicting for a uniform age/sex population. Dashed lines show the predictions from the marginal
model.
25
References
[1] D. A. Binder. Fitting Cox's proportional hazards models from survey data. Biometrika,
79:139147, 1992.
[3] M. H. Gail and D. P. Byar. Variance calculations for direct adjusted survival curves, with
applications to testing for no treatment eect. Biometrical J., 28:587599, 1986.
[6] F. Javier Nieto and Josef Coresh. Adjusting survival curves for confounders: a review and a
new method. Am J of Epidemiology, pages 10591068, 1996.
[7] T. M. Therneau and P. M. Grambsch. Modeling Survival Data: Extending the Cox Model.
Springer-Verlag, New York, 2000.
[8] B. L. Thomsen, N. Keiding, and D. G. Altman. A note on the calculation of expected survival,
illustrated by the survival of liver transplant patients. Stat. in Medicine, 10:733738, 1991.
26