Advice on debugging your code

I received the following email:

Hello, Dr. Gelman,

I am working on person-fit index for reading comprehension test using PPMC. I am pretty new for Bayesian, WinBUGS, and PPMC. . . .Could you take a look at my WinBUGS code for me? I calculated likelihood for posterior and predictive posterior and PPP-value . . .

Good question. I don’t have time to look at people’s code but I responded that you can check things by simulating fake data from the model and then checking that the estimated parameters are close to the true values; see Section 8.3 of my recent book with Hill. I’m usually too lazy to do this fake-data checking, but when I get around to it, it often is helpful.

Sam and Don and I wrote a paper with a systematic approach to fake-data checking. Often, though, just simulating one fake dataset and fitting the model is enough to reveal problems.