Skip to contents

sta310r collects the data sets that accompany Collett (2023), Modelling Survival Data in Medical Research (4th edition), together with the computer exercises used in the STA310 course at the University of Gothenburg. The package focuses on the data sets, their documentation and the exercise vignettes.

Installation

The recommended way is from R-universe, which provides pre-built binaries for Windows, macOS and Linux, so no compiler toolchain is needed:

install.packages(
  "sta310r",
  repos = c(
    "https://eribul.r-universe.dev",
    "https://cloud.r-project.org"
  ),
  dependencies = TRUE
)

You can also install the development version directly from GitHub with pak (this builds from source, so Windows users need Rtools installed):

pak::pak("eribul/sta310r")

Name conflicts

The package includes six data sets with names also used by the survival package, for data sets that are not the same:

  • bladder
  • cgd
  • kidney
  • myeloma
  • ovarian
  • rats

Attach sta310r last (library(sta310r) AFTER library(survival)), or use sta310r::xxx explicitly if both packages are attached. You may also just refer to the datasets by their aliases as described below.

Data sets by example

Each data set that is used in a worked example of Collett (2023) has an alias dX.Y, where X.Y is the number of the example. For example, d3.7 is the myeloma data used in Example 3.7, and d8.4 is the baseline cirrhosis data. The aliases are ordinary data objects: d3.7 works after library(sta310r), and ?d3.7 opens the help page of the data set. See vignette("datasets-by-exercise").

Note that 2 data sets are used in example 8.4 (hence no aliases used there).

library(sta310r)
dataset_by_exercise |>
  dplyr::filter(!is.na(chapter)) |>
  dplyr::mutate(chapter = paste(chapter, chapter_title, sep = ". ")) |>
  dplyr::select(chapter, example, alias, dataset, n_rows, n_variables) |>
  gt::gt(groupname_col = "chapter", id = "datasets-by-example")
example alias dataset n_rows n_variables
  1. Survival analysis
1.1 d1.1 iud 18 2
1.2 d1.2 breast 45 3
1.3 d1.3 myeloma 48 10
1.4 d1.4 prostate 38 8
  1. Some non-parametric procedures
2.1 d2.1 pulmonary 11 1
2.2 d2.2 myeloma 48 10
2.3 d2.3 iud 18 2
2.4 d2.4 iud 18 2
2.5 d2.5 iud 18 2
2.6 d2.6 myeloma 48 10
2.7 d2.7 iud 18 2
2.8 d2.8 iud 18 2
2.9 d2.9 iud 18 2
2.10 d2.10 iud 18 2
2.11 d2.11 breast 45 3
2.12 d2.12 breast 45 3
2.13 d2.13 breast 45 3
2.14 d2.14 breast 45 3
2.15 d2.15 melanoma 30 4
2.16 d2.16 melanoma 30 4
  1. The Cox regression model
3.1 d3.1 breast 45 3
3.2 d3.2 myeloma 48 10
3.3 d3.3 breast 45 3
3.4 d3.4 hyper 36 4
3.5 d3.5 myeloma 48 10
3.6 d3.6 prostate 38 8
3.7 d3.7 myeloma 48 10
3.8 d3.8 myeloma 48 10
3.9 d3.9 myeloma 48 10
3.10 d3.10 hyper 36 4
3.11 d3.11 hyper 36 4
3.12 d3.12 prostate 38 8
3.13 d3.13 hyper 36 4
3.14 d3.14 hyper 36 4
3.15 d3.15 myeloma 48 10
3.16 d3.16 prostate 38 8
3.17 d3.17 myeloma 48 10
3.19 d3.19 myeloma 48 10
3.20 d3.20 myeloma 48 10
  1. Model checking in the Cox regression model
4.1 d4.1 dialysis 13 5
4.2 d4.2 dialysis 13 5
4.3 d4.3 dialysis 13 5
4.4 d4.4 dialysis 13 5
4.5 d4.5 myeloma 48 10
4.6 d4.6 dialysis 13 5
4.7 d4.7 dialysis 13 5
4.8 d4.8 myeloma 48 10
4.9 d4.9 myeloma 48 10
4.10 d4.10 dialysis 13 5
4.11 d4.11 dialysis 13 5
4.12 d4.12 dialysis 13 5
  1. Parametric regression models
5.1 d5.1 iud 18 2
5.2 d5.2 iud 18 2
5.3 d5.3 iud 18 2
5.4 d5.4 iud 18 2
5.5 d5.5 breast 45 3
5.6 d5.6 breast 45 3
5.7 d5.7 breast 45 3
5.8 d5.8 breast 45 3
5.9 d5.9 numerical_illustration 37 4
5.10 d5.10 hyper 36 4
5.11 d5.11 ovarian 26 7
5.12 d5.12 ovarian 26 7
5.13 d5.13 breast 45 3
5.14 d5.14 breast 45 3
5.15 d5.15 prostate 38 8
5.16 d5.16 myeloma 48 10
5.17 d5.17 breast 45 3
  1. Flexible parametric models
6.1 d6.1 hyper 36 4
6.4 d6.4 hyper 36 4
6.5 d6.5 breast_rfs 686 11
6.6 d6.6 breast_rfs 686 11
  1. Model checking in parametric models
7.1 d7.1 ovarian 26 7
7.2 d7.2 ovarian 26 7
7.3 d7.3 ovarian 26 7
7.4 d7.4 ovarian 26 7
  1. Time-dependent variables
8.2 d8.2 bmt_leukaemia 23 8
8.3 d8.3 ovarian 26 7
8.4 d8.4 cirrhosis 12 6
8.4 NA cirrhosis_cp 54 7
8.4 NA cirrhosis_lbr 42 3
8.5 d8.5 aortic 988 11
8.6 d8.6 aortic 988 11
8.7 d8.7 aortic 988 11
8.8 d8.8 aortic 988 11
8.9 d8.9 aortic 988 11
  1. Interval-censored survival data
9.1 d9.1 ulcer 43 6
9.4 d9.4 ulcer 43 6
9.5 d9.5 ulcer 43 6
9.6 d9.6 ulcer 43 6
9.7 d9.7 ulcer 43 6
  1. Frailty models
10.1 d10.1 breast 45 3
10.2 d10.2 breast 45 3
10.3 d10.3 lung_transplant 196 7
10.4 d10.4 kidney 434 7
  1. Non-proportional hazards and institutional comparisons
11.1 d11.1 ulcer 43 6
11.2 d11.2 gastric 90 4
11.3 d11.3 gastric 90 4
11.4 d11.4 kidney_centres 1439 9
11.5 d11.5 kidney_centres 1439 9
11.6 d11.6 kidney_centres 1439 9
11.7 d11.7 kidney_centres 1439 9
11.8 d11.8 kidney_centres 1439 9
  1. Competing risks
12.1 d12.1 liver 1761 7
12.2 d12.2 liver 1761 7
12.3 d12.3 liver 1761 7
12.4 d12.4 liver 1761 7
12.5 d12.5 liver 1761 7
12.6 d12.6 liver 1761 7
12.7 d12.7 mice 181 3
  1. Multiple events and event history modelling
13.2 d13.2 rats 254 4
13.3 d13.3 tamoxifen 641 18
13.4 d13.4 bmt_outcome 2204 9
  1. Dependent censoring
14.1 d14.1 liver_wait 281 7
14.3 d14.3 liver_wait 281 7
  1. Sample size requirements for a survival study
15.1 d15.1 hepatitis 44 3
15.2 d15.2 hepatitis 44 3
15.3 d15.3 hepatitis 44 3
  1. Bayesian survival analysis
16.1 d16.1 iud 18 2
16.2 d16.2 iud 18 2
16.3 d16.3 iud 18 2
16.4 d16.4 breast 45 3
16.5 d16.5 breast 45 3
16.6 d16.6 breast 45 3
16.7 d16.7 help 447 7

Computer exercises

The course exercises are shipped as vignettes. The first exercise covers censoring, the survivor and hazard functions, Kaplan–Meier, Nelson–Aalen and the log-rank family, and ships with a solutions vignette:

vignette("cs1-survival-data")
vignette("cs1-solutions")