Skip to content

Commit

Permalink
Merge pull request #809 from wlandau/738-instantiate
Browse files Browse the repository at this point in the history
Document a CmdStan-focused way to pre-compile Stan models in R packages
  • Loading branch information
jgabry authored Aug 8, 2023
2 parents 74f39dc + 8505f1c commit b90c143
Showing 1 changed file with 18 additions and 0 deletions.
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

0 comments on commit b90c143

Please sign in to comment.