I’ve created a GitHub repository for this book. It’s at

Most of the code and data you need to recreate this book is there. The exception is that the data files that I downloaded from JSTOR are not there. That’s for two reasons. One is that it wasn’t 100% clear that the licence for them would allow redistribution. The other was that they would have been too big to put on GitHub anyway. So to recreate everything I’m doing here, you’ll need to download them directly.

In the notes directory of the GitHub repository there are some R scripts for converting downloaded JSTOR files into things that can be managed in R. A lot of the things I’m doing here are based on code that’s in the code for the book. But it takes about 24-32 hours (on a reasonably fast personal computer) to build the model, so I don’t build it anew each time I compile the book. The next section describes how to build a model like the one I’m using.

If you want to go directly to the code for the chapter you’re in, the eye icon in the top bar will take you there.