"Bayesian Cognitive Modeling" in cmdstanr

I’m teaching myself how to better Stan by recoding “Bayesian Cognitive Modeling” by Lee and Wagenmakers in Stan + cmdstanr. I am aware of the stan/rstan recoding by Martin Smira (example-models/Bayesian_Cognitive_Modeling at master · stan-dev/example-models · GitHub), which I use as a reference when I get stuck, but I was wondering whether it’d be useful to contribute the R code to fit and analyze the models relying on cmdstanr (it being compatible with the stan code produced by Smira).
If anybody is interested I’ll set up a github repository.

6 Likes

Yes, it would be useful! And also very useful to get updated Stan code (the code in example-models is using many deprecated language features).

2 Likes

Ok, I set up the repository. It should all work and be up to date for the estimation of the binomial rate (models 1-5). I’ll be updating it as I proceed.

Is there any specific concerns as related to code style that I should be aware of in order to later on add this to the examples on the stan repository? (e.g. I do use ggplot for plots instead of the base plots in the previous recoding of cognitive modeling)

3 Likes

And consider adding the models/data you generate to posteriordb so that future MCMC algos can be tested against them!

1 Like

it’s a new thing to me, but I’ll def look into that!

1 Like

For the purpose of providing stan examples, I’ve found some issues on one example (the 7 scientists), kudos to @mike-lawrence for help in identifying the issues (Divergences when adding prior sampling).
The model is probably unidentifiable (7 data points, 7 variances to estimate). However, the early smira script (https://github.com/stan-dev/example-models/blob/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Gaussian/SevenScientists_Stan.R) runs without any issue. At least as long as I don’t try to sample the priors, then all sort of divergences occur.
For my own learning I can comment on the issues and play with amount of data.
For the Stan example to be added to the repository, perhaps I can augment the data, and comment on the discrepancy with the original model in the book and smira repository. Would that work?

1 Like