R functions and data from Chapter 5 of 'Statistical Methods for