Debugging in Stan
And building a comprehensive picture of the Stan modeling workflow
Welcome to the ninth and final workshop of the BayesCog course!
Collectively, over this course we have built up our knowledge and ability to formalise and write cognitive models in Stan. We have done so using multiple examples, from basic probability models like the binomial and Bernoulli, to linear regression, and then explored various reinforcement learning models - from simple Rescorla-Wagner models to more complex hierarchical models.
All the while, things have gone relatively smoothly; we have not encountered major problems when writing or running our Stan models. However, it is worth to bear in mind that the materials (including the Stan models) for this course were carefully constructed and checked to work correctly without issue. In this final workshop, we’ll focus on debugging and fixing common errors in Stan code, and discuss best coding practices.
By the end of this workshop, you will be able to:
- Recognise common Stan errors and warnings and explain their causes
- Apply best practices for writing readable, debuggable Stan code
- Debug and fix a faulty memory-retention model
- Build a principled workflow for cognitive modeling
Model code and R scripts for this workshop are located in the (/workshops/09.debugging) directory. Remember to use the R.proj file within each folder to avoid manually setting directories!