Chapter 14 R code for data simulation