Test Stan Function


I have written a mathematical function and tested it in Python. I now want to transcribe to within Stan, but I want to make sure I haven’t messed up any of the changes in indices, and it would be good to test the Stan function anyhow.

What’s the best way to do this? I can write my new function in the functions block, but then what’s the best way to test it with various inputs and check the output?

I am using PyStan.


Import data with data block and use generated_quantities to call it. Use algorithm="Fixed_param" and iter=1.

If you want to test derivatives and such, other users might have some ideas.


In the end I used the transformed data block to output the values I wanted and I piped the output to a file that I then parsed. It’s not ideal, but it gave me some level of comfort that my model was doing the right thing.