| Title: | Data Sets and Computer Exercises for the STA310 Survival Analysis Course |
|---|---|
| Description: | The data sets that accompany Collett (2023), "Modelling Survival Data in Medical Research" (4th edition), documented for the STA310 course at the University of Gothenburg, together with the computer exercises used in the course. The package focuses on the data sets, their documentation and the exercise vignettes. |
| Authors: | Erik Bülow [aut, cre] |
| Maintainer: | Erik Bülow <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-11 06:03:10 UTC |
| Source: | https://github.com/eribul/sta310r |
Longitudinal measurements of the left ventricular mass index (LVMI) and survival times for 256 patients who received an aortic valve replacement (Collett, 2023, Example 8.5).
aorticaortic
A data frame with 988 rows and 11 variables:
Patient number (1-256).
Total follow-up time from the date of surgery, in years.
Event indicator: 1 = death, 0 = right-censored.
Time of the LVMI measurement after surgery, in years.
Standardised left ventricular mass index.
Age of the patient in years.
Sex: 0 = male, 1 = female.
Previous cardiac surgery: 0 = no, 1 = yes.
Operative urgency: 0 = elective, 1 = urgent or emergency.
Preoperative diabetes mellitus: 0 = no, 1 = yes.
Type of valve: 1 = human tissue, 2 = porcine tissue.
The file is in long format: one row per LVMI measurement, and the baseline
and survival variables (futime, status, age, ...) are repeated on each
row for the patient. There are 988 measurement rows for 256 patients; 54 of
the patients died (status is 1, repeated on each of their rows). Patients
who had a second procedure are censored at that time so that they do not
appear twice in the survival data.
The data are used for joint modelling of a longitudinal and a survival
outcome (Examples 8.5-8.9). The full data set is available as heart.valve
in the joineR package.
The data set is available under the aliases d8.5, d8.6, d8.7, d8.8,
d8.9; dX.Y is the alias for the data set used in Example X.Y of Collett
(2023). See dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 8.5 (Table 8.10). Data from Lim et al. (2008).
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 8.5-8.9: LVMI as a time-dependent covariate, built with tmerge() base <- aortic[!duplicated(aortic$id), c("id", "futime", "status", "age", "sex")] long <- aortic[, c("id", "time", "lvmi")] cp <- survival::tmerge(base, base, id = id, endpt = event(futime, status)) cp <- survival::tmerge(cp, long, id = id, lvmi = tdc(time, lvmi)) survival::coxph( survival::Surv(tstart, tstop, endpt) ~ lvmi + age + sex, data = cp )# Collett (2023), Chapter 17 style ----------------------------------- # Examples 8.5-8.9: LVMI as a time-dependent covariate, built with tmerge() base <- aortic[!duplicated(aortic$id), c("id", "futime", "status", "age", "sex")] long <- aortic[, c("id", "time", "lvmi")] cp <- survival::tmerge(base, base, id = id, endpt = event(futime, status)) cp <- survival::tmerge(cp, long, id = id, lvmi = tdc(time, lvmi)) survival::coxph( survival::Surv(tstart, tstop, endpt) ~ lvmi + age + sex, data = cp )
Times to the first recurrence of a bladder tumour, in months, for 86 patients in a placebo-controlled trial of thiotepa (Collett, 2023, Appendix B.2).
bladderbladder
A data frame with 86 rows and 6 variables:
Patient number (1-86).
Time to first recurrence, in months.
Event indicator: 1 = recurrence, 0 = right-censored.
Treatment: 1 = placebo, 2 = thiotepa.
Initial number of tumours.
Diameter of the largest initial tumour, in cm.
The trial was conducted by the Veterans Administration Cooperative Urological Research Group. Superficial tumours were removed transurethrally before randomisation. The original data set in Andrews and Herzberg (1985) contains the times to up to nine recurrences; the file here keeps only the time to the first recurrence (47 recurrences).
The appendix suggests a Cox model for init and size, an assessment of the
treatment effect after adjustment, a test of interaction, model-checking
diagnostics, a test of proportional hazards for treatment using a
time-dependent variable, and a comparison with a Weibull proportional
hazards model.
This data set is not used in a numbered example, so it has no dX.Y alias.
See dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Appendix B.2 (Table B.2). Data from Andrews and Herzberg (1985).
# Collett (2023), Appendix B.2 (no numbered example) ------------------ # Chapter 17 style: Cox model for the time to the first recurrence survival::coxph( survival::Surv(time, status) ~ init + size + factor(treat), data = bladder ) # Modern tools -------------------------------------------------------- if (requireNamespace("broom", quietly = TRUE)) { broom::tidy( survival::coxph( survival::Surv(time, status) ~ init + size + factor(treat), data = bladder ), exponentiate = TRUE, conf.int = TRUE ) }# Collett (2023), Appendix B.2 (no numbered example) ------------------ # Chapter 17 style: Cox model for the time to the first recurrence survival::coxph( survival::Surv(time, status) ~ init + size + factor(treat), data = bladder ) # Modern tools -------------------------------------------------------- if (requireNamespace("broom", quietly = TRUE)) { broom::tidy( survival::coxph( survival::Surv(time, status) ~ init + size + factor(treat), data = bladder ), exponentiate = TRUE, conf.int = TRUE ) }
Survival times, in days, of 37 leukaemia patients who received a bone marrow transplant, together with donor and recipient variables (Collett, 2023, Appendix B.4).
bmtbmt
A data frame with 37 rows and 9 variables:
Patient number (1-37).
Survival time in days.
Event indicator: 1 = death, 0 = alive.
Age of the recipient in years.
Age of the donor in years.
Type of leukaemia: 1 = AML, 2 = ALL, 3 = CML.
Whether the donor had previously been pregnant: 0 = no, 1 = yes.
Index of mixed epidermal lymphocyte reactions.
Graft-versus-host disease: 0 = no, 1 = yes.
The 37 patients were in complete remission from AML or ALL, or in the chronic phase of CML, and received a non-depleted allogeneic bone marrow transplant. There are 17 deaths. The data were also given in Altman (1991).
The appendix suggests fitting a Weibull accelerated failure time model, estimating and plotting the baseline survivor function, comparing with log-logistic and lognormal models and with a Cox model, and checking the adequacy of the preferred model. See bmt_leukaemia (a different study of 23 patients) and bmt_outcome (EBMT registry data).
This data set is not used in a numbered example, so it has no dX.Y alias.
See dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Appendix B.4 (Table B.4). Data from Bagot et al. (1988) and Altman (1991).
# Collett (2023), Appendix B.4 (no numbered example) ------------------ # Chapter 17 style: Weibull accelerated failure time model survival::survreg( survival::Surv(time, status) ~ rage + dage + factor(type) + gvhd, data = bmt, dist = "weibull" ) # The corresponding Cox model survival::coxph( survival::Surv(time, status) ~ rage + dage + factor(type) + gvhd, data = bmt ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(time, status) ~ rage + dage + factor(type) + gvhd, data = bmt, dist = "weibull" ) }# Collett (2023), Appendix B.4 (no numbered example) ------------------ # Chapter 17 style: Weibull accelerated failure time model survival::survreg( survival::Surv(time, status) ~ rage + dage + factor(type) + gvhd, data = bmt, dist = "weibull" ) # The corresponding Cox model survival::coxph( survival::Surv(time, status) ~ rage + dage + factor(type) + gvhd, data = bmt ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(time, status) ~ rage + dage + factor(type) + gvhd, data = bmt, dist = "weibull" ) }
Survival times, in days, of 23 leukaemia patients who received a bone marrow transplant, with donor and recipient characteristics and an indicator of platelet recovery (Collett, 2023, Example 8.2).
bmt_leukaemiabmt_leukaemia
A data frame with 23 rows and 8 variables:
Patient number (1-23).
Survival time in days from transplantation.
Event indicator: 1 = death, 0 = alive at the end of follow-up.
Disease group: 1 = acute lymphoblastic leukaemia (ALL), 2 = low-risk acute myeloid leukaemia (AML), 3 = high-risk AML.
Age of the patient in years.
Age of the bone marrow donor in years.
Platelet recovery: 0 = no, 1 = platelet count returned to a normal level of 40 x 10^9 per litre.
Time in days until the platelet count returned to normal
(NA when precovery is 0).
This is the subset of the study from St Vincent's Hospital, Sydney, used by
Klein and Moeschberger (2005). There are 12 deaths. Patients 7 and 21 died
before their platelet count returned to normal, and so ptime is missing for
them; these missing values are stored as NA in the package.
The data illustrate the use of a time-dependent covariate: the indicator of
platelet recovery changes from 0 to 1 at ptime, so the survival data are
expanded into the counting process format (Example 8.2, and Example 8.1
introduces the format itself).
The data set is available under the alias d8.2; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 8.2 (Table 8.2). Data from Klein and Moeschberger (2005).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 8.2: platelet recovery as a time-dependent covariate base <- bmt_leukaemia[, c("patient", "time", "status", "group", "page", "dage")] recovery <- subset(bmt_leukaemia, precovery == 1)[, c("patient", "ptime")] cp <- survival::tmerge(base, base, id = patient, endpt = event(time, status)) cp <- survival::tmerge(cp, recovery, id = patient, preg = tdc(ptime)) survival::coxph( survival::Surv(tstart, tstop, endpt) ~ preg + factor(group) + page + dage, data = cp )# Collett (2023), Chapter 17 style ----------------------------------- # Example 8.2: platelet recovery as a time-dependent covariate base <- bmt_leukaemia[, c("patient", "time", "status", "group", "page", "dage")] recovery <- subset(bmt_leukaemia, precovery == 1)[, c("patient", "ptime")] cp <- survival::tmerge(base, base, id = patient, endpt = event(time, status)) cp <- survival::tmerge(cp, recovery, id = patient, preg = tdc(ptime)) survival::coxph( survival::Surv(tstart, tstop, endpt) ~ preg + factor(group) + page + dage, data = cp )
Data from 2204 leukaemia patients who received a bone marrow transplant, with times to platelet recovery and to relapse or death (Collett, 2023, Example 13.4).
bmt_outcomebmt_outcome
A data frame with 2204 rows and 9 variables:
Patient identifier.
Disease type: "AML", "ALL" or "CML".
Age group: "<=20", "21-40" or ">40".
Donor-recipient gender match: 0 = no, 1 = yes.
T-cell depletion: 0 = no, 1 = yes.
Time from transplantation to platelet recovery, in days.
Platelet recovery indicator: 0 = censored, 1 = recovery.
Time from transplantation to relapse or death, in days.
Relapse-or-death indicator: 0 = censored, 1 = event.
The data come from the European Group for Blood and Marrow Transplantation (EBMT) Registry, and are the version used by Putter, Fiocco and Geskus (2007). Following the transplant a patient may either recover platelet function and later relapse or die, or relapse or die before platelet recovery. The data therefore describe a three-state model with transition rates for transplantation to platelet recovery, transplantation to relapse or death, and platelet recovery to relapse or death.
Of the 2204 patients, 1169 experienced platelet recovery and 458 relapsed
or died before their platelet count had returned to normal; a further 383
patients relapsed or died after platelet recovery. Note that the ptime
of a patient who relapsed before recovering platelets is censored at the
time of relapse when the first transition is modelled. To fit the model the
data are expanded into one row per possible transition per patient
(Example 13.4).
The data set is available under the alias d13.4; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 13.4 (Table 13.9). Data from the EBMT Registry, see Putter, Fiocco and Geskus (2007).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 13.4: the two endpoints of the three-state model # 1 -> 2: platelet recovery survival::coxph( survival::Surv(ptime, pcens) ~ leukaemia + age + match + tcell, data = bmt_outcome ) # 1 -> 3: relapse or death before recovery survival::coxph( survival::Surv(rdtime, rdcens) ~ leukaemia + age + match + tcell, data = bmt_outcome ) # Modern tools -------------------------------------------------------- # Transition-specific hazards are fitted by stratifying on the transition if (requireNamespace("mstate", quietly = TRUE)) { tmat <- mstate::transMat( list(c(2, 3), 3, c()), names = c("transplant", "recovery", "relapse") ) tmat }# Collett (2023), Chapter 17 style ----------------------------------- # Example 13.4: the two endpoints of the three-state model # 1 -> 2: platelet recovery survival::coxph( survival::Surv(ptime, pcens) ~ leukaemia + age + match + tcell, data = bmt_outcome ) # 1 -> 3: relapse or death before recovery survival::coxph( survival::Surv(rdtime, rdcens) ~ leukaemia + age + match + tcell, data = bmt_outcome ) # Modern tools -------------------------------------------------------- # Transition-specific hazards are fitted by stratifying on the transition if (requireNamespace("mstate", quietly = TRUE)) { tmat <- mstate::transMat( list(c(2, 3), 3, c()), names = c("transplant", "recovery", "relapse") ) tmat }
Survival times, in months, of 45 women who received a mastectomy for a Grade II, III or IV breast tumour, classified by whether the tumour stained positively or negatively with the lectin HPA (Collett, 2023, Example 1.2).
breastbreast
A data frame with 45 rows and 3 variables:
Result of HPA staining: 1 = negative, 2 = positive. Positive staining indicates a tumour with the potential to metastasise.
Survival time in months from surgery.
Event indicator: 1 = death from breast cancer, 0 = right-censored.
The women were treated between January 1969 and December 1971 and the study was closed in July 1987. Women still alive at that date, as well as women who died from causes other than breast cancer, contribute censored times. There are 13 women in the negative-staining group and 32 in the positive-staining group, with 26 deaths in total.
This is the standard small example for comparing two survival curves: the
Kaplan-Meier estimate by group (Examples 2.11-2.14), the log-rank and
Wilcoxon tests (Section 2.4) and a Cox model with stain as the single
covariate (Examples 3.1 and 3.3).
The data set is available under the aliases d1.2, d2.11, d2.12,
d2.13, d2.14, d3.1, d3.3, d5.5, d5.6, d5.7, d5.8, d5.13,
d5.14, d5.17, d10.1, d10.2, d16.4, d16.5, d16.6; dX.Y is
the alias for the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 1.2 (Table 1.2). Data from Leathem and Brooks (1987).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 1.2: survival by HPA staining (1 = negative, 2 = positive) survival::survfit(survival::Surv(time, status) ~ stain, data = breast) # Examples 2.11-2.14: log-rank and Peto-Peto tests survival::survdiff(survival::Surv(time, status) ~ stain, data = breast) survival::survdiff(survival::Surv(time, status) ~ stain, data = breast, rho = 1) # Examples 3.1 and 3.3: Cox model with the staining indicator fit_breast <- survival::coxph(survival::Surv(time, status) ~ stain, data = breast) summary(fit_breast) # Examples 5.5-5.8, 5.13, 5.14 and 5.17: Weibull models survival::survreg(survival::Surv(time, status) ~ stain, data = breast, dist = "weibull") # Modern tools -------------------------------------------------------- if (requireNamespace("ggsurvfit", quietly = TRUE)) { ggsurvfit::survfit2(survival::Surv(time, status) ~ stain, data = breast) |> ggsurvfit::ggsurvfit() |> ggsurvfit::add_risktable() } if (requireNamespace("broom", quietly = TRUE)) { broom::tidy(fit_breast, exponentiate = TRUE, conf.int = TRUE) } if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg(survival::Surv(time, status) ~ stain, data = breast, dist = "weibull") }# Collett (2023), Chapter 17 style ----------------------------------- # Example 1.2: survival by HPA staining (1 = negative, 2 = positive) survival::survfit(survival::Surv(time, status) ~ stain, data = breast) # Examples 2.11-2.14: log-rank and Peto-Peto tests survival::survdiff(survival::Surv(time, status) ~ stain, data = breast) survival::survdiff(survival::Surv(time, status) ~ stain, data = breast, rho = 1) # Examples 3.1 and 3.3: Cox model with the staining indicator fit_breast <- survival::coxph(survival::Surv(time, status) ~ stain, data = breast) summary(fit_breast) # Examples 5.5-5.8, 5.13, 5.14 and 5.17: Weibull models survival::survreg(survival::Surv(time, status) ~ stain, data = breast, dist = "weibull") # Modern tools -------------------------------------------------------- if (requireNamespace("ggsurvfit", quietly = TRUE)) { ggsurvfit::survfit2(survival::Surv(time, status) ~ stain, data = breast) |> ggsurvfit::ggsurvfit() |> ggsurvfit::add_risktable() } if (requireNamespace("broom", quietly = TRUE)) { broom::tidy(fit_breast, exponentiate = TRUE, conf.int = TRUE) } if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg(survival::Surv(time, status) ~ stain, data = breast, dist = "weibull") }
Recurrence-free survival times, in days, of 686 patients with node-positive breast cancer from the German Breast Cancer Study Group (Collett, 2023, Example 6.5).
breast_rfsbreast_rfs
A data frame with 686 rows and 11 variables:
Patient number.
Hormonal treatment: 0 = no tamoxifen, 1 = tamoxifen.
Age of the patient in years.
Menopausal status: 1 = premenopausal, 2 = postmenopausal.
Tumour size in mm.
Tumour grade (1, 2 or 3).
Number of positive lymph nodes.
Progesterone receptor status (femtomoles).
Oestrogen receptor status (femtomoles).
Recurrence-free survival time in days.
Event indicator: 1 = relapse or death, 0 = right-censored.
The patients had primary, histologically proven, non-metastatic node-positive breast cancer treated with mastectomy; the study compared three with six cycles of chemotherapy and investigated additional hormonal treatment. Recurrence-free survival is the time from entry until a recurrence of the cancer or death, and there are 299 events.
The example introduces flexible parametric (Royston-Parmar) models with a treatment effect and several prognostic variables (Examples 6.5 and 6.6).
The data set is available under the aliases d6.5, d6.6; dX.Y is the
alias for the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 6.5 (Table 6.1). Data from Schumacher et al. (1994) and Sauerbrei and Royston (1999).
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 6.5 and 6.6: log-logistic (proportional odds) model survival::survreg( survival::Surv(time, status) ~ treat + age + men + size + grade + nodes + prog + oest, data = breast_rfs, dist = "loglogistic" ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvspline( survival::Surv(time, status) ~ treat + age + men + size + grade + nodes + prog + oest, data = breast_rfs, k = 1 ) }# Collett (2023), Chapter 17 style ----------------------------------- # Examples 6.5 and 6.6: log-logistic (proportional odds) model survival::survreg( survival::Surv(time, status) ~ treat + age + men + size + grade + nodes + prog + oest, data = breast_rfs, dist = "loglogistic" ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvspline( survival::Surv(time, status) ~ treat + age + men + size + grade + nodes + prog + oest, data = breast_rfs, k = 1 ) }
Time to the first serious infection for 128 patients with chronic granulomatous disease (CGD) in a multicentre trial (Collett, 2023, Appendix B.5).
cgdcgd
A data frame with 128 rows and 12 variables:
Patient number (1-128).
Time to the first serious infection, in days.
Event indicator: 1 = infection, 0 = censored.
Trial centre (1-14; centre 8 does not occur in these data).
Treatment: 0 = placebo, 1 = interferon.
Age in years.
Sex: 1 = male, 2 = female.
Height in cm.
Weight in kg.
Pattern of inheritance: 1 = X-linked, 2 = autosomal recessive.
Use of corticosteroids at trial entry: 1 = used, 2 = not used.
Use of antibiotics at trial entry: 1 = used, 2 = not used.
CGD is a group of inherited disorders that leave patients vulnerable to recurrent infections. The trial compared the antiviral drug interferon with placebo, and the endpoint is the time to the first serious infection after randomisation; there are 44 infections. The data were described by Therneau and Grambsch (2000); this is the 128-patient version used in the book.
The appendix suggests a wide range of analyses: model selection and model
checking, consistency of the treatment effect across centres, a
constructed interval-censored version of the data, shared frailty models
with centre as a random effect, risk-adjusted centre-specific infection
rates, and an inverse probability of censoring weighting analysis for
dependent censoring. The infection data are also available, in a larger
form, as cgd in the survival package.
This data set is not used in a numbered example, so it has no dX.Y alias.
See dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Appendix B.5. Data described by Therneau and Grambsch (2000); the trial was carried out by Genentech, Inc.
# Collett (2023), Appendix B.5 (no numbered example) ------------------ # Chapter 17 style: Cox model for the first serious infection survival::coxph( survival::Surv(time, status) ~ factor(treat) + age + sex + height + weight, data = cgd ) # A shared frailty for trial centre survival::coxph( survival::Surv(time, status) ~ factor(treat) + age + frailty(centre), data = cgd ) # Modern tools -------------------------------------------------------- if (requireNamespace("coxme", quietly = TRUE)) { coxme::coxme( survival::Surv(time, status) ~ factor(treat) + age + (1 | centre), data = cgd ) }# Collett (2023), Appendix B.5 (no numbered example) ------------------ # Chapter 17 style: Cox model for the first serious infection survival::coxph( survival::Surv(time, status) ~ factor(treat) + age + sex + height + weight, data = cgd ) # A shared frailty for trial centre survival::coxph( survival::Surv(time, status) ~ factor(treat) + age + frailty(centre), data = cgd ) # Modern tools -------------------------------------------------------- if (requireNamespace("coxme", quietly = TRUE)) { coxme::coxme( survival::Surv(time, status) ~ factor(treat) + age + (1 | centre), data = cgd ) }
Survival times, in days, of 12 patients in an artificial study of the treatment of cirrhosis of the liver, with baseline age and bilirubin level (Collett, 2023, Example 8.4).
cirrhosiscirrhosis
A data frame with 12 rows and 6 variables:
Patient number (1-12).
Survival time in days.
Event indicator: 1 = death, 0 = right-censored.
Age of the patient in years.
Treatment: 0 = placebo, 1 = Liverol.
Logarithm of the baseline bilirubin level (in micromol/l).
The data are artificial but are used to mimic a real liver study. Six
patients are allocated to Liverol and six to placebo. The baseline
log(bilirubin) value is analysed first, and the treatment effect is
estimated after adjustment for age and lbr (Example 8.4).
The same patients appear in three files in this package. cirrhosis holds
the baseline values (one row per patient), cirrhosis_lbr holds the
repeated log(bilirubin) measurements in long format (one row per visit) and
cirrhosis_cp holds the survival data together with the time-dependent
log(bilirubin) value in counting process format (one row per interval).
See cirrhosis_lbr and cirrhosis_cp.
The data set is available under the alias d8.4; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 8.4 (Table 8.4). The hypothetical study is loosely based on the primary biliary cirrhosis data of Therneau and Grambsch (2000).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 8.4: the baseline model survival::coxph( survival::Surv(time, status) ~ age + lbr + treat, data = cirrhosis ) # Example 8.4: log(bilirubin) as a time-dependent covariate # (two patients have a zero-length interval, hence the filter) cp <- subset(cirrhosis_cp, stop > start) survival::coxph(survival::Surv(start, stop, status) ~ lbrt + age, data = cp)# Collett (2023), Chapter 17 style ----------------------------------- # Example 8.4: the baseline model survival::coxph( survival::Surv(time, status) ~ age + lbr + treat, data = cirrhosis ) # Example 8.4: log(bilirubin) as a time-dependent covariate # (two patients have a zero-length interval, hence the filter) cp <- subset(cirrhosis_cp, stop > start) survival::coxph(survival::Surv(start, stop, status) ~ lbrt + age, data = cp)
Survival data for the 12 patients in the cirrhosis study, with the log(bilirubin) level as a time-dependent covariate, in counting process format (Collett, 2023, Example 8.4).
cirrhosis_cpcirrhosis_cp
A data frame with 54 rows and 7 variables:
Patient number (1-12).
Start of the interval, in days.
End of the interval, in days.
Event indicator for the interval: 1 = death at stop,
0 = otherwise.
Treatment: 0 = placebo, 1 = Liverol.
Age of the patient in years.
Time-dependent log(bilirubin) value in effect during the
interval, i.e. the most recent measurement after start and up to
stop.
Each row is a time interval during which all covariates are constant, so a
patient with many visits contributes several rows. Patient 1, for example,
has log(bilirubin) 3.2 for t <= 47, 3.8 for 47 < t <= 184, 4.9 for
184 < t <= 251 and 5.0 for 251 < t <= 281. The data are used to fit a Cox
model with a time-dependent covariate (start, stop and status form the
response).
The baseline values are in cirrhosis and the repeated measurements in cirrhosis_lbr.
Used in Example 8.4, but the alias d8.4 is the baseline cirrhosis; this
counting-process form has no alias of its own. See dataset_by_exercise
for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 8.4 (Tables 8.4 and 8.5).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 8.4: counting process form of the cirrhosis study # (patient 5 and patient 8 have a zero-length interval, hence the filter) cp <- subset(cirrhosis_cp, stop > start) survival::coxph(survival::Surv(start, stop, status) ~ lbrt + age, data = cp) # Without the time-dependent covariate, for comparison with the baseline data survival::coxph(survival::Surv(start, stop, status) ~ treat + age, data = cp)# Collett (2023), Chapter 17 style ----------------------------------- # Example 8.4: counting process form of the cirrhosis study # (patient 5 and patient 8 have a zero-length interval, hence the filter) cp <- subset(cirrhosis_cp, stop > start) survival::coxph(survival::Surv(start, stop, status) ~ lbrt + age, data = cp) # Without the time-dependent covariate, for comparison with the baseline data survival::coxph(survival::Surv(start, stop, status) ~ treat + age, data = cp)
Repeated measurements of log(bilirubin) for the 12 patients in the cirrhosis study, in long format (Collett, 2023, Example 8.4).
cirrhosis_lbrcirrhosis_lbr
A data frame with 42 rows and 3 variables:
Patient number (1-12).
Time of the measurement, in days from the start of treatment.
Logarithm of the bilirubin level (in micromol/l) measured at
time.
Patients return to the clinic three, six and twelve months after the start of treatment and yearly thereafter. Values for a given patient form a step function that is constant between two adjacent visits, with the new value taking effect immediately after the reading. This file is the input to the counting process version of the data, cirrhosis_cp; the baseline values are in cirrhosis.
Used in Example 8.4, but the alias d8.4 is the baseline cirrhosis; this
long-format form has no alias of its own. See dataset_by_exercise for the
complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 8.4 (Table 8.5).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 8.4: the repeated log(bilirubin) measurements in long format head(cirrhosis_lbr) # These are the measurements from which the time-dependent covariate lbrt # in cirrhosis_cp is built: the value at each visit applies until the next. merge( cirrhosis[c("patient", "time", "status")], cirrhosis_lbr, by = "patient", suffixes = c("_surv", "_visit") ) |> head()# Collett (2023), Chapter 17 style ----------------------------------- # Example 8.4: the repeated log(bilirubin) measurements in long format head(cirrhosis_lbr) # These are the measurements from which the time-dependent covariate lbrt # in cirrhosis_cp is built: the value at each visit applies until the next. merge( cirrhosis[c("patient", "time", "status")], cirrhosis_lbr, by = "patient", suffixes = c("_surv", "_visit") ) |> head()
An index of the data sets in the package, one row for each combination of a
data set and a worked example in Collett (2023) that uses it. Each such
combination also defines an alias dX.Y, where X.Y is the number of the
example, and the alias is a copy of the data set. A data set that is used in
several examples therefore has several aliases.
dataset_by_exercisedataset_by_exercise
A data frame with one row per data set and example, with columns:
Name of the data set in the package.
Descriptive title of the data set, as on its help page.
Alias of the data set for this example, dX.Y, or NA for
data sets that are not used in a numbered example.
Number of the example in Collett (2023), such as "3.7",
or NA.
Number of the chapter that contains the example, or NA.
Title of that chapter, or NA.
Title of the example as it appears in the book, or
NA.
Number of rows in the data set.
Number of columns in the data set.
A note for data sets that are not used in a numbered example, for example that they come from an appendix of the book or from the course material.
The index was compiled from the Example X.Y headings of the 4th edition.
The aliases are the data sets themselves, saved under the name dX.Y, so
d3.7 is the data used in Example 3.7 (the myeloma data) and d8.4 is
the baseline cirrhosis data. Use dataset_by_exercise to look up which
data set an example uses, and ?d3.7 to open the help page of that data
set.
Four data sets from the appendices of the book (bladder, ducks, bmt
and cgd) and the synthetic scottish_mbc_cohort are not used in a
numbered example. They have no alias and their example is NA; the
note column says where they come from. The cirrhosis study is the only
example with more than one data set in the package: cirrhosis is the
baseline form and has the alias d8.4, while cirrhosis_lbr and
cirrhosis_cp are the long and counting-process forms used in the same
example and have no alias of their own.
The table is generated by data-raw/dataset_by_exercise.R; re-run that
script after adding a data set or changing the example mapping.
The worked examples in Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC.
iud, breast, myeloma and the other data sets; the package
vignette vignette("datasets-by-exercise") presents the same index.
head(dataset_by_exercise) subset(dataset_by_exercise, dataset == "myeloma") # The alias is a copy of the data set identical(d3.7, myeloma)head(dataset_by_exercise) subset(dataset_by_exercise, dataset == "myeloma") # The alias is a copy of the data set identical(d3.7, myeloma)
Times from insertion of a catheter to its removal following infection, for 13 kidney patients (Collett, 2023, Example 4.1).
dialysisdialysis
A data frame with 13 rows and 5 variables:
Patient number (1-13).
Time from insertion of the catheter to its removal, in days.
Event indicator: 1 = catheter removed because of infection, 0 = removed for another reason.
Age of the patient in years.
Sex: 1 = male, 2 = female.
The data relate to the 13 patients with kidney disease coded as type 3 by McGilchrist and Aisbett (1991). In the original study each patient could experience an infection of both the first and the second catheter, but only the time to removal of the first catheter is given here. There is a single censored observation (patient 6).
With 13 observations and 12 events the data set is used to demonstrate model-checking diagnostics for the Cox model: Cox-Snell, martingale and deviance residuals and influence (Examples 4.1-4.4), a non-linear effect of age and a time-dependent effect of sex (Examples 4.10-4.12).
The data set is available under the aliases d4.1, d4.2, d4.3, d4.4,
d4.6, d4.7, d4.10, d4.11, d4.12; dX.Y is the alias for the data
set used in Example X.Y of Collett (2023). See dataset_by_exercise for
the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 4.1 (Table 4.1). Data from McGilchrist and Aisbett (1991).
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 4.1-4.4: Cox model and the model-checking residuals fit_dialysis <- survival::coxph( survival::Surv(time, status) ~ age + sex, data = dialysis ) summary(fit_dialysis) head(stats::residuals(fit_dialysis, type = "martingale")) head(stats::residuals(fit_dialysis, type = "dfbeta")) # Examples 4.10 and 4.11: a non-linear effect of age survival::coxph( survival::Surv(time, status) ~ age + I(age^2) + sex, data = dialysis ) # Example 4.12: a time-varying coefficient for sex survival::coxph( survival::Surv(time, status) ~ age + sex + tt(sex), data = dialysis, tt = function(x, t, ...) x * t ) # Modern tools -------------------------------------------------------- if (requireNamespace("rms", quietly = TRUE)) { rms::cph(survival::Surv(time, status) ~ age + sex, data = dialysis, x = TRUE, y = TRUE) }# Collett (2023), Chapter 17 style ----------------------------------- # Examples 4.1-4.4: Cox model and the model-checking residuals fit_dialysis <- survival::coxph( survival::Surv(time, status) ~ age + sex, data = dialysis ) summary(fit_dialysis) head(stats::residuals(fit_dialysis, type = "martingale")) head(stats::residuals(fit_dialysis, type = "dfbeta")) # Examples 4.10 and 4.11: a non-linear effect of age survival::coxph( survival::Surv(time, status) ~ age + I(age^2) + sex, data = dialysis ) # Example 4.12: a time-varying coefficient for sex survival::coxph( survival::Surv(time, status) ~ age + sex + tt(sex), data = dialysis, tt = function(x, t, ...) x * t ) # Modern tools -------------------------------------------------------- if (requireNamespace("rms", quietly = TRUE)) { rms::cph(survival::Surv(time, status) ~ age + sex, data = dialysis, x = TRUE, y = TRUE) }
Survival times, in days, of 50 female black ducks captured and fitted with radios (Collett, 2023, Appendix B.3).
ducksducks
A data frame with 50 rows and 6 variables:
Duck number (1-50).
Survival time in days.
Event indicator: 1 = dead, 0 = alive or missing.
Age group: 0 = hatch-year bird, 1 = bird aged at least one year.
Body weight in g.
Wing length in mm.
Fifty female ducks from two locations in New Jersey were captured between 8 November and 14 December 1983 and their status was recorded daily until the study ended on 15 February 1984; there are 18 deaths. The data are included in Hand et al. (1994).
The appendix suggests a proportional hazards model for age, weight and length, a test of whether the coefficients of weight and length differ between age groups, and an assessment of whether non-linear functions of weight and length are needed.
This data set is not used in a numbered example, so it has no dX.Y alias.
See dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Appendix B.3 (Table B.3). Data from Hand et al. (1994); the study was conducted by the US Fish and Wildlife Service.
# Collett (2023), Appendix B.3 (no numbered example) ------------------ # Chapter 17 style: proportional hazards model for age, weight and length survival::coxph( survival::Surv(time, status) ~ age + weight + length, data = ducks ) # Modern tools -------------------------------------------------------- if (requireNamespace("broom", quietly = TRUE)) { broom::tidy( survival::coxph(survival::Surv(time, status) ~ age + weight + length, data = ducks), exponentiate = TRUE, conf.int = TRUE ) }# Collett (2023), Appendix B.3 (no numbered example) ------------------ # Chapter 17 style: proportional hazards model for age, weight and length survival::coxph( survival::Surv(time, status) ~ age + weight + length, data = ducks ) # Modern tools -------------------------------------------------------- if (requireNamespace("broom", quietly = TRUE)) { broom::tidy( survival::coxph(survival::Surv(time, status) ~ age + weight + length, data = ducks), exponentiate = TRUE, conf.int = TRUE ) }
Survival times, in days, of 90 patients with locally advanced gastric cancer, randomised to chemotherapy alone or chemotherapy plus radiotherapy (Collett, 2023, Example 11.2).
gastricgastric
A data frame with 90 rows and 4 variables:
Patient number (1-90).
Time from randomisation to death from gastric cancer, in days.
Event indicator: 1 = death from gastric cancer, 0 = right-censored.
Treatment: 0 = chemotherapy alone, 1 = chemotherapy plus radiotherapy.
The trial was carried out by the Gastrointestinal Tumor Study Group; the patients were followed for over eight years. There are 82 deaths. The estimated survivor functions cross, so the proportional hazards assumption is not tenable and the data are used to motivate non-proportional hazards: the log-cumulative hazard plot, the restricted mean survival time and time-dependent effects (Examples 11.2 and 11.3).
The data set is available under the aliases d11.2, d11.3; dX.Y is the
alias for the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 11.2 (Table 11.2). Data from Stablein and Koutrouvelis (1985).
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 11.2 and 11.3: evidence against proportional hazards survival::cox.zph(survival::coxph(survival::Surv(time, status) ~ treat, data = gastric)) # A treatment effect that differs between time periods gastric_cp <- survival::survSplit( gastric, cut = c(360, 720, 1080), end = "time", event = "status", start = "tstart", episode = "period" ) survival::coxph( survival::Surv(tstart, time, status) ~ treat + treat:strata(period), data = gastric_cp ) # Modern tools -------------------------------------------------------- # The restricted mean survival time summarises the same non-proportional effect rmst <- summary( survival::survfit(survival::Surv(time, status) ~ treat, data = gastric), rmean = 1000 ) rmst$table[, c("rmean", "se(rmean)")]# Collett (2023), Chapter 17 style ----------------------------------- # Examples 11.2 and 11.3: evidence against proportional hazards survival::cox.zph(survival::coxph(survival::Surv(time, status) ~ treat, data = gastric)) # A treatment effect that differs between time periods gastric_cp <- survival::survSplit( gastric, cut = c(360, 720, 1080), end = "time", event = "status", start = "tstart", episode = "period" ) survival::coxph( survival::Surv(tstart, time, status) ~ treat + treat:strata(period), data = gastric_cp ) # Modern tools -------------------------------------------------------- # The restricted mean survival time summarises the same non-proportional effect rmst <- summary( survival::survfit(survival::Surv(time, status) ~ treat, data = gastric), rmean = 1000 ) rmst$table[, c("rmean", "se(rmean)")]
Time from randomisation to linkage to primary care for 447 patients in a residential detoxification programme, in the HELP study (Collett, 2023, Example 16.7).
helphelp
A data frame with 447 rows and 7 variables:
Patient identifier.
Time from randomisation to linkage to primary care, in days.
Event indicator: 1 = linked to primary care, 0 = censored.
Age of the patient in years.
Gender: 0 = female, 1 = male.
Housing status: 0 = homeless, 1 = housed.
Assistance from the HELP clinic in linking to primary care: 0 = no, 1 = yes.
Patients undergoing detoxification for alcohol, heroin or cocaine who had no
primary care physician were randomised to help from a HELP clinic or to no
such help. The response is the number of days until linkage to primary care,
and there are 167 events. The file is the complete-case version of the
HELPmiss data set in the mosaicData package.
The example is the running illustration of Bayesian survival analysis: a Bayesian Weibull model and a piecewise exponential model (Example 16.7).
The data set is available under the alias d16.7; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 16.7 (Tables 16.1 and 16.2). Data from Samet et al. (2003); see also the mosaicData package.
# Collett (2023), Chapter 17 style ----------------------------------- # Example 16.7: a Bayesian Weibull and piecewise exponential model # Chapter 17 fits these with rstanarm::stan_surv(); the maximum likelihood # counterparts below give the same point estimates of the hazard ratios. survival::survreg( survival::Surv(days, status) ~ age + gender + housing + linkage, data = sta310r::help, dist = "weibull" ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(days, status) ~ age + gender + housing + linkage, data = sta310r::help, dist = "weibull" ) }# Collett (2023), Chapter 17 style ----------------------------------- # Example 16.7: a Bayesian Weibull and piecewise exponential model # Chapter 17 fits these with rstanarm::stan_surv(); the maximum likelihood # counterparts below give the same point estimates of the hazard ratios. survival::survreg( survival::Surv(days, status) ~ age + gender + housing + linkage, data = sta310r::help, dist = "weibull" ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(days, status) ~ age + gender + housing + linkage, data = sta310r::help, dist = "weibull" ) }
Survival times, in months, of 44 patients with chronic active hepatitis, randomised to prednisolone or to an untreated control group (Collett, 2023, Appendix B.1).
hepatitishepatitis
A data frame with 44 rows and 3 variables:
Treatment: 1 = prednisolone, 2 = control.
Survival time in months from admission to the trial.
Event indicator: 1 = death, 0 = right-censored.
The data were originally reported by Kirk et al. (1980) and given in Pocock (1983); there are 27 deaths. The trial is used in Chapter 15 as the worked example for sample size calculation: with five-year survival of 0.41 under the standard treatment and 0.60 under the new treatment, the number of events required by Schoenfeld's formula is about 140, corresponding to roughly 400 patients (Examples 15.1-15.3). The appendix also suggests survival curves by treatment, the log-rank and Wilcoxon tests, Cox and Weibull models and a log-cumulative hazard plot.
The data set is available under the aliases d15.1, d15.2, d15.3;
dX.Y is the alias for the data set used in Example X.Y of Collett (2023).
See dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Appendix B.1 (Table B.1) and Examples 15.1-15.3. Data from Kirk et al. (1980) via Pocock (1983).
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 15.1-15.3: number of events for the log-rank test # Schoenfeld's formula, as in Equation 15.1 hr <- 0.57 alpha <- 0.05 power <- 0.8 (stats::qnorm(1 - alpha / 2) + stats::qnorm(power))^2 / (0.25 * log(hr)^2) # The survival times themselves are used for the exponential model survival::survfit(survival::Surv(time, status) ~ treatment, data = hepatitis) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(time, status) ~ treatment, data = hepatitis, dist = "exponential" ) }# Collett (2023), Chapter 17 style ----------------------------------- # Examples 15.1-15.3: number of events for the log-rank test # Schoenfeld's formula, as in Equation 15.1 hr <- 0.57 alpha <- 0.05 power <- 0.8 (stats::qnorm(1 - alpha / 2) + stats::qnorm(power))^2 / (0.25 * log(hr)^2) # The survival times themselves are used for the exponential model survival::survfit(survival::Surv(time, status) ~ treatment, data = hepatitis) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(time, status) ~ treatment, data = hepatitis, dist = "exponential" ) }
Survival times, in months, of 36 patients with hypernephroma (a malignant tumour of the kidney) treated with chemotherapy and immunotherapy, with or without a nephrectomy, and classified by age group (Collett, 2023, Example 3.4).
hyperhyper
A data frame with 36 rows and 4 variables:
Whether the kidney was surgically removed: 0 = no, 1 = yes.
Age group at diagnosis: 1 = under 60 years, 2 = 60-70 years, 3 = over 70 years.
Survival time in months.
Event indicator: 1 = death, 0 = right-censored.
The age of each patient has been grouped for the analysis (the underlying age in years is not included). The example is the running illustration of the Cox regression model: indicator variables for a factor with three levels, models with and without interaction, and the interpretation of the baseline hazard (Examples 3.4, 3.10, 3.11, 3.13 and 3.14), followed by the corresponding Weibull analysis (Examples 5.10, 6.1 and 6.4).
The data set is available under the aliases d3.4, d3.10, d3.11,
d3.13, d3.14, d5.10, d6.1, d6.4; dX.Y is the alias for the data
set used in Example X.Y of Collett (2023). See dataset_by_exercise for
the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 3.4 (Table 3.6). Data from Lee and Wang (2013).
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 3.4, 3.10, 3.11, 3.13 and 3.14: Cox model with age group fit_hyper <- survival::coxph( survival::Surv(time, status) ~ nephrectomy + factor(age), data = hyper ) summary(fit_hyper) # Example 5.10: the corresponding Weibull model survival::survreg( survival::Surv(time, status) ~ nephrectomy + factor(age), data = hyper, dist = "weibull" ) # Examples 6.1 and 6.4: piecewise exponential baseline hazard # Chapter 17 fits this with phreg(dist = "pch", cuts = ...) in the eha package; # pchreg() is the current name of the same fit. eha::pchreg( survival::Surv(time, status) ~ factor(age) + nephrectomy, data = hyper, cuts = c(5, 6, 8, 9, 10, 12, 14, 15, 17, 18, 21, 26, 35, 36, 38, 48, 52, 56, 68, 72, 84, 108, 115) ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvspline( survival::Surv(time, status) ~ nephrectomy + factor(age), data = hyper, k = 1 ) }# Collett (2023), Chapter 17 style ----------------------------------- # Examples 3.4, 3.10, 3.11, 3.13 and 3.14: Cox model with age group fit_hyper <- survival::coxph( survival::Surv(time, status) ~ nephrectomy + factor(age), data = hyper ) summary(fit_hyper) # Example 5.10: the corresponding Weibull model survival::survreg( survival::Surv(time, status) ~ nephrectomy + factor(age), data = hyper, dist = "weibull" ) # Examples 6.1 and 6.4: piecewise exponential baseline hazard # Chapter 17 fits this with phreg(dist = "pch", cuts = ...) in the eha package; # pchreg() is the current name of the same fit. eha::pchreg( survival::Surv(time, status) ~ factor(age) + nephrectomy, data = hyper, cuts = c(5, 6, 8, 9, 10, 12, 14, 15, 17, 18, 21, 26, 35, 36, 38, 48, 52, 56, 68, 72, 84, 108, 115) ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvspline( survival::Surv(time, status) ~ nephrectomy + factor(age), data = hyper, k = 1 ) }
Number of weeks from the start of use of a Multiload 250 intrauterine device until discontinuation because of menstrual bleeding problems, for 18 women (Collett, 2023, Example 1.1). The data come from a World Health Organization study of contraceptive methods.
iudiud
A data frame with 18 rows and 2 variables:
Time from first use of the IUD to discontinuation, in weeks.
Event indicator: 1 = discontinuation due to menstrual bleeding problems, 0 = right-censored.
The time origin is the first day of IUD use and the endpoint is discontinuation because of bleeding problems. Women who stopped using the device for other reasons (desire for pregnancy, no further need of contraception, lost to follow-up) contribute censored observations, as do three women whose follow-up extended beyond the two-year study protocol. There are 9 events and 9 censored times among the 18 women, three of the censored times being greater than 104 weeks.
The data are small enough to illustrate the product-limit estimator by hand. In the book they are used for the Kaplan-Meier estimate and the median (Examples 2.3-2.10), for exponential, Weibull and log-logistic parametric models (Examples 5.1-5.4) and for Bayesian analyses (Examples 16.1-16.3).
The data set is available under the aliases d1.1, d2.3, d2.4, d2.5,
d2.7, d2.8, d2.9, d2.10, d5.1, d5.2, d5.3, d5.4, d16.1,
d16.2, d16.3; dX.Y is the alias for the data set used in Example X.Y
of Collett (2023). See dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 1.1 (Table 1.1). Data from the World Health Organization (1987).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 1.1: times to discontinuation of an IUD survival::survfit(survival::Surv(time, status) ~ 1, data = iud) # Examples 2.3-2.5 and 2.7-2.10: product-limit estimate and the median km_iud <- survival::survfit(survival::Surv(time, status) ~ 1, data = iud) summary(km_iud, times = c(12, 24, 48)) quantile(km_iud, probs = c(0.25, 0.5, 0.75)) # Examples 5.1-5.4: exponential, Weibull and log-logistic models survival::survreg(survival::Surv(time, status) ~ 1, data = iud, dist = "exponential") survival::survreg(survival::Surv(time, status) ~ 1, data = iud, dist = "weibull") survival::survreg(survival::Surv(time, status) ~ 1, data = iud, dist = "loglogistic") # Examples 16.1-16.3: conjugate gamma posterior for the exponential rate # (a vague Gamma(0.001, 0.001) prior, as in the book) a1 <- 0.001 + sum(iud$status) b1 <- 0.001 + sum(iud$time) c(mean = a1 / b1, stats::qgamma(c(0.025, 0.975), a1, b1)) # For a non-conjugate model Chapter 17 uses rstanarm::stan_surv(). # Modern tools -------------------------------------------------------- if (requireNamespace("ggsurvfit", quietly = TRUE)) { ggsurvfit::survfit2(survival::Surv(time, status) ~ 1, data = iud) |> ggsurvfit::ggsurvfit() + ggsurvfit::add_confidence_interval() } if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg(survival::Surv(time, status) ~ 1, data = iud, dist = "weibull") }# Collett (2023), Chapter 17 style ----------------------------------- # Example 1.1: times to discontinuation of an IUD survival::survfit(survival::Surv(time, status) ~ 1, data = iud) # Examples 2.3-2.5 and 2.7-2.10: product-limit estimate and the median km_iud <- survival::survfit(survival::Surv(time, status) ~ 1, data = iud) summary(km_iud, times = c(12, 24, 48)) quantile(km_iud, probs = c(0.25, 0.5, 0.75)) # Examples 5.1-5.4: exponential, Weibull and log-logistic models survival::survreg(survival::Surv(time, status) ~ 1, data = iud, dist = "exponential") survival::survreg(survival::Surv(time, status) ~ 1, data = iud, dist = "weibull") survival::survreg(survival::Surv(time, status) ~ 1, data = iud, dist = "loglogistic") # Examples 16.1-16.3: conjugate gamma posterior for the exponential rate # (a vague Gamma(0.001, 0.001) prior, as in the book) a1 <- 0.001 + sum(iud$status) b1 <- 0.001 + sum(iud$time) c(mean = a1 / b1, stats::qgamma(c(0.025, 0.975), a1, b1)) # For a non-conjugate model Chapter 17 uses rstanarm::stan_surv(). # Modern tools -------------------------------------------------------- if (requireNamespace("ggsurvfit", quietly = TRUE)) { ggsurvfit::survfit2(survival::Surv(time, status) ~ 1, data = iud) |> ggsurvfit::ggsurvfit() + ggsurvfit::add_confidence_interval() } if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg(survival::Surv(time, status) ~ 1, data = iud, dist = "weibull") }
Transplant survival times of 434 kidney recipients, where the two kidneys of a donor may have been transplanted into two different recipients (Collett, 2023, Example 10.4).
kidneykidney
A data frame with 434 rows and 7 variables:
Patient number (1-434).
Donor number (1-270). Recipients of kidneys from the same donor share this value.
Transplant survival time in days; the earlier of graft failure and death with a functioning graft.
Event indicator: 1 = transplant failure, 0 = right-censored.
Age of the recipient in years.
Diabetes status: 0 = absent, 1 = present.
Cold ischaemic time, in hours, between retrieval of the kidney and transplantation.
The transplants used organs from deceased donors following circulatory death. Of the 270 donors, 106 gave one kidney and 164 gave both, so many recipients are clustered within donors and their survival times are likely to be correlated; there are 71 failures. The example fits Weibull models with and without a shared frailty effect for the donor (Example 10.4).
See kidney_centres for transplant survival in eight centres, a centre-level analogue of the same problem.
The data set is available under the alias d10.4; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 10.4 (Table 10.5). Data from the UK Transplant Registry.
# Collett (2023), Chapter 17 style ----------------------------------- # Example 10.4: shared gamma frailty for kidneys from the same donor survival::coxph( survival::Surv(time, status) ~ age + cit + diabetes + frailty(donor, distribution = "gamma"), data = kidney ) # Modern tools -------------------------------------------------------- if (requireNamespace("coxme", quietly = TRUE)) { coxme::coxme( survival::Surv(time, status) ~ age + cit + diabetes + (1 | donor), data = kidney ) }# Collett (2023), Chapter 17 style ----------------------------------- # Example 10.4: shared gamma frailty for kidneys from the same donor survival::coxph( survival::Surv(time, status) ~ age + cit + diabetes + frailty(donor, distribution = "gamma"), data = kidney ) # Modern tools -------------------------------------------------------- if (requireNamespace("coxme", quietly = TRUE)) { coxme::coxme( survival::Surv(time, status) ~ age + cit + diabetes + (1 | donor), data = kidney ) }
Transplant survival times of 1439 kidney recipients in eight UK transplant centres (Collett, 2023, Example 11.4).
kidney_centreskidney_centres
A data frame with 1439 rows and 9 variables:
Patient identifier.
Transplant centre (1-8).
Transplant survival time in days.
Event indicator: 1 = transplant failure, 0 = right-censored.
Age of the donor in years.
Donor type: 0 = donation after brain death (DBD), 1 = donation after circulatory death (DCD).
Age of the recipient in years.
Diabetic status of the recipient: 0 = absent, 1 = present.
Cold ischaemic time, in hours.
The data cover transplants with organs from deceased donors performed
between January 2009 and December 2011. Transplant survival is the earlier
of graft failure and patient death, and there are 206 failures. One
recipient (patient 7) had a kidney that never functioned, so tsurv is 0.
The data are used to compare centre-specific one-year failure rates, both unadjusted and risk-adjusted through a Cox model, and to estimate centre-specific rates with fixed and random effects (Examples 11.4-11.8).
The data set is available under the aliases d11.4, d11.5, d11.6,
d11.7, d11.8; dX.Y is the alias for the data set used in Example X.Y
of Collett (2023). See dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 11.4 (Table 11.4). Data from the UK Transplant Registry.
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 11.4-11.8: comparison of transplant centres survival::coxph( survival::Surv(tsurv, tcens) ~ strata(centre) + dage + dtype + rage + diab + cit, data = kidney_centres ) # A random (frailty) effect for centre instead of stratification survival::coxph( survival::Surv(tsurv, tcens) ~ dage + dtype + rage + diab + cit + frailty(centre, distribution = "gamma"), data = kidney_centres ) # Modern tools -------------------------------------------------------- if (requireNamespace("coxme", quietly = TRUE)) { coxme::coxme( survival::Surv(tsurv, tcens) ~ dage + dtype + rage + diab + cit + (1 | centre), data = kidney_centres ) }# Collett (2023), Chapter 17 style ----------------------------------- # Examples 11.4-11.8: comparison of transplant centres survival::coxph( survival::Surv(tsurv, tcens) ~ strata(centre) + dage + dtype + rage + diab + cit, data = kidney_centres ) # A random (frailty) effect for centre instead of stratification survival::coxph( survival::Surv(tsurv, tcens) ~ dage + dtype + rage + diab + cit + frailty(centre, distribution = "gamma"), data = kidney_centres ) # Modern tools -------------------------------------------------------- if (requireNamespace("coxme", quietly = TRUE)) { coxme::coxme( survival::Surv(tsurv, tcens) ~ dage + dtype + rage + diab + cit + (1 | centre), data = kidney_centres ) }
Graft survival times of 1761 adult liver transplant recipients, with the cause of graft failure (Collett, 2023, Example 12.1).
liverliver
A data frame with 1761 rows and 7 variables:
Patient number (1-1761).
Age of the patient in years.
Gender: 1 = male, 2 = female.
Primary liver disease: 1 = primary biliary cirrhosis (PBC), 2 = primary sclerosing cholangitis (PSC), 3 = alcoholic liver disease (ALD).
Time from transplantation to graft failure, death or last follow-up, in days.
Event indicator: 1 = graft failure or death, 0 = right-censored.
Cause of graft failure: 0 = functioning graft (censored), 1 = rejection, 2 = thrombosis, 3 = recurrent disease, 4 = other.
The patients had a first elective transplant with an organ from a deceased
donor between January 2000 and December 2010 and were followed up to the end
of 2012. In the book there are 261 graft failures among the 1761 patients,
and an additional 211 patients die with a functioning graft; the failure
times of the latter group are censored at death. In the distributed file
status is 1 for 265 patients while cof is non-zero for 260, so the two
indicators are not perfectly consistent.
The data are the main illustration of competing risks: the cumulative incidence of each cause of graft failure, cause-specific hazard models and the subdistribution approach (Examples 12.1-12.6). See liver_wait for the waiting-list data from the same registry.
The data set is available under the aliases d12.1, d12.2, d12.3,
d12.4, d12.5, d12.6; dX.Y is the alias for the data set used in
Example X.Y of Collett (2023). See dataset_by_exercise for the complete
index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 12.1 (Table 12.1). Data from the UK Transplant Registry.
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 12.1-12.6: cumulative incidence by cause of graft failure # (cof: 1 = rejection, 2 = thrombosis, 3 = recurrent disease, 4 = other) ci <- cmprsk::cuminc(liver$time, liver$cof, liver$disease) plot(ci, curvlab = c("PBC", "PSC", "ALD"), xlab = "Time (days)") # A Fine-Gray model for one cause of failure (cause 2, thrombosis) cmprsk::crr( liver$time, liver$cof, cov1 = as.matrix(liver[c("age", "gender")]), failcode = 2 ) # Modern tools -------------------------------------------------------- if (requireNamespace("tidycmprsk", quietly = TRUE)) { tidycmprsk::cuminc(survival::Surv(time, factor(cof)) ~ disease, data = liver) tidycmprsk::crr( survival::Surv(time, factor(cof)) ~ age + gender, data = liver, failcode = "2" ) }# Collett (2023), Chapter 17 style ----------------------------------- # Examples 12.1-12.6: cumulative incidence by cause of graft failure # (cof: 1 = rejection, 2 = thrombosis, 3 = recurrent disease, 4 = other) ci <- cmprsk::cuminc(liver$time, liver$cof, liver$disease) plot(ci, curvlab = c("PBC", "PSC", "ALD"), xlab = "Time (days)") # A Fine-Gray model for one cause of failure (cause 2, thrombosis) cmprsk::crr( liver$time, liver$cof, cov1 = as.matrix(liver[c("age", "gender")]), failcode = 2 ) # Modern tools -------------------------------------------------------- if (requireNamespace("tidycmprsk", quietly = TRUE)) { tidycmprsk::cuminc(survival::Surv(time, factor(cof)) ~ disease, data = liver) tidycmprsk::crr( survival::Surv(time, factor(cof)) ~ age + gender, data = liver, failcode = "2" ) }
Time from registration to death on the waiting list for 281 adults with primary biliary cirrhosis (Collett, 2023, Example 14.1).
liver_waitliver_wait
A data frame with 281 rows and 7 variables:
Patient identifier.
Time from registration to death on the waiting list, in days.
Event indicator: 1 = died while waiting, 0 = censored (usually at transplantation).
Age of the patient in years.
Gender: 0 = female, 1 = male.
Body mass index, in kg/m squared.
UK end-stage liver disease score; higher values indicate more severe disease.
The patients were first registered for a liver transplant in the five years from 1 January 2006, and there are 64 deaths. The time of a patient who receives a transplant is censored at transplantation. Livers are allocated on the basis of need, so the time to transplantation (censoring) is associated with the time to death; the data are used to illustrate sensitivity analysis for dependent censoring and inverse probability of censoring weighting (Examples 14.1 and 14.3). The rows are ordered by survival time.
See liver for the post-transplant graft survival data from the same registry.
The data set is available under the aliases d14.1, d14.3; dX.Y is the
alias for the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 14.1 (Table 14.1). Data from the UK Transplant Registry.
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 14.1 and 14.3: dependent censoring (transplant) modelled with # inverse probability of censoring weights liver_wait$cens <- 1 - liver_wait$status cens_fit <- survival::survreg( survival::Surv(time, cens) ~ age + gender + bmi + ukeld, data = liver_wait ) lp <- cens_fit$linear.predictors sigma <- cens_fit$scale # Probability of still being uncensored at each observed time survival_uncensored <- exp(-exp((log(liver_wait$time) - lp) / sigma)) weights <- 1 / survival_uncensored summary(weights) survival::coxph( survival::Surv(time, status) ~ age + gender + bmi + ukeld, data = liver_wait, weights = weights )# Collett (2023), Chapter 17 style ----------------------------------- # Examples 14.1 and 14.3: dependent censoring (transplant) modelled with # inverse probability of censoring weights liver_wait$cens <- 1 - liver_wait$status cens_fit <- survival::survreg( survival::Surv(time, cens) ~ age + gender + bmi + ukeld, data = liver_wait ) lp <- cens_fit$linear.predictors sigma <- cens_fit$scale # Probability of still being uncensored at each observed time survival_uncensored <- exp(-exp((log(liver_wait$time) - lp) / sigma)) weights <- 1 / survival_uncensored summary(weights) survival::coxph( survival::Surv(time, status) ~ age + gender + bmi + ukeld, data = liver_wait, weights = weights )
Survival times from registration for a lung transplant for 196 UK patients (Collett, 2023, Example 10.3).
lung_transplantlung_transplant
A data frame with 196 rows and 7 variables:
Patient identifier.
Survival time in days from registration for a transplant.
Event indicator: 1 = death, 0 = right-censored.
Age at registration in years.
Gender: 1 = male, 2 = female.
Body mass index at registration.
Primary disease: 1 = COPD, 2 = fibrosis, 3 = suppurative disease, 4 = other.
The patients were registered in 2004 and survival is measured from registration to death regardless of any intervening transplantation; 123 of the 196 patients died. Times are censored at removal from the list, at the last known follow-up date, or at 30 April 2012 for patients still alive. The disease codings above follow the values in the distributed file (they can be checked against Table 10.2 of the book).
The example compares a Weibull model with and without an individual lognormal frailty term (Example 10.3). See kidney for a shared frailty example and liver_wait for a similar waiting-list cohort.
The data set is available under the alias d10.3; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 10.3 (Table 10.2). Data from the UK Transplant Registry.
# Collett (2023), Chapter 17 style ----------------------------------- # Example 10.3: an individual gamma frailty for each patient survival::coxph( survival::Surv(time, status) ~ age + bmi + factor(gender) + factor(disease) + frailty(patient, distribution = "gamma"), data = lung_transplant ) # Modern tools -------------------------------------------------------- if (requireNamespace("coxme", quietly = TRUE)) { coxme::coxme( survival::Surv(time, status) ~ age + bmi + factor(gender) + factor(disease) + (1 | patient), data = lung_transplant ) }# Collett (2023), Chapter 17 style ----------------------------------- # Example 10.3: an individual gamma frailty for each patient survival::coxph( survival::Surv(time, status) ~ age + bmi + factor(gender) + factor(disease) + frailty(patient, distribution = "gamma"), data = lung_transplant ) # Modern tools -------------------------------------------------------- if (requireNamespace("coxme", quietly = TRUE)) { coxme::coxme( survival::Surv(time, status) ~ age + bmi + factor(gender) + factor(disease) + (1 | patient), data = lung_transplant ) }
Survival times, in months, of 30 patients with melanoma, from two immunotherapy treatment groups and stratified by age group (Collett, 2023, Example 2.15).
melanomamelanoma
A data frame with 30 rows and 4 variables:
Age group: 1 = 21-40 years, 2 = 41-60 years, 3 = 61 years and over.
Treatment: 1 = BCG vaccine, 2 = Corynebacterium parvum vaccine.
Survival time in months.
Event indicator: 1 = death, 0 = right-censored.
The tumour was removed surgically before randomisation. The data are used to illustrate the log-rank test for comparing two treatment groups within each age stratum (Examples 2.15 and 2.16) and the log-rank test for trend.
The data set is available under the aliases d2.15, d2.16; dX.Y is the
alias for the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Examples 2.15 and 2.16 (Table 2.9). Data from Lee and Wang (2013).
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 2.15 and 2.16: log-rank test within each age stratum survival::survfit( survival::Surv(time, status) ~ treatment + strata(age), data = melanoma ) survival::survdiff( survival::Surv(time, status) ~ treatment + strata(age), data = melanoma ) # Modern tools -------------------------------------------------------- if (requireNamespace("ggsurvfit", quietly = TRUE)) { ggsurvfit::survfit2( survival::Surv(time, status) ~ treatment + strata(age), data = melanoma ) |> ggsurvfit::ggsurvfit() }# Collett (2023), Chapter 17 style ----------------------------------- # Examples 2.15 and 2.16: log-rank test within each age stratum survival::survfit( survival::Surv(time, status) ~ treatment + strata(age), data = melanoma ) survival::survdiff( survival::Surv(time, status) ~ treatment + strata(age), data = melanoma ) # Modern tools -------------------------------------------------------- if (requireNamespace("ggsurvfit", quietly = TRUE)) { ggsurvfit::survfit2( survival::Surv(time, status) ~ treatment + strata(age), data = melanoma ) |> ggsurvfit::ggsurvfit() }
Survival times and causes of death for 181 irradiated mice, reared in a standard or a germ-free environment (Collett, 2023, Example 12.7).
micemice
A data frame with 181 rows and 3 variables:
Rearing environment: 1 = standard, 2 = germ-free.
Cause of death: 1 = thymic lymphoma, 2 = reticulum cell sarcoma, 3 = other causes.
Survival time in days.
The mice were RFM strain males, a strain susceptible to tumour development after exposure to ionising radiation, and were given 300 rads at five or six weeks of age. An autopsy established the cause of death for every mouse. There is no censoring. There are 99 mice in the standard environment (22 deaths from thymic lymphoma, 38 from reticulum cell sarcoma and 39 from other causes) and 82 in the germ-free environment (29, 15 and 38).
The data illustrate estimation of the cumulative incidence function for each cause and cause-specific Cox regression (Example 12.7).
The data set is available under the alias d12.7; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 12.7 (Table 12.7). Data first described by Hoel (1972).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 12.7: three competing causes of death # (1 = thymic lymphoma, 2 = reticulum cell sarcoma, 3 = other causes) ci_mice <- cmprsk::cuminc(mice$time, mice$causeofdeath, mice$environment) plot(ci_mice, curvlab = c("Standard", "Germ-free"), xlab = "Time (days)") # Modern tools -------------------------------------------------------- if (requireNamespace("tidycmprsk", quietly = TRUE)) { tidycmprsk::cuminc( survival::Surv(time, factor(causeofdeath)) ~ environment, data = mice ) }# Collett (2023), Chapter 17 style ----------------------------------- # Example 12.7: three competing causes of death # (1 = thymic lymphoma, 2 = reticulum cell sarcoma, 3 = other causes) ci_mice <- cmprsk::cuminc(mice$time, mice$causeofdeath, mice$environment) plot(ci_mice, curvlab = c("Standard", "Germ-free"), xlab = "Time (days)") # Modern tools -------------------------------------------------------- if (requireNamespace("tidycmprsk", quietly = TRUE)) { tidycmprsk::cuminc( survival::Surv(time, factor(causeofdeath)) ~ environment, data = mice ) }
Survival times, in months, from diagnosis until death for 48 patients with multiple myeloma, together with seven prognostic variables (Collett, 2023, Example 1.3).
myelomamyeloma
A data frame with 48 rows and 10 variables:
Patient number (1-48).
Survival time in months from diagnosis.
Event indicator: 1 = death from multiple myeloma, 0 = right-censored.
Age at diagnosis in years (50-80).
Sex: 1 = male, 2 = female.
Blood urea nitrogen level.
Serum calcium level.
Haemoglobin level.
Percentage of plasma cells in the bone marrow.
Bence-Jones protein in the urine: 0 = absent, 1 = present.
There are 36 deaths among the 48 patients. The time origin is the date of diagnosis and the endpoint is death from multiple myeloma; patients alive at the end of the study contribute censored times.
The data are used throughout the book: life-table estimation (Examples 2.2 and 2.6), Cox regression with several covariates, variable selection and interaction (Examples 3.2-3.20), model checking and influence diagnostics (Examples 4.5, 4.8 and 4.9) and a Weibull model for a prognostic index (Example 5.16).
The data set is available under the aliases d1.3, d2.2, d2.6, d3.2,
d3.5, d3.7, d3.8, d3.9, d3.15, d3.17, d3.19, d3.20, d4.5,
d4.8, d4.9, d5.16; dX.Y is the alias for the data set used in
Example X.Y of Collett (2023). See dataset_by_exercise for the complete
index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 1.3 (Table 1.3). Original data from Krall, Uthoff and Harley (1975); the study was carried out at the Medical Center of the University of West Virginia, USA.
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 2.2 and 2.6: the survivor function for a single sample survival::survfit(survival::Surv(time, status) ~ 1, data = myeloma) # Examples 3.2, 3.5, 3.8, 3.9, 3.15, 3.17, 3.19 and 3.20: Cox model fit_myeloma <- survival::coxph( survival::Surv(time, status) ~ age + sex + bun + ca + hb + pcells + protein, data = myeloma ) summary(fit_myeloma) # Example 3.7: lasso variable selection (the book uses the penalized package) # The fitting routine prints its progress; it is captured here so that the # selected coefficients are easy to read. progress <- utils::capture.output( lass <- penalized::penalized( survival::Surv(myeloma$time, myeloma$status), penalized = ~ age + sex + bun + ca + hb + pcells + protein, lambda1 = 30, data = myeloma ) ) round(lass@penalized, 3) # Examples 4.5, 4.8 and 4.9: residuals and the proportional hazards assumption head(stats::residuals(fit_myeloma, type = "martingale")) survival::cox.zph(fit_myeloma) # Example 5.16: Weibull model with a prognostic index survival::survreg( survival::Surv(time, status) ~ age + bun + hb, data = myeloma, dist = "weibull" ) # Modern tools -------------------------------------------------------- if (requireNamespace("broom", quietly = TRUE)) { broom::tidy(fit_myeloma, exponentiate = TRUE, conf.int = TRUE) } if (requireNamespace("glmnet", quietly = TRUE)) { x <- as.matrix(myeloma[c("age", "sex", "bun", "ca", "hb", "pcells", "protein")]) cv <- glmnet::cv.glmnet(x, survival::Surv(myeloma$time, myeloma$status), family = "cox") stats::coef(cv, s = "lambda.min") } if (requireNamespace("rms", quietly = TRUE)) { rms::cph( survival::Surv(time, status) ~ age + sex + bun + ca + hb + pcells + protein, data = myeloma, x = TRUE, y = TRUE ) }# Collett (2023), Chapter 17 style ----------------------------------- # Examples 2.2 and 2.6: the survivor function for a single sample survival::survfit(survival::Surv(time, status) ~ 1, data = myeloma) # Examples 3.2, 3.5, 3.8, 3.9, 3.15, 3.17, 3.19 and 3.20: Cox model fit_myeloma <- survival::coxph( survival::Surv(time, status) ~ age + sex + bun + ca + hb + pcells + protein, data = myeloma ) summary(fit_myeloma) # Example 3.7: lasso variable selection (the book uses the penalized package) # The fitting routine prints its progress; it is captured here so that the # selected coefficients are easy to read. progress <- utils::capture.output( lass <- penalized::penalized( survival::Surv(myeloma$time, myeloma$status), penalized = ~ age + sex + bun + ca + hb + pcells + protein, lambda1 = 30, data = myeloma ) ) round(lass@penalized, 3) # Examples 4.5, 4.8 and 4.9: residuals and the proportional hazards assumption head(stats::residuals(fit_myeloma, type = "martingale")) survival::cox.zph(fit_myeloma) # Example 5.16: Weibull model with a prognostic index survival::survreg( survival::Surv(time, status) ~ age + bun + hb, data = myeloma, dist = "weibull" ) # Modern tools -------------------------------------------------------- if (requireNamespace("broom", quietly = TRUE)) { broom::tidy(fit_myeloma, exponentiate = TRUE, conf.int = TRUE) } if (requireNamespace("glmnet", quietly = TRUE)) { x <- as.matrix(myeloma[c("age", "sex", "bun", "ca", "hb", "pcells", "protein")]) cv <- glmnet::cv.glmnet(x, survival::Surv(myeloma$time, myeloma$status), family = "cox") stats::coef(cv, s = "lambda.min") } if (requireNamespace("rms", quietly = TRUE)) { rms::cph( survival::Surv(time, status) ~ age + sex + bun + ca + hb + pcells + protein, data = myeloma, x = TRUE, y = TRUE ) }
Artificial survival times of 37 patients classified by the levels of two two-level factors, A and B (Collett, 2023, Example 5.9).
numerical_illustrationnumerical_illustration
A data frame with 37 rows and 4 variables:
Level of factor A: 1 or 2.
Level of factor B: 1 or 2.
Survival time.
Event indicator: 1 = event, 0 = right-censored.
The data are not real. They are constructed so that factor A has a proportional effect while the effect of factor B, and the interaction between A and B, are more complicated, and are used to compare Weibull proportional hazards and accelerated failure time models fitted to the same data (Example 5.9).
The data set is available under the alias d5.9; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 5.9 (Table 5.1).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 5.9: Weibull models for two two-level factors and their interaction survival::survreg( survival::Surv(time, status) ~ factor(a) * factor(b), data = numerical_illustration, dist = "weibull" ) # The proportional hazards form of the same model survival::coxph( survival::Surv(time, status) ~ factor(a) * factor(b), data = numerical_illustration ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(time, status) ~ factor(a) * factor(b), data = numerical_illustration, dist = "weibull" ) }# Collett (2023), Chapter 17 style ----------------------------------- # Example 5.9: Weibull models for two two-level factors and their interaction survival::survreg( survival::Surv(time, status) ~ factor(a) * factor(b), data = numerical_illustration, dist = "weibull" ) # The proportional hazards form of the same model survival::coxph( survival::Surv(time, status) ~ factor(a) * factor(b), data = numerical_illustration ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(time, status) ~ factor(a) * factor(b), data = numerical_illustration, dist = "weibull" ) }
Survival times, in days, of 26 women with ovarian cancer randomised to one of two chemotherapy regimens (Collett, 2023, Example 5.11).
ovarianovarian
A data frame with 26 rows and 7 variables:
Patient number (1-26).
Survival time in days from randomisation.
Event indicator: 1 = death, 0 = right-censored.
Treatment: 1 = cyclophosphamide alone (single), 2 = cyclophosphamide combined with adriamycin.
Age of the patient in years.
Extent of residual disease: 1 = incomplete excision, 2 = complete excision.
Performance status: 1 = good, 2 = poor.
All women had minimal residual disease after surgical excision of tumours
larger than 2 cm. There are 12 deaths among the 26 patients. The factors
treat, rdisease and perf each have two levels and are fitted as
indicator variables, so the baseline hazard does not correspond to a
patient with all covariates zero (see Example 5.11).
The data are used for Weibull proportional hazards models and variable selection (Examples 5.11 and 5.12), for model checking of parametric models (Examples 7.1-7.4) and for a time-dependent covariate (Example 8.3).
The data set is available under the aliases d5.11, d5.12, d7.1,
d7.2, d7.3, d7.4, d8.3; dX.Y is the alias for the data set used
in Example X.Y of Collett (2023). See dataset_by_exercise for the
complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 5.11 (Table 5.6). Data from Edmunson et al. (1979) via Therneau (1986).
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 5.11 and 5.12: Weibull proportional hazards model fit_ovarian <- survival::survreg( survival::Surv(time, status) ~ treat + age, data = ovarian, dist = "weibull" ) summary(fit_ovarian) # Examples 7.1-7.4: residual checks for the parametric model head(stats::residuals(fit_ovarian, type = "deviance")) # Example 8.3: a time-dependent effect of treatment survival::coxph( survival::Surv(time, status) ~ treat + tt(treat), data = ovarian, tt = function(x, t, ...) x * log(t) ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(time, status) ~ treat + age, data = ovarian, dist = "weibull" ) }# Collett (2023), Chapter 17 style ----------------------------------- # Examples 5.11 and 5.12: Weibull proportional hazards model fit_ovarian <- survival::survreg( survival::Surv(time, status) ~ treat + age, data = ovarian, dist = "weibull" ) summary(fit_ovarian) # Examples 7.1-7.4: residual checks for the parametric model head(stats::residuals(fit_ovarian, type = "deviance")) # Example 8.3: a time-dependent effect of treatment survival::coxph( survival::Surv(time, status) ~ treat + tt(treat), data = ovarian, tt = function(x, t, ...) x * log(t) ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(time, status) ~ treat + age, data = ovarian, dist = "weibull" ) }
Survival times, in months, of 38 men with Stage III prostatic cancer, randomised to placebo or to diethylstilbestrol (DES) (Collett, 2023, Example 1.4).
prostateprostate
A data frame with 38 rows and 8 variables:
Patient number (1-38).
Treatment group: 1 = placebo, 2 = diethylstilbestrol (DES).
Survival time in months from randomisation.
Event indicator: 1 = death from prostatic cancer, 0 = right-censored.
Age at trial entry, in years.
Serum haemoglobin level, in g/100 ml.
Size of the primary tumour, in cm squared.
Combined index of tumour stage and grade (the Gleason index); higher values indicate a more advanced tumour.
The trial was run by the Veteran's Administration Cooperative Urological Research Group and only patients with a local tumour extension but without elevated serum prostatic acid phosphatase are included. Deaths from other causes and losses to follow-up are censored. There are only 6 deaths in this subset of 38 patients.
With so few events the example is used to show the behaviour of the partial likelihood and of the estimated hazard ratios (Examples 3.6, 3.12, 3.16 and 5.15), and the fitted Cox model is re-used for an accelerated failure time comparison (Example 5.15).
The data set is available under the aliases d1.4, d3.6, d3.12,
d3.16, d5.15; dX.Y is the alias for the data set used in Example X.Y
of Collett (2023). See dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 1.4 (Table 1.4). The full trial is given in Andrews and Herzberg (1985).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 1.4: the trial data survival::survfit(survival::Surv(time, status) ~ treatment, data = prostate) # Examples 3.6, 3.12 and 3.16: Cox model for treatment and prognostic variables fit_prostate <- survival::coxph( survival::Surv(time, status) ~ treatment + age + shb + size + index, data = prostate ) summary(fit_prostate) # Example 5.15: the corresponding Weibull accelerated failure time model survival::survreg( survival::Surv(time, status) ~ treatment + age + shb + size + index, data = prostate, dist = "weibull" ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(time, status) ~ treatment + age + shb + size + index, data = prostate, dist = "weibull" ) }# Collett (2023), Chapter 17 style ----------------------------------- # Example 1.4: the trial data survival::survfit(survival::Surv(time, status) ~ treatment, data = prostate) # Examples 3.6, 3.12 and 3.16: Cox model for treatment and prognostic variables fit_prostate <- survival::coxph( survival::Surv(time, status) ~ treatment + age + shb + size + index, data = prostate ) summary(fit_prostate) # Example 5.15: the corresponding Weibull accelerated failure time model survival::survreg( survival::Surv(time, status) ~ treatment + age + shb + size + index, data = prostate, dist = "weibull" ) # Modern tools -------------------------------------------------------- if (requireNamespace("flexsurv", quietly = TRUE)) { flexsurv::flexsurvreg( survival::Surv(time, status) ~ treatment + age + shb + size + index, data = prostate, dist = "weibull" ) }
Survival times, in months, of eleven male patients with pulmonary metastasis arising from osteosarcoma (Collett, 2023, Example 2.1).
pulmonarypulmonary
A data frame with 11 rows and 1 variable:
Survival time in months.
There is no censoring in these data and all survival times are distinct, so the survivor function can be estimated directly from the observed proportions surviving. The estimated values of S(t) at 11, 13, 14, 15 and 17 months are 1.000, 0.909, 0.455, 0.273 and 0.091, and S(t) is zero after 17 months. The example is used in the book to introduce the empirical survivor function before censoring is considered.
The data set is available under the alias d2.1; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 2.1. Data from Burdette and Gehan (1970).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 2.1: no censoring, so Surv() needs only the time survival::survfit(survival::Surv(time) ~ 1, data = pulmonary) # Modern tools -------------------------------------------------------- if (requireNamespace("ggsurvfit", quietly = TRUE)) { ggsurvfit::survfit2(survival::Surv(time) ~ 1, data = pulmonary) |> ggsurvfit::ggsurvfit() }# Collett (2023), Chapter 17 style ----------------------------------- # Example 2.1: no censoring, so Surv() needs only the time survival::survfit(survival::Surv(time) ~ 1, data = pulmonary) # Modern tools -------------------------------------------------------- if (requireNamespace("ggsurvfit", quietly = TRUE)) { ggsurvfit::survfit2(survival::Surv(time) ~ 1, data = pulmonary) |> ggsurvfit::ggsurvfit() }
Times from randomisation to the development of mammary tumours for 48 female rats, treated with a retinoid or a control, in recurrent-event form (Collett, 2023, Example 13.2).
ratsrats
A data frame with 254 rows and 4 variables:
Rat number (1-48).
Treatment: 0 = control, 1 = retinoid prophylaxis.
Time from randomisation to a detected tumour, in days, or to censoring.
Event indicator: 1 = tumour detected, 0 = right-censored.
All rats were injected with a carcinogen and the 48 rats that were tumour
free after 60 days were randomised to retinoid or control. Rats were
examined twice weekly and the observation period ended 122 days after
randomisation. Because several tumours could be found at the same
assessment, tied times have been broken by adding 0.1 and 0.2 days, so
time is not always a whole number. There are 23 treated and 25 control
rats, 212 detected tumours in total, and only two rats never developed a
tumour.
The data are used for multiple-event and event-history models: the Andersen-Gill, PWP and WLW models, with the data expanded into counting process format (Example 13.2; see also cirrhosis_cp for a simpler counting process illustration).
The data set is available under the alias d13.2; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 13.2 (Table 13.2). Data from Gail, Santner and Brown (1980).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 13.2: recurrent tumours; Andersen-Gill model with robust SEs # The start of each interval is the previous tumour time for that rat. rats <- rats[order(rats$rat, rats$time), ] rats$start <- unlist(lapply(split(rats$time, rats$rat), function(t) c(0, t[-length(t)]))) survival::coxph( survival::Surv(start, time, status) ~ treatment + cluster(rat), data = rats ) # Modern tools -------------------------------------------------------- # The Prentice-Williams-Peterson model stratifies by the number of prior events rats$event_number <- unlist(lapply(split(rats$rat, rats$rat), seq_along)) survival::coxph( survival::Surv(start, time, status) ~ treatment + strata(event_number), data = rats )# Collett (2023), Chapter 17 style ----------------------------------- # Example 13.2: recurrent tumours; Andersen-Gill model with robust SEs # The start of each interval is the previous tumour time for that rat. rats <- rats[order(rats$rat, rats$time), ] rats$start <- unlist(lapply(split(rats$time, rats$rat), function(t) c(0, t[-length(t)]))) survival::coxph( survival::Surv(start, time, status) ~ treatment + cluster(rat), data = rats ) # Modern tools -------------------------------------------------------- # The Prentice-Williams-Peterson model stratifies by the number of prior events rats$event_number <- unlist(lapply(split(rats$rat, rats$rat), seq_along)) survival::coxph( survival::Surv(start, time, status) ~ treatment + strata(event_number), data = rats )
A cohort of 850 patients diagnosed with metastatic breast cancer, used in the computer exercise on survival analysis. The data are not from Collett (2023); they come from the teaching material of the Edinburgh Cancer Informatics group, which is redistributed here (see Source).
scottish_mbc_cohortscottish_mbc_cohort
A data frame with 850 rows and 21 variables:
Patient identifier, MBC0001 to MBC0850.
NHS Health Board of the treating centre, one of the 14 Scottish boards.
Age at diagnosis of metastatic disease, in years.
Sex of the patient.
Scottish Index of Multiple Deprivation quintile, 1 (most deprived) to 5 (least deprived).
ECOG performance status at baseline: 0 (best) to 3 (worst).
Oestrogen receptor status: Positive or Negative.
Progesterone receptor status: Positive or Negative.
HER2 status: Positive or Negative.
Number of metastatic sites at diagnosis.
Metastatic involvement
of bone, liver, lung and brain: Yes or No.
De novo metastatic or Recurrent disease.
Date of diagnosis of metastatic disease.
First-line treatment.
Follow-up time in months from diagnosis to death or censoring.
Event indicator: 1 = death, 0 = right-censored.
Age group at diagnosis: <50, 50-64, 65-74 or 75+.
Hormone receptor status: HR-positive or
HR-negative, derived from er_status and pr_status.
The time origin is the date of diagnosis of metastatic breast cancer and the time scale is time since diagnosis, in months. The event of interest is death from any cause; patients who were alive at the end of follow-up are right-censored. Of the 850 patients, 703 died and 147 (17.3 %) were censored, and the observed follow-up times range from 0.5 to 71.2 months. The patients were diagnosed between 5 January 2018 and 28 December 2022.
The cohort is entirely synthetic. It was generated for teaching purposes and contains no real patient data, but it was designed to reproduce realistic patterns of metastatic breast cancer in Scotland. The code that generated it, together with a longer walk-through of the same cohort, is part of the tutorial by the Edinburgh Cancer Informatics group that is cited under Source.
Compared with the data sets from Collett (2023), two columns are stored in a
slightly different form: status is an integer and diagnosis_date a Date,
so that the object matches the other data sets in the package. Otherwise the
file is used as distributed.
This course data set is not used in a numbered example, so it has no dX.Y
alias. See dataset_by_exercise for the complete index.
The file scottish_mbc_cohort.xlsx in the onco-stats repository of
the Edinburgh Cancer Informatics group,
https://github.com/Edinburgh-Cancer-Informatics/onco-stats/tree/main/docs/data,
redistributed under the MIT licence of that repository (Copyright (c) 2025
Edinburgh-Cancer-Informatics). See also Survival Analysis in R: A
Practical Tutorial,
https://edinburgh-cancer-informatics.github.io/onco-stats/tutorials/survival_analysis_tutorial.html,
which documents the same cohort and the simulation that generated it.
# Not from Collett (2023) --------------------------------------------- # The synthetic Scottish metastatic breast cancer cohort used in the # first computer exercise; see the vignette cs1-survival-data. survival::survfit( survival::Surv(observed_time, status) ~ hormone_receptor, data = scottish_mbc_cohort ) # Modern tools -------------------------------------------------------- if (requireNamespace("ggsurvfit", quietly = TRUE)) { ggsurvfit::survfit2( survival::Surv(observed_time, status) ~ hormone_receptor, data = scottish_mbc_cohort ) |> ggsurvfit::ggsurvfit() |> ggsurvfit::add_risktable() } if (requireNamespace("broom", quietly = TRUE)) { broom::tidy( survival::coxph( survival::Surv(observed_time, status) ~ age_at_diagnosis + factor(hormone_receptor) + factor(ecog_ps), data = scottish_mbc_cohort ), exponentiate = TRUE, conf.int = TRUE ) }# Not from Collett (2023) --------------------------------------------- # The synthetic Scottish metastatic breast cancer cohort used in the # first computer exercise; see the vignette cs1-survival-data. survival::survfit( survival::Surv(observed_time, status) ~ hormone_receptor, data = scottish_mbc_cohort ) # Modern tools -------------------------------------------------------- if (requireNamespace("ggsurvfit", quietly = TRUE)) { ggsurvfit::survfit2( survival::Surv(observed_time, status) ~ hormone_receptor, data = scottish_mbc_cohort ) |> ggsurvfit::ggsurvfit() |> ggsurvfit::add_risktable() } if (requireNamespace("broom", quietly = TRUE)) { broom::tidy( survival::coxph( survival::Surv(observed_time, status) ~ age_at_diagnosis + factor(hormone_receptor) + factor(ecog_ps), data = scottish_mbc_cohort ), exponentiate = TRUE, conf.int = TRUE ) }
Time-to-event data for five different endpoints in 641 women from a randomised trial of tamoxifen alone versus tamoxifen plus radiotherapy (Collett, 2023, Example 13.3).
tamoxifentamoxifen
A data frame with 641 rows and 18 variables:
Patient identifier.
Treatment: 0 = tamoxifen plus radiotherapy, 1 = tamoxifen alone.
Age of the patient in years.
Tumour size in cm.
Tumour histology: 1 = ductal, 2 = lobular, 3 = medullary, 4 = mixed, 5 = other.
Hormone receptor level: 0 = negative, 1 = positive.
Haemoglobin level in g/l.
Axillary node dissection: 0 = no, 1 = yes.
Time to local relapse or last follow-up.
Local relapse: 0 = no, 1 = yes.
Time to axillary relapse or last follow-up.
Axillary relapse: 0 = no, 1 = yes.
Time to distant relapse or last follow-up.
Distant relapse: 0 = no, 1 = yes.
Time to second malignancy or last follow-up.
Second malignancy: 0 = no, 1 = yes.
Time from randomisation to death or last follow-up.
Status at last follow-up: 0 = alive, 1 = dead.
The women were randomised to tamoxifen alone or with radiotherapy; 320 received tamoxifen plus radiotherapy and 321 tamoxifen alone. Each of the five endpoints has its own time and indicator, and the times are censored at the last date the woman was known to be alive. For women who relapsed after the start of follow-up the relevant indicator switches from 0 to 1.
The example was used by Pintilie (2006) to illustrate the WLW model for multiple events. Because a woman can experience more than one of the five event types, the data are rearranged into one row per possible event per woman before fitting the model (Example 13.3).
The data set is available under the alias d13.3; dX.Y is the alias for
the data set used in Example X.Y of Collett (2023). See
dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 13.3 (Table 13.5). Data from Fyles et al. (2004) and Pintilie (2006).
# Collett (2023), Chapter 17 style ----------------------------------- # Example 13.3: four event types, each analysed as a cause-specific hazard # local relapse survival::coxph(survival::Surv(lsurv, ls) ~ treat + age + size + hr, data = tamoxifen) # axillary relapse survival::coxph(survival::Surv(asurv, as) ~ treat + age + size + hr, data = tamoxifen) # distant relapse survival::coxph(survival::Surv(dsurv, ds) ~ treat + age + size + hr, data = tamoxifen) # second malignancy survival::coxph(survival::Surv(msurv, ms) ~ treat + age + size + hr, data = tamoxifen) # Modern tools -------------------------------------------------------- # A competing-risk view of the first event of any of the four types if (requireNamespace("tidycmprsk", quietly = TRUE)) { first <- data.frame( time = pmin(tamoxifen$lsurv, tamoxifen$asurv, tamoxifen$dsurv, tamoxifen$msurv), treat = tamoxifen$treat ) first$cause <- factor( c("local", "axillary", "distant", "second")[ apply(cbind(tamoxifen$lsurv, tamoxifen$asurv, tamoxifen$dsurv, tamoxifen$msurv), 1, which.min) ] ) tidycmprsk::cuminc(survival::Surv(time, cause) ~ treat, data = first) }# Collett (2023), Chapter 17 style ----------------------------------- # Example 13.3: four event types, each analysed as a cause-specific hazard # local relapse survival::coxph(survival::Surv(lsurv, ls) ~ treat + age + size + hr, data = tamoxifen) # axillary relapse survival::coxph(survival::Surv(asurv, as) ~ treat + age + size + hr, data = tamoxifen) # distant relapse survival::coxph(survival::Surv(dsurv, ds) ~ treat + age + size + hr, data = tamoxifen) # second malignancy survival::coxph(survival::Surv(msurv, ms) ~ treat + age + size + hr, data = tamoxifen) # Modern tools -------------------------------------------------------- # A competing-risk view of the first event of any of the four types if (requireNamespace("tidycmprsk", quietly = TRUE)) { first <- data.frame( time = pmin(tamoxifen$lsurv, tamoxifen$asurv, tamoxifen$dsurv, tamoxifen$msurv), treat = tamoxifen$treat ) first$cause <- factor( c("local", "axillary", "distant", "second")[ apply(cbind(tamoxifen$lsurv, tamoxifen$asurv, tamoxifen$dsurv, tamoxifen$msurv), 1, which.min) ] ) tidycmprsk::cuminc(survival::Surv(time, cause) ~ treat, data = first) }
Interval-censored times to recurrence of an ulcer among 43 patients in a double-blind clinical trial of two treatments (Collett, 2023, Example 9.1).
ulcerulcer
A data frame with 43 rows and 6 variables:
Patient number (1-43).
Age of the patient in years.
Duration of verified disease: 1 = less than five years, 2 = five years or more.
Treatment group: 1 = A, 2 = B.
Time of the last visit, in months.
Result of the endoscopy at the last visit: 1 = no ulcer detected, 2 = ulcer detected.
Endoscopies were scheduled 6 and 12 months after randomisation, and patients
who presented with symptoms between visits had an unscheduled endoscopy.
The pair (time, result) is converted to an interval-censored recurrence
time: for example, a visit at 7 months with result 2 means recurrence in
the interval (6, 7], while result 1 at 12 months means the recurrence time
is right-censored at 12 months. Because 6 months is the earliest possible
interval limit, the combination (time = 6, result = 2) becomes (0, 6].
There are 11 detected recurrences.
The data are used for interval-censored analyses (Examples 9.1-9.7) and for the restricted mean survival time computed from interval-censored data (Example 11.1). The full multinational study is described by Whitehead (1989); the data here are the Belgian subset.
The data set is available under the aliases d9.1, d9.4, d9.5, d9.6,
d9.7, d11.1; dX.Y is the alias for the data set used in Example X.Y
of Collett (2023). See dataset_by_exercise for the complete index.
Collett, D. (2023) Modelling Survival Data in Medical Research, 4th ed. Chapman & Hall/CRC, Example 9.1 (Tables 9.1 and 9.2). Data from Whitehead (1989).
# Collett (2023), Chapter 17 style ----------------------------------- # Examples 9.1 and 9.4: interval-censored recurrence times # (Table 9.2 of the book gives the interval for each visit and result) ulcer$left <- ifelse(ulcer$result == 2, ifelse(ulcer$time <= 6, 0, 6), ulcer$time) ulcer$right <- ifelse(ulcer$result == 2, ulcer$time, Inf) survival::Surv(ulcer$left, ulcer$right, type = "interval2")[1:5] # Chapter 17 fits the Turnbull estimate with icfit() in the interval package; # icenReg provides the same estimator. icenReg::ic_np(cbind(ulcer$left, ulcer$right)) # Examples 9.5-9.7: a proportional hazards model for interval-censored data icenReg::ic_sp( survival::Surv(left, right, type = "interval2") ~ treatment, data = ulcer ) # Modern tools -------------------------------------------------------- if (requireNamespace("icenReg", quietly = TRUE)) { plot(icenReg::ic_np(cbind(ulcer$left, ulcer$right))) }# Collett (2023), Chapter 17 style ----------------------------------- # Examples 9.1 and 9.4: interval-censored recurrence times # (Table 9.2 of the book gives the interval for each visit and result) ulcer$left <- ifelse(ulcer$result == 2, ifelse(ulcer$time <= 6, 0, 6), ulcer$time) ulcer$right <- ifelse(ulcer$result == 2, ulcer$time, Inf) survival::Surv(ulcer$left, ulcer$right, type = "interval2")[1:5] # Chapter 17 fits the Turnbull estimate with icfit() in the interval package; # icenReg provides the same estimator. icenReg::ic_np(cbind(ulcer$left, ulcer$right)) # Examples 9.5-9.7: a proportional hazards model for interval-censored data icenReg::ic_sp( survival::Surv(left, right, type = "interval2") ~ treatment, data = ulcer ) # Modern tools -------------------------------------------------------- if (requireNamespace("icenReg", quietly = TRUE)) { plot(icenReg::ic_np(cbind(ulcer$left, ulcer$right))) }