| ID | Transplant | Death |
|---|---|---|
| 1 | 2000 | 2005 |
| 2 | 2000 | 2009 |
| 3 | 2001 | 2005 |
| 4 | 2003 | 2004 |
| 5 | 2004 | 2016 |

Motivation: study the distribution of time to event \(T\).
Example: time of death after kidney transplant.
| ID | Transplant | Death |
|---|---|---|
| 1 | 2000 | 2005 |
| 2 | 2000 | 2009 |
| 3 | 2001 | 2005 |
| 4 | 2003 | 2004 |
| 5 | 2004 | 2016 |

We then calculate time to death for each respondents.
With this, all we need is to fit a linear model t ~ X or log(t) ~ X
| ID | Transplant | Death | Time to death |
|---|---|---|---|
| 1 | 2000 | 2005 | 5 |
| 2 | 2000 | 2009 | 9 |
| 3 | 2001 | 2005 | 4 |
| 4 | 2003 | 2004 | 1 |
| 5 | 2004 | 2016 | 12 |

What if we do not know when exactly some respondents die?
Scenario 1: the study ends at the year 2008?
| ID | Transplant | Death | Time to death |
|---|---|---|---|
| 1 | 2000 | 2005 | 5 |
| 2 | 2000 | > 2008 | > 8 |
| 3 | 2001 | 2005 | 4 |
| 4 | 2003 | 2004 | 1 |
| 5 | 2004 | > 2008 | > 4 |


Right Censoring: only observe the event (death) if it occurs before a certain time (2008).
Scenario 2: respondent 3 move away; loss follow up
| ID | Transplant | Death | Time to death |
|---|---|---|---|
| 1 | 2000 | 2005 | 5 |
| 2 | 2000 | > 2008 | > 8 |
| 3 | 2001 | > 2005 | > 4 |
| 4 | 2003 | 2004 | 1 |
| 5 | 2004 | > 2008 | > 4 |


How many patients are right censored?

hla.match
0 1 2 3 4 5 6 <NA>
784 1504 1553 3778 1278 365 279 234


age.donormean(dat$age.donor, na.rm = TRUE)[1] 31.29952
median(dat$age.donor, na.rm = TRUE)[1] 33
Warning: Removed 113 rows containing non-finite outside the scale range
(`stat_count()`).

Warning: Removed 113 rows containing non-finite outside the scale range
(`stat_count()`).

Warning: Removed 113 rows containing non-finite outside the scale range
(`stat_density()`).

age.recmean(dat$age.rec, na.rm = TRUE)[1] 11.64653
median(dat$age.rec, na.rm = TRUE)[1] 13
Warning: Removed 9 rows containing non-finite outside the scale range
(`stat_count()`).

Warning: Removed 113 rows containing non-finite outside the scale range
(`stat_boxplot()`).

Warning: Removed 9 rows containing non-finite outside the scale range
(`stat_count()`).

Warning: Removed 9 rows containing non-finite outside the scale range
(`stat_density()`).

Warning: Removed 2250 rows containing non-finite outside the scale range
(`stat_boxplot()`).

cold.iscmean(dat$cold.isc, na.rm = TRUE)[1] 10.85967
median(dat$cold.isc, na.rm = TRUE)[1] 7
Warning: Removed 2250 rows containing non-finite outside the scale range
(`stat_density()`).

Warning: Removed 2250 rows containing non-finite outside the scale range
(`stat_density()`).

tx.typedat$tx.type |> table()
Cadaveric Living
5148 4627

year
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002
728 734 666 736 787 813 789 745 740 842 706 834 655



Warning: Removed 9 rows containing non-finite outside the scale range
(`stat_boxplot()`).

Warning: Removed 113 rows containing non-finite outside the scale range
(`stat_boxplot()`).


death Distribution (?)

# A tibble: 7 × 5
fu.interval n.censored n.event n.at.risk hazard.rate
<dbl> <int> <int> <dbl> <dbl>
1 0.333 830 152 9775 0.0155
2 0.667 491 37 8793 0.00421
3 1 613 27 8265 0.00327
4 2 1164 62 7625 0.00813
5 3 1143 41 6399 0.00641
6 4 1053 40 5215 0.00767
7 5 919 31 4122 0.00752
tx.type (M)age (continuous) (L)age (categorical) (M)Call:
coxph(formula = Surv(follow.up, death) ~ hla.match + tx.type,
data = dat)
n= 9541, number of events= 451
(234 observations deleted due to missingness)
coef exp(coef) se(coef) z Pr(>|z|)
hla.match1 -0.08845 0.91535 0.17308 -0.511 0.60933
hla.match2 -0.36340 0.69531 0.17919 -2.028 0.04256 *
hla.match3 -0.50810 0.60164 0.18298 -2.777 0.00549 **
hla.match4 -0.65410 0.51991 0.22221 -2.944 0.00324 **
hla.match5 -0.39445 0.67405 0.29410 -1.341 0.17985
hla.match6 -0.51491 0.59755 0.31489 -1.635 0.10201
tx.typeLiving 0.39049 1.47771 0.12688 3.078 0.00209 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
exp(coef) exp(-coef) lower .95 upper .95
hla.match1 0.9153 1.0925 0.6520 1.2850
hla.match2 0.6953 1.4382 0.4894 0.9879
hla.match3 0.6016 1.6621 0.4203 0.8612
hla.match4 0.5199 1.9234 0.3363 0.8037
hla.match5 0.6740 1.4836 0.3787 1.1996
hla.match6 0.5976 1.6735 0.3224 1.1077
tx.typeLiving 1.4777 0.6767 1.1524 1.8949
Concordance= 0.613 (se = 0.014 )
Likelihood ratio test= 56.79 on 7 df, p=7e-10
Wald test = 57.08 on 7 df, p=6e-10
Score (logrank) test = 59.51 on 7 df, p=2e-10
Call:
coxph(formula = Surv(follow.up, death) ~ hla.match * tx.type,
data = dat)
n= 9541, number of events= 451
(234 observations deleted due to missingness)
coef exp(coef) se(coef) z Pr(>|z|)
hla.match1 0.8094 2.2467 0.8165 0.991 0.3215
hla.match2 1.1371 3.1176 0.7530 1.510 0.1311
hla.match3 0.4217 1.5245 0.7140 0.591 0.5548
hla.match4 0.1094 1.1156 0.7341 0.149 0.8816
hla.match5 0.4754 1.6087 0.7820 0.608 0.5432
hla.match6 0.5836 1.7925 0.8021 0.728 0.4669
tx.typeLiving 1.3801 3.9752 0.7218 1.912 0.0559 .
hla.match1:tx.typeLiving -0.9614 0.3823 0.8355 -1.151 0.2498
hla.match2:tx.typeLiving -1.6578 0.1905 0.7762 -2.136 0.0327 *
hla.match3:tx.typeLiving -1.0096 0.3644 0.7461 -1.353 0.1760
hla.match4:tx.typeLiving -0.5175 0.5960 0.7863 -0.658 0.5105
hla.match5:tx.typeLiving -0.8601 0.4231 0.8805 -0.977 0.3286
hla.match6:tx.typeLiving -1.3342 0.2634 0.9113 -1.464 0.1432
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
exp(coef) exp(-coef) lower .95 upper .95
hla.match1 2.2467 0.4451 0.45341 11.1322
hla.match2 3.1176 0.3208 0.71257 13.6400
hla.match3 1.5245 0.6559 0.37617 6.1787
hla.match4 1.1156 0.8964 0.26460 4.7032
hla.match5 1.6087 0.6216 0.34737 7.4498
hla.match6 1.7925 0.5579 0.37212 8.6342
tx.typeLiving 3.9752 0.2516 0.96600 16.3580
hla.match1:tx.typeLiving 0.3823 2.6155 0.07435 1.9662
hla.match2:tx.typeLiving 0.1905 5.2480 0.04162 0.8723
hla.match3:tx.typeLiving 0.3644 2.7444 0.08443 1.5726
hla.match4:tx.typeLiving 0.5960 1.6778 0.12763 2.7836
hla.match5:tx.typeLiving 0.4231 2.3635 0.07533 2.3763
hla.match6:tx.typeLiving 0.2634 3.7971 0.04414 1.5712
Concordance= 0.615 (se = 0.014 )
Likelihood ratio test= 66.78 on 13 df, p=3e-09
Wald test = 65.9 on 13 df, p=5e-09
Score (logrank) test = 69.92 on 13 df, p=8e-10
Analysis of Deviance Table
Cox model: response is Surv(follow.up, death)
Model 1: ~ hla.match + tx.type
Model 2: ~ hla.match * tx.type
loglik Chisq Df Pr(>|Chi|)
1 -3848.5
2 -3843.5 9.9891 6 0.1251
year or not?