Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document a CmdStan-focused way to pre-compile Stan models in R packages #809

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions vignettes/cmdstanr-internals.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,24 @@ CmdStanR can of course be used for developing other packages that require compil
and running Stan models as well as using new or custom Stan features available
through CmdStan.

### Pre-compiled Stan models in R packages

You may compile a Stan model at runtime (e.g. just before sampling),
or you may compile all the models inside the package file system in advance at installation time.
The latter avoids compilations at runtime, which matters in centrally managed R installations
where users should not compile their own software.

To pre-compile all the models in a package,
you may create top-level scripts `configure` and `configure.win`
which run `cmdstan_model()` with `compile = TRUE` and save the compiled executables
somewhere inside the `inst/` folder of the package source.
The [`instantiate`](https://wlandau.github.io/instantiate/) package helps developers
configure packages this way,
and it documents other topics such as submitting to CRAN and administering CmdStan.
Kevin Ushey's [`configure`](https://github.com/kevinushey/configure) package helps
create and manage package configuration files in general.


### Troubleshooting and debugging

When developing or testing new features it might be useful to have more
Expand Down