rstantools package has served the community beautifully, allowing us to pre-compile Stan models in R packages much like
rstanarm. Aside from the obvious efficiency gains, especially in simulation studies, pre-compiling saves us the trouble of diagnosing compiler errors near runtime. However, the version of Stan in CmdStan is far more advanced, and many of us R package developers are keen to work it into our packages in a seamless way.
To meet the need, I created a package called
instantiate package configures other packages to pre-compile their models at installation time, then offers up
cmdstanr’s excellent interface without any further compilation. It also offers alternative ways to install and connect to CmdStan which may be more amenable to centralized R installations at large highly-regulated companies. The documentation website is at Pre-Compiled CmdStan Models in R Packages • instantiate. It is a brand new package, and I still have a lot to learn about Stan, but I hope this pattern is useful.