R packages

In this practical, a number of R packages are used. If any of them are not installed you may be able to follow the practical but will not be able to run all of the code. The packages used (with versions that were used to generate the solutions) are:

  • R version 3.6.0 (2019-04-26)
  • mice (version: 3.4.0)
  • survival (version: 2.43.3; note: in versions 2.44-1 and 2.44-1.1 confint() returns NA)
  • JointAI (version: 0.5.1)
  • ggplot2 (version: 3.1.1)

Help files

You can find help files for any function by adding a ? before the name of the function.

Alternatively, you can look up the help pages online at or find the whole manual for a package at


Data & Model of interest

In this practical we will work with a different subset of the PBC data, omitting the longitudinal structure and focusing on the survival component.

To get the pbcdat data, load the file pbcdat.RData. You can download it here. To load this dataset, you can use the command file.choose() which opens the explorer and allows you to navigate to the location of the downloaded file on your computer. If you know the path to the file, you can also use load("<path>/<pbcdat.RData").

The variables contained in this subset (pbcdat) are:
time number of years between inclusion and death, transplantion, or end of follow-up
status status at time (censored, transplant, dead)
age patient’s age at intake
sex patient’s sex
platelet platelet count
chol serum cholesterol
stage histologic stage of disease

The variables in pbcdat dataset have the following distributions: