sta310r
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")
<style>#datasets-by-example table {
font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
#datasets-by-example thead, #datasets-by-example tbody, #datasets-by-example tfoot, #datasets-by-example tr, #datasets-by-example td, #datasets-by-example th {
border-style: none;
}
#datasets-by-example p {
margin: 0;
padding: 0;
}
#datasets-by-example .gt_table {
display: table;
border-collapse: collapse;
line-height: normal;
margin-left: auto;
margin-right: auto;
color: #333333;
font-size: 16px;
font-weight: normal;
font-style: normal;
background-color: #FFFFFF;
width: auto;
border-top-style: solid;
border-top-width: 2px;
border-top-color: #A8A8A8;
border-right-style: none;
border-right-width: 2px;
border-right-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #A8A8A8;
border-left-style: none;
border-left-width: 2px;
border-left-color: #D3D3D3;
}
#datasets-by-example .gt_caption {
padding-top: 4px;
padding-bottom: 4px;
}
#datasets-by-example .gt_title {
color: #333333;
font-size: 125%;
font-weight: initial;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 5px;
padding-right: 5px;
border-bottom-color: #FFFFFF;
border-bottom-width: 0;
}
#datasets-by-example .gt_subtitle {
color: #333333;
font-size: 85%;
font-weight: initial;
padding-top: 3px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;
border-top-color: #FFFFFF;
border-top-width: 0;
}
#datasets-by-example .gt_heading {
background-color: #FFFFFF;
text-align: center;
border-bottom-color: #FFFFFF;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
}
#datasets-by-example .gt_bottom_border {
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
}
#datasets-by-example .gt_col_headings {
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
}
#datasets-by-example .gt_col_heading {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: normal;
text-transform: inherit;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
vertical-align: bottom;
padding-top: 5px;
padding-bottom: 6px;
padding-left: 5px;
padding-right: 5px;
overflow-x: hidden;
}
#datasets-by-example .gt_column_spanner_outer {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: normal;
text-transform: inherit;
padding-top: 0;
padding-bottom: 0;
padding-left: 4px;
padding-right: 4px;
}
#datasets-by-example .gt_column_spanner_outer:first-child {
padding-left: 0;
}
#datasets-by-example .gt_column_spanner_outer:last-child {
padding-right: 0;
}
#datasets-by-example .gt_column_spanner {
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
vertical-align: bottom;
padding-top: 5px;
padding-bottom: 5px;
overflow-x: hidden;
display: inline-block;
width: 100%;
}
#datasets-by-example .gt_spanner_row {
border-bottom-style: hidden;
}
#datasets-by-example .gt_group_heading {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
text-transform: inherit;
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
vertical-align: middle;
text-align: left;
}
#datasets-by-example .gt_empty_group_heading {
padding: 0.5px;
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
vertical-align: middle;
}
#datasets-by-example .gt_from_md > :first-child {
margin-top: 0;
}
#datasets-by-example .gt_from_md > :last-child {
margin-bottom: 0;
}
#datasets-by-example .gt_row {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
margin: 10px;
border-top-style: solid;
border-top-width: 1px;
border-top-color: #D3D3D3;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
vertical-align: middle;
overflow-x: hidden;
}
#datasets-by-example .gt_stub {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
text-transform: inherit;
border-right-style: solid;
border-right-width: 2px;
border-right-color: #D3D3D3;
padding-left: 5px;
padding-right: 5px;
}
#datasets-by-example .gt_stub_row_group {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
text-transform: inherit;
border-right-style: solid;
border-right-width: 2px;
border-right-color: #D3D3D3;
padding-left: 5px;
padding-right: 5px;
vertical-align: top;
}
#datasets-by-example .gt_row_group_first td {
border-top-width: 2px;
}
#datasets-by-example .gt_row_group_first th {
border-top-width: 2px;
}
#datasets-by-example .gt_summary_row {
color: #333333;
background-color: #FFFFFF;
text-transform: inherit;
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
}
#datasets-by-example .gt_first_summary_row {
border-top-style: solid;
border-top-color: #D3D3D3;
}
#datasets-by-example .gt_first_summary_row.thick {
border-top-width: 2px;
}
#datasets-by-example .gt_last_summary_row {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
}
#datasets-by-example .gt_grand_summary_row {
color: #333333;
background-color: #FFFFFF;
text-transform: inherit;
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
}
#datasets-by-example .gt_first_grand_summary_row {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
border-top-style: double;
border-top-width: 6px;
border-top-color: #D3D3D3;
}
#datasets-by-example .gt_last_grand_summary_row_top {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
border-bottom-style: double;
border-bottom-width: 6px;
border-bottom-color: #D3D3D3;
}
#datasets-by-example .gt_striped {
background-color: rgba(128, 128, 128, 0.05);
}
#datasets-by-example .gt_table_body {
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
}
#datasets-by-example .gt_footnotes {
color: #333333;
background-color: #FFFFFF;
border-bottom-style: none;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 2px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 2px;
border-right-color: #D3D3D3;
}
#datasets-by-example .gt_footnote {
margin: 0px;
font-size: 90%;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 5px;
padding-right: 5px;
}
#datasets-by-example .gt_sourcenotes {
color: #333333;
background-color: #FFFFFF;
border-bottom-style: none;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 2px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 2px;
border-right-color: #D3D3D3;
}
#datasets-by-example .gt_sourcenote {
font-size: 90%;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 5px;
padding-right: 5px;
}
#datasets-by-example .gt_left {
text-align: left;
}
#datasets-by-example .gt_center {
text-align: center;
}
#datasets-by-example .gt_right {
text-align: right;
font-variant-numeric: tabular-nums;
}
#datasets-by-example .gt_font_normal {
font-weight: normal;
}
#datasets-by-example .gt_font_bold {
font-weight: bold;
}
#datasets-by-example .gt_font_italic {
font-style: italic;
}
#datasets-by-example .gt_super {
font-size: 65%;
}
#datasets-by-example .gt_footnote_marks {
font-size: 75%;
vertical-align: 0.4em;
position: initial;
}
#datasets-by-example .gt_asterisk {
font-size: 100%;
vertical-align: 0;
}
#datasets-by-example .gt_indent_1 {
text-indent: 5px;
}
#datasets-by-example .gt_indent_2 {
text-indent: 10px;
}
#datasets-by-example .gt_indent_3 {
text-indent: 15px;
}
#datasets-by-example .gt_indent_4 {
text-indent: 20px;
}
#datasets-by-example .gt_indent_5 {
text-indent: 25px;
}
#datasets-by-example .katex-display {
display: inline-flex !important;
margin-bottom: 0.75em !important;
}
#datasets-by-example div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
height: 0px !important;
}
</style>
| 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 |
| 2. 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 |
| 3. 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 |
| 4. 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 |
| 5. 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 |
| 6. 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 |
| 7. 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 |
| 8. 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 |
| 9. 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 |
| 10. 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 |
| 11. 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 |
| 12. 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 |
| 13. 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 |
| 14. Dependent censoring |
| 14.1 |
d14.1 |
liver_wait |
281 |
7 |
| 14.3 |
d14.3 |
liver_wait |
281 |
7 |
| 15. 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 |
| 16. 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")