Using cmdstanr with R package

I have searched the forum, but have been unable to find documentation to answer/demonstrate my question.

Is it possible to use cmdstanr inside of R packages like rstan may currently be used with rstandevtools?

If so, would somebody please point me towards the documentation and also provide search tips so I can improve my Google ninja skills.

(As an FYI, I’m working debugging/profiling a model in an R package and cmdstanr takes ~2 seconds to run a model that takes ~90 seconds to with rstan).

Hello Have a look to here

and to this package extending cmdstanr

4 Likes

This has been requested a few times so I created a minimal package that depends on a Stan model and uses cmdstanr to sample using it: misc/democmdstanr at master · rok-cesnovar/misc · GitHub

It has a single function bernoulli(y = c(0,1,1,1,1,1,0,0)) that will compile the model the first time after installation, but all subsequent runs will be instant.

4 Likes