Download as pdf or txt
Download as pdf or txt
You are on page 1of 66

Lifetime Data Analysis

Semiparametric multiplicative hazards regression models

Mahbub Latif
Institute of Statistical Research and Training (ISRT)
University Dhaka, Dhaka 1000, Bangladesh
(mlatif@isrt.ac.bd)

January 2024

Mahbub Latif Lifetime Data Analysis January 2024 1 / 66


Mahbub Latif Lifetime Data Analysis January 2024 2 / 66
Plan

Semiparametric multiplicative hazards regression models


Methods for continuous multiplicative hazards model
Comparison of two or more lifetime distributions
Stratification
Model checking

Mahbub Latif Lifetime Data Analysis January 2024 3 / 66


Methods for continuous multiplicative hazards model

Mahbub Latif Lifetime Data Analysis January 2024 4 / 66


Methods for continuous multiplicative hazards model

• Models in which covariates have a multiplicative effect on the hazard function


play an important role in the analysis of lifetime data
The proportional hazard (PH) model is one such models
• Depending on whether the baseline hazard function is left arbitrary or not, the
PH model could be either semiparametric or parametric
• In this section, semiparametric PH models are discussed, where baseline hazard
function is left arbitrary

Mahbub Latif Lifetime Data Analysis January 2024 5 / 66


Methods for continuous multiplicative hazards model

• The hazard function for lifetime 𝑇 given 𝑝-dimensional covariate vector


𝑥 = (𝑥1 , … , 𝑥𝑝 )′ is defined as

𝑥′𝛽 )
ℎ(𝑡 | 𝑥 ) = ℎ0 (𝑡) exp(𝑥 (1)

• 𝛽 = (𝛽1 , … , 𝛽𝑝 )′ → vector of regression coefficients


• Covariate vector 𝑥 could include time-varying covariate
• No intercept term is included in 𝑥 ′𝛽
• Model (1) is known as “Cox’s proportional hazards model” or simply “Cox
model,” where no distributional assumption is required for estimating the
parameters of the model

Mahbub Latif Lifetime Data Analysis January 2024 6 / 66


Methods for continuous multiplicative hazards model

• The cumulative baseline hazard function is defined as


𝑡
𝐻0 (𝑡) = ∫ ℎ0 (𝑢) 𝑑𝑢 (2)
0

• The baseline survivor function

𝑆0 (𝑡) = exp [ − 𝐻0 (𝑡)] (3)

• The survivor function of 𝑇 given covariate vector 𝑥


𝑥 ′𝛽 )
exp(𝑥
𝑆(𝑡 | 𝑥 ) = [𝑆0 (𝑡)] (4)

Mahbub Latif Lifetime Data Analysis January 2024 7 / 66


Estimation of model parameters

• Data
{(𝑡𝑖 , 𝛿𝑖 , 𝑥 𝑖 ), 𝑖 = 1, … , 𝑛}

• Parameters of interest are ℎ0 (𝑡) and 𝛽

Mahbub Latif Lifetime Data Analysis January 2024 8 / 66


Estimation of model parameters

• Log-likelihood function
𝑛
𝛿 1−𝛿𝑖
ℓ(ℎ0 (𝑡), 𝛽 ) = log ∏ [𝑓(𝑡𝑖 ; 𝑥 𝑖 )] 𝑖 [𝑆(𝑡𝑖 ; 𝑥 𝑖 )]
𝑖=1

𝑥′𝑖𝛽 )] + exp(𝑥
= ∑ {𝛿𝑖 log [ℎ0 (𝑡𝑖 ) exp(𝑥 𝑥′𝑖𝛽 ) log 𝑆0 (𝑡𝑖 )}
𝑖

= ∑ {𝛿𝑖 [ log ℎ0 (𝑡𝑖 ) + 𝑥 ′𝑖𝛽 ] + exp(𝑥


𝑥′𝑖𝛽 ) log 𝑆0 (𝑡𝑖 )]} (5)
𝑖

• No unique solutions of the parameters because the number of parameters to be


estimated is greater than the number of observations

Mahbub Latif Lifetime Data Analysis January 2024 9 / 66


Estimation of model parameters

The complete likelihood function does not help estimate parameters of Cox’s
proportional hazards model
• There are a number of different likelihood functions defined for estimating
parameters
• Conditional likelihood function, marginal likelihood function, and partial
likelihood function
• Cox’s “partial likelihood function” is widely used for PH models

Mahbub Latif Lifetime Data Analysis January 2024 10 / 66


Partial likelihood function

The log-partial-likelihood function is defined as


𝛿𝑖
𝑛
exp(𝑥 𝑥′𝑖𝛽 )
𝛽 ) = log ∏ ( 𝑛
ℓ1 (𝛽 ) (6)
𝑖=1 𝑥′𝑘𝛽 )
∑𝑘=1 𝑌𝑘 (𝑡𝑖 ) exp(𝑥

• 𝑌𝑘 (𝑡) = 𝐼(𝑡𝑘 ≥ 𝑡) → indicates whether the 𝑘𝑡ℎ subject is still in the risk set at
time 𝑡 or not

Mahbub Latif Lifetime Data Analysis January 2024 11 / 66


Partial likelihood function

• Partial likelihood function is defined on the expression of the probability that a


specific subject (say 𝑖) dies at time 𝑡 given the history of failure and censoring
prior to time 𝑡 and 𝑌𝑖 (𝑡) = 1

ℎ(𝑡 | 𝑥 𝑖 ) exp(𝑥𝑥′𝑖𝛽 )
𝑛 = 𝑛 (7)
∑𝑘=1 𝑌𝑘 (𝑡)ℎ(𝑡𝑘 | 𝑥 𝑖 ) ∑𝑘=1 𝑌𝑘 (𝑡) exp(𝑥𝑥′𝑘𝛽 )

Mahbub Latif Lifetime Data Analysis January 2024 12 / 66


Estimation of model parameters

• Partial likelihood function can be treated as a regular likelihood function for


making statistical inferences, and corresponding estimates are considered as
MLEs
𝛽 ̂ = arg max ℓ1 (𝛽
𝛽)
𝛽 ∈Θ

• For partial likelihood function, estimated parameters 𝛽 ̂ follow asymptotically


normal distribution, similar to MLEs
• The baseline hazard function ℎ0 (𝑡) is estimated from the full likelihood function
with regression parameters assumed to be known, i.e., ℓ(ℎ0 (𝑡), 𝛽 ̂ )

Mahbub Latif Lifetime Data Analysis January 2024 13 / 66


• Obtain the expression of the partial likelihood function for the following
censored sample
time x
3 1
5 0
8 1
4+ 1
10 0

Mahbub Latif Lifetime Data Analysis January 2024 14 / 66


Comparison of two or more lifetime distributions

Mahbub Latif Lifetime Data Analysis January 2024 15 / 66


Comparison of two or more lifetime distributions

• Let 𝑆𝑗 (𝑡) be the survivor function of lifetime 𝑇𝑗 , 𝑗 = 1, 2 and want to compare


survivor function with the available data

{(𝑡𝑖 , 𝛿𝑖 , 𝑥𝑖 ), 𝑖 = 1, … , 𝑛}
• 𝑥𝑖 = 𝐼(𝑖𝑡ℎ subject is from group 1)
• Null and alternative hypotheses

𝐻0 ∶ 𝑆1 (𝑡) = 𝑆2 (𝑡) 𝑎𝑛𝑑 𝐻0 ∶ 𝑆1 (𝑡) ≠ 𝑆2 (𝑡)

Mahbub Latif Lifetime Data Analysis January 2024 16 / 66


Comparison of two or more lifetime distributions

• Consider a PH model

ℎ(𝑡 | 𝑥) = ℎ0 (𝑡) exp(𝛽𝑥) ⇒ 𝑆(𝑡 | 𝑥) = [𝑆0 (𝑡)]exp(𝛽𝑥)

• We can obtain

𝑆2 (𝑡) = 𝑆(𝑡 | 𝑥 = 0) = 𝑆0 (𝑡)

𝑆1 (𝑡) = 𝑆(𝑡 | 𝑥 = 1) = [𝑆0 (𝑡)]exp(𝛽) = [𝑆2 (𝑡)]exp(𝛽)

Mahbub Latif Lifetime Data Analysis January 2024 17 / 66


Comparison of two or more lifetime distributions

• The null and alternative hypotheses under the proportional model assumption

𝐻0 ∶ 𝑆1 (𝑡) = 𝑆2 (𝑡) ⇒ 𝐻0 ∶ 𝛽 = 0
𝐻0 ∶ 𝑆1 (𝑡) = 𝑆2 (𝑡) ⇒ 𝐻0 ∶ 𝛽 ≠ 0

• Large sample-based property of MLE 𝛽 ̂ can be used to test the null hypothesis

Mahbub Latif Lifetime Data Analysis January 2024 18 / 66


Comparison of two or more lifetime distributions

• Log-likelihood function
𝛿𝑖
𝑛
𝑒𝛽𝑥𝑖
ℓ(𝛽) = log ∏ ( 𝑛 𝛽𝑥𝑘
)
𝑖=1 ∑ 𝑘=1
𝑌 𝑘 (𝑡𝑖 ) 𝑒
𝑛 𝑛
= ∑ (𝛿𝑖 𝑥𝑖 𝛽 − 𝛿𝑖 log ∑ 𝑌𝑘 (𝑡𝑖 ) 𝑒𝛽𝑥𝑘 )
𝑖=1 𝑘=1

Mahbub Latif Lifetime Data Analysis January 2024 19 / 66


Comparison of two or more lifetime distributions
• Score function
𝑛 𝑛
𝛿𝑖 ∑𝑘=1 𝑌𝑘 (𝑡𝑖 ) 𝑒𝛽𝑥𝑘 𝑥𝑘
𝑈 (𝛽) = ∑ (𝛿𝑖 𝑥𝑖 − 𝑛 )
𝑖=1 ∑𝑘=1 𝑌𝑘 (𝑡𝑖 ) 𝑒𝛽𝑥𝑘
𝑛
𝑑𝑖 𝑛1𝑖 𝑒𝛽
= ∑ (𝑑1𝑖 − )
𝑖=1
𝑛1𝑖 𝑒𝛽 + 𝑛2𝑖

• 𝑑𝑖 = 𝛿𝑖 = I(𝑡𝑖 is a lifetime)
• 𝑑1𝑖 = 𝛿𝑖 𝑥𝑖 = 𝐼(𝑡𝑖 is a lifetime and from group 1)
𝑛
• 𝑛1𝑖 = ∑𝑘=1 𝑌𝑘 (𝑡𝑖 )𝑥𝑘 → number of group 1 subjects at risk at time 𝑡𝑖
𝑛
• 𝑛2𝑖 = ∑𝑘=1 𝑌𝑘 (𝑡𝑖 )(1 − 𝑥𝑘 ) → number of group 2 subjects at risk at time 𝑡𝑖

Mahbub Latif Lifetime Data Analysis January 2024 20 / 66


Comparison of two or more lifetime distributions

• Information Matrix
𝑛
𝑑𝑖 𝑛1𝑖 𝑒𝛽 𝑛1𝑖 𝑒𝛽 − 𝑑𝑖 (𝑛1𝑖 𝑒𝛽 + 𝑛2𝑖 )𝑛1𝑖 𝑒𝛽
𝐼(𝛽) = ∑ [ − 2
]
𝑖=1 (𝑛1𝑖 𝑒𝛽 + 𝑛2𝑖 )
𝑛
𝑑𝑖 𝑛1𝑖 𝑛2𝑖 𝑒𝛽
= ∑[ 2
]
𝑖=1 (𝑛1𝑖 𝑒𝛽 + 𝑛2𝑖 )

Mahbub Latif Lifetime Data Analysis January 2024 21 / 66


Comparison of two or more lifetime distributions

• Confidence interval for 𝛽 can be obtained from the following pivotal quantity

𝑈 (𝛽)
𝑍(𝛽) =
[𝐼(𝛽)]1/2

• 𝑍(𝛽) follows an asymptotic standard normal distribution


• 100(1 − 𝛼)% confidence interval for 𝛽 can be obtained from the set of values of
𝛽 that satisfy
𝑍(𝛽) ≤ 𝑧1−𝛼

Mahbub Latif Lifetime Data Analysis January 2024 22 / 66


Comparison of two or more lifetime distributions

• Under 𝐻0 ∶ 𝛽 = 0
𝑛
𝑑𝑖 𝑛1𝑖
𝑈 (0) = ∑ (𝑑1𝑖 − )
𝑖=1
𝑛1𝑖 + 𝑛2𝑖
𝑛
𝑑𝑖 𝑛1𝑖 𝑛2𝑖
𝐼(0) = ∑ 2
𝑖=1 (𝑛1𝑖 + 𝑛2𝑖 )

• Test statistic
𝑈 (0)
𝑍= ∼ 𝒩(0, 1)
[𝐼(0)]1/2
• MLE of 𝛽 does not require to test 𝐻0 ∶ 𝛽 = 0 using the statistic 𝑍

Mahbub Latif Lifetime Data Analysis January 2024 23 / 66


Comparison of two or more lifetime distributions

• The expression of 𝑈 (0) can be considered as the difference between observed


number of deaths from group 1, (𝑑1𝑖 ), at time 𝑡𝑖 and the corresponding
expected number of deaths, i.e.

𝑛1𝑖
𝑑1𝑖 − [𝑑𝑖 × ]
𝑛1𝑖 + 𝑛2𝑖

Mahbub Latif Lifetime Data Analysis January 2024 24 / 66


Comparison of two or more lifetime distributions

• At the time 𝑡𝑖 , there are 𝑛𝑖 = 𝑛1𝑖 + 𝑛2𝑖 subjects are at risk, and 𝑑𝑖 is either 0 or
1 (i.e., there is no ties in the lifetime)

group event alive at risk


1 𝑑1𝑖 𝑛1𝑖 − 𝑑1𝑖 𝑛1𝑖
2 𝑑2𝑖 𝑛2𝑖 − 𝑑2𝑖 𝑛2𝑖
𝑑𝑖 𝑛𝑖 − 𝑑 𝑖 𝑛𝑖

Mahbub Latif Lifetime Data Analysis January 2024 25 / 66


Comparison of two or more lifetime distributions

• In the presence of a small number of ties in the data, the score test is still valid
• In the presence of substantial ties, the discrete model is preferable, and the
resulting expression of the information matrix takes the following form
𝑛
𝑑𝑖 𝑛1𝑖 𝑛2𝑖 (𝑛𝑖 − 𝑑𝑖 )
𝐼(0) = ∑
𝑖=1
𝑛2𝑖 (𝑛𝑖 − 1)

• This test is also known as log-rank test

Mahbub Latif Lifetime Data Analysis January 2024 26 / 66


Example 7.1.1

Data below show remission times (in weeks) for 40 leukemia patients who were
randomly assigned either treatment 𝐴 or 𝐵
> tab7_1_1
## # A tibble: 40 x 3
## time status group
## <dbl> <dbl> <chr>
## 1 1 1 A
## 2 3 1 A
## 3 3 1 A
## 4 6 1 A
## 5 7 1 A
## 6 7 1 A
## 7 10 1 A
## 8 12 1 A
## 9 14 1 A
## 10 15 1 A
## # i 30 more rows

Mahbub Latif Lifetime Data Analysis January 2024 27 / 66


Example 7.1.1

> survdiff(Surv(time, status) ~ group,


data = tab7_1_1)
## Call:
## survdiff(formula = Surv(time, status) ~ group, data = tab7_1_1)
##
## N Observed Expected (O-E)^2/E (O-E)^2/V
## group=A 20 17 21.5 0.951 2.36
## group=B 20 20 15.5 1.322 2.36
##
## Chisq= 2.4 on 1 degrees of freedom, p= 0.1

Mahbub Latif Lifetime Data Analysis January 2024 28 / 66


Example 7.1.1

> coxph(Surv(time, status) ~ group, data = tab7_1_1) %>%


tidy()
## # A tibble: 1 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 groupB 0.503 0.332 1.51 0.130

Mahbub Latif Lifetime Data Analysis January 2024 29 / 66


Estimation of 𝐻0(𝑡)

• Breslow’s estimate of 𝐻0 (𝑡)

𝛿𝑖
𝐻̂0 (𝑡) = ∑ 𝑛
𝑥′𝑘𝛽 ̂ )
𝑖∶𝑡𝑖 ≤𝑡 ∑𝑘=1 𝑌𝑘 (𝑡𝑖 ) exp(𝑥

• At 𝛽 ̂ = 0 , 𝐻̂0 (𝑡) is the Nelson-Aalen estimator of cumulative hazard function


• 𝐻̂0 (𝑡) is also known as generalized Nelson-Aalen estimator

Mahbub Latif Lifetime Data Analysis January 2024 30 / 66


Estimation of 𝑆0(𝑡)

• Estimate of 𝑆0 (𝑡) = exp[−𝐻0 (𝑡)]

𝑆0̂ (𝑡) = exp[−𝐻̂0 (𝑡− )]

• When there is no covariate, i.e. 𝛽 ̂ = 0


• 𝑆0̂ (𝑡) is not Kaplan-Meier estimator
• 𝑆0̂ (𝑡) is known as Fleming-Harrington estimator
• Survivor function at time 𝑡 for a given 𝑥
′ ̂
𝑥) = [𝑆0̂ (𝑡)]exp(𝑥𝑥 𝛽 )
𝑆(𝑡 |𝑥

Mahbub Latif Lifetime Data Analysis January 2024 31 / 66


Example 7.2.1

• Patients with cystic fibrosis are susceptible to an accumulation of mucus in the


lungs, which leads to pulmonary exacerbation and deterioration of lung function
• A clinical trial was conducted to investigate the efficacy of the new drug
DNase-1, and subjects were randomly assigned to a new treatment or a placebo
• Time of interest is the time to first exacerbation after randomization, and data
on fev (forced expiratory volume at the time of randomization) are also
measured

Mahbub Latif Lifetime Data Analysis January 2024 32 / 66


Mahbub Latif Lifetime Data Analysis January 2024 33 / 66
Creating the data from the R object rhDNase
> tab1_4 <- as_tibble(rhDNase) %>%
filter(is.na(ivstart) | ivstart > 0) %>%
mutate(time0 = as.numeric(end.dt - entry.dt),
status = as.numeric(!is.na(ivstart)),
time = if_else(status == 1, ivstart, time0),
fevm = fev - mean(fev)) %>%
group_by(id) %>%
mutate(visit = n()) %>%
ungroup()

Mahbub Latif Lifetime Data Analysis January 2024 34 / 66


Cox’s PH model

ℎ(𝑡 | trt, fevm) = ℎ0 (𝑡) exp(𝛽1 trt + 𝛽2 fevm)

R code for fitting the model


> mod1 <- coxph(Surv(time, status) ~ trt + fevm,
data = tab1_4)

Mahbub Latif Lifetime Data Analysis January 2024 35 / 66


Estimates of regression coefficients

> tidy(mod1)
## # A tibble: 2 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 trt -0.352 0.106 -3.31 9.47e- 4
## 2 fevm -0.0188 0.00226 -8.31 9.63e-17
• Treatment group patients have a lower hazard for time to first exacerbation
• As FEV value increases, the hazard of first exacerbation decreases
• Effects of treatment and FEV are significant on the hazard of first exacerbation
decreases

Mahbub Latif Lifetime Data Analysis January 2024 36 / 66


Table 1: Estimates and corresponding confidence intervals of the parameters of Cox’s
PH model

term estimate p.value HR 2.5 % 97.5 %


trt -0.352 0.001 0.703 0.571 0.867
fevm -0.019 0.000 0.981 0.977 0.986
• Treatment group patients have about 30% lower hazard of first exacerbation
than that of the placebo group patients provided FEV value remains constant
• For 1-unit increase of FEV value, the hazard of first exacerbation decreases
about 2% provided treatment group remains constant

Mahbub Latif Lifetime Data Analysis January 2024 37 / 66


Estimate of baseline cumulative hazard function 𝐻0 (𝑡) and baseline survivor
function 𝑆0 (𝑡)
> hdat <- basehaz(mod1) %>%
as_tibble() %>%
mutate(surv = exp(-hazard))

Mahbub Latif Lifetime Data Analysis January 2024 38 / 66


> hdat
## # A tibble: 161 x 3
## hazard time surv
## <dbl> <dbl> <dbl>
## 1 0.00138 1 0.999
## 2 0.00552 5 0.994
## 3 0.00691 6 0.993
## 4 0.0125 8 0.988
## 5 0.0167 9 0.983
## 6 0.0195 11 0.981
## 7 0.0223 13 0.978
## 8 0.0252 14 0.975
## 9 0.0309 15 0.970
## 10 0.0337 16 0.967
## # i 151 more rows

Mahbub Latif Lifetime Data Analysis January 2024 39 / 66


0.6

hazard 0.4

0.2

0.0
0 50 100 150
time
Figure 1: Plot of estimated baseline cumulative hazard function 𝐻̂ 0 (𝑡)

Mahbub Latif Lifetime Data Analysis January 2024 40 / 66


1.0

0.9

0.8
surv
0.7

0.6

0.5

0 50 100 150
time
Figure 2: Plot of estimated baseline survivor function 𝑆0̂ (𝑡)

Mahbub Latif Lifetime Data Analysis January 2024 41 / 66


survfit() provides an estimate of survivor function and corresponding standard
errors
> tidy(survfit(mod1)) %>%
as_tibble() %>%
slice(1:6)
## # A tibble: 6 x 8
## time n.risk n.event n.censor estimate std.error
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 761 1 0 0.999 0.00138
## 2 5 760 3 0 0.994 0.00277
## 3 6 757 1 0 0.993 0.00311
## 4 8 756 4 0 0.988 0.00420
## 5 9 752 3 0 0.983 0.00489
## 6 11 749 2 0 0.981 0.00530
## # i 2 more variables: conf.high <dbl>, conf.low <dbl>

Mahbub Latif Lifetime Data Analysis January 2024 42 / 66


Predictions

• predict.coxph can be used for prediction using a coxph object


• The argument type of predict.coxph function specifies the type of
predictions, and below are the available options of type argument
• “lp” → linear predictor
• “risk” → exp(“lp”)
• “expected” → expected number of events given the covariates (cumulative
hazard function)
• “survival” → survival function, which is the same as exp(-“expected”)

Mahbub Latif Lifetime Data Analysis January 2024 43 / 66


1.0

0.9

0.8 treatment
survival 0
0.7
1

0.6

0.5

0 50 100 150
time
Figure 3: Estimated survivor functions for treatment and placebo groups obtained from Cox’s
PH model.

Mahbub Latif Lifetime Data Analysis January 2024 44 / 66


Is there a significant difference in 𝑆(160 | trt, fevm) between the two treatment
groups?
> ndat <- tibble(trt = c(1, 0), fevm = c(0, 0),
time = c(160, 160),
status = c(1, 1))
> augment(mod1, newdata = ndat,
type.predict = "survival")
## # A tibble: 2 x 6
## trt fevm time status .fitted .se.fit
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 0 160 1 0.610 0.0253
## 2 0 0 160 1 0.495 0.0256

Mahbub Latif Lifetime Data Analysis January 2024 45 / 66


Stratification

Mahbub Latif Lifetime Data Analysis January 2024 46 / 66


Stratification

• Stratified Cox’s proportional model is useful when subjects can be assigned to


one of the 𝐽 strata
• For a subject of stratum 𝑗 with covariate vector 𝑥 , the hazard function is
defined as
𝑥′𝛽 )
ℎ(𝑡 | 𝑥 ) = ℎ0𝑗 (𝑡) exp(𝑥
• ℎ0𝑗 (𝑡) → baseline hazard function for stratum 𝑗
• No stratum-covariate interaction

Mahbub Latif Lifetime Data Analysis January 2024 47 / 66


Stratification

• Data: {(𝑡𝑗𝑖 , 𝛿𝑗𝑖 , 𝑥 𝑗𝑖 ), 𝑗 = 1, … , 𝐽 ; 𝑖 = 1, … , 𝑛𝑗 }


• Log-likelihood function
𝐽 𝑛𝑗 𝛿𝑗𝑖
𝑥′𝑗𝑖𝛽 )
exp(𝑥
𝛽 ) = log ∏ ∏ (
ℓ(𝛽 𝑛 )
𝑗=1 𝑖=1 𝑥′𝑗𝑖𝛽 )
∑𝑘=1 𝑌𝑘 (𝑡𝑗𝑖 ) exp (𝑥
𝐽
𝛽)
= log ∏ 𝐿𝑗 (𝛽
𝑗=1

• 𝛽 ) → partial likelihood function for the subjects assigned to the 𝑗𝑡ℎ stratum
𝐿𝑗 (𝛽
• Estimation and inference procedures are the same as before

Mahbub Latif Lifetime Data Analysis January 2024 48 / 66


Assume treatment groups of time to first exacerbation data are strata and
consider following stratified Cox’s PH model

ℎ𝑗 (𝑡 | fevm) = ℎ0𝑗 (𝑡) exp(𝛽 fevm), 𝑗 = 0, 1

> mod2 <- coxph(Surv(time, status) ~ fevm + strata(trt),


data = tab1_4)

Mahbub Latif Lifetime Data Analysis January 2024 49 / 66


> tidy(mod2)
## # A tibble: 1 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 fevm -0.0188 0.00226 -8.29 1.13e-16

Mahbub Latif Lifetime Data Analysis January 2024 50 / 66


> basehaz(mod2) %>%
as_tibble()
## # A tibble: 245 x 3
## hazard time strata
## <dbl> <dbl> <fct>
## 1 0.00230 1 trt=0
## 2 0.00924 5 trt=0
## 3 0.0162 8 trt=0
## 4 0.0209 9 trt=0
## 5 0.0233 11 trt=0
## 6 0.0257 13 trt=0
## 7 0.0281 14 trt=0
## 8 0.0329 15 trt=0
## 9 0.0377 16 trt=0
## 10 0.0401 17 trt=0
## # i 235 more rows
Mahbub Latif Lifetime Data Analysis January 2024 51 / 66
> basehaz(mod2) %>%
ggplot() +
geom_step(aes(time, hazard, col = strata)) +
theme_bw() + labs(col = "treatment")

0.6

treatment
hazard

0.4
trt=0
trt=1
0.2

0.0
0 50 100 150
Mahbub Latif time
Lifetime Data Analysis January 2024 52 / 66
> basehaz(mod2) %>%
mutate(surv = exp(-hazard)) %>%
ggplot() +
geom_step(aes(time, surv, col = strata)) +
theme_bw() + labs(col = "treatment")
1.0

0.9

0.8 treatment
surv

trt=0
0.7
trt=1

0.6

0.5

Mahbub Latif Lifetime Data Analysis January 2024 53 / 66


Model checking

Mahbub Latif Lifetime Data Analysis January 2024 54 / 66


Model checking

• The key assumptions of the PH models


• Proportionality assumption of covariate effect on the hazard function
• 𝑥′𝛽 ) or some other function 𝑟(𝑥
Specification of covariate term exp(𝑥 𝑥′ ; 𝛽 )

Mahbub Latif Lifetime Data Analysis January 2024 55 / 66


Model checking

• Cox’s PH model implies that

log[− log 𝑆(𝑡 | 𝑥 )] = log 𝐻0 (𝑡) + 𝑥 ′𝛽 = log[− log 𝑆0 (𝑡)] + 𝑥 ′𝛽

• If PH assumption is reasonable a plot of log[− log 𝑆(𝑡 | 𝑥 )] versus 𝑡 or log 𝑡


should be parallel vertically
• As an estimate of log[− log 𝑆(𝑡 | 𝑥 )] individuals are divided into several groups
based on their covariate values so that each group has sufficient number of
individuals
• For the group 𝑗, 𝑆(𝑡 | 𝑥 𝑗 ) is estimated by Kaplan-Meier estimate 𝑆𝑗 (𝑡), and a
plot of log[− log 𝑆𝑗 (𝑡)] versus 𝑡 or log 𝑡 is considered for checking the PH
assumption

Mahbub Latif Lifetime Data Analysis January 2024 56 / 66


Model checking

• Residuals of fitted PH are introduced in two ways:


• Exponential residuals
• Martingale residuals

Mahbub Latif Lifetime Data Analysis January 2024 57 / 66


Exponential residuals

• Exponential residuals are defined as

𝑒𝑖̂ = 𝐻(𝑡 𝑥′𝑖𝛽 ̂ )


̂ 𝑖 | 𝑥 𝑖 ) = 𝐻̂0 (𝑡𝑖 ) exp(𝑥 (8)
𝑒𝑎𝑑𝑗
𝑖 = 𝑒𝑖̂ + 1 − 𝛿𝑖 (9)

• Residuals 𝑒𝑖̂ should be roughly independent of 𝑥 𝑖 and can be considered as a


random sample from standard exponential distribution in large samples
• The residuals 𝑒𝑖̂ or 𝑒𝑎𝑑𝑗
𝑖 are not helpful in practice because their values are
always positive, their distribution is highly skewed, and heavy censoring can
create a systematic pattern in the residuals

Mahbub Latif Lifetime Data Analysis January 2024 58 / 66


Martingale residuals

• It can be shown that martingales 𝑀𝑖 (𝑡) are uncorrelated and have zero mean
𝑡
𝑥′𝑖𝛽 ) 𝑑𝐻0 (𝑢)
𝑀𝑖 (𝑡) = 𝑁𝑖 (𝑡) − ∫ 𝑌𝑖 (𝑢) exp(𝑥 (10)
0

• Martingale residuals

𝑀𝑖 = 𝑀𝑖 (∞) = 𝛿𝑖 − ∫ 𝑥′𝑖𝛽 ̂ ) 𝑑𝐻̂0 (𝑢)
𝑌𝑖 (𝑢) exp(𝑥
0

𝑥′𝑖𝛽 ̂ )
= 𝛿𝑖 − 𝐻̂0 (𝑡𝑖 ) exp(𝑥 (11)

Mahbub Latif Lifetime Data Analysis January 2024 59 / 66


Martingale residuals

• Since

𝑒𝑎𝑑𝑗
𝑖 𝑥′𝑖𝛽 ̂ ) + 1 − 𝛿𝑖
= 𝐻̂0 (𝑡𝑖 ) exp(𝑥

• We can show

𝑥′𝑖𝛽 ̂ )
𝑀𝑖 = 𝛿𝑖 − 𝐻̂0 (𝑡𝑖 ) exp(𝑥
= 1 − 𝑒𝑎𝑑𝑗
𝑖

Mahbub Latif Lifetime Data Analysis January 2024 60 / 66


Martingale residuals

• Martingale residuals are uncorrelated and have zero mean, and it lie between
−∞ to 1
• For correct regression mean function, a plot of martinagle residuals and
covariate should show 𝐸(𝑀̂ 𝑖 ) = 0
• Similar to exponential residuals, the distribution of martingale residuals is
skewed, and there could be a systematic pattern because if heavy censoring

Mahbub Latif Lifetime Data Analysis January 2024 61 / 66


R function for residuals

• residuals.coxph function can be used to obtain residuals related to Cox’s PH


models, such as
• “martingale”, “deviance”, “score”, “schoenfeld”, “dfbeta”, “dfbetas”,
“scaledsch”, “partial”

Mahbub Latif Lifetime Data Analysis January 2024 62 / 66


1

resid 0 status
0
1

−1

0 50
fevm

Mahbub Latif Lifetime Data Analysis January 2024 63 / 66


Other topics

• Time-dependent covariates can be included in Cox’s model


• Competing risks
• Frailty models

Mahbub Latif Lifetime Data Analysis January 2024 64 / 66


Exercise

• Problems 7.8 and 7.9 of the textbook

Mahbub Latif Lifetime Data Analysis January 2024 65 / 66


References I

Mahbub Latif Lifetime Data Analysis January 2024 66 / 66

You might also like