compile_stan {makemyprior} | R Documentation |
Compile stan-model
Description
Function that compiles the stan-code for inference that is included in the model. The compiled version is stored in a .rds-file, which is by default stored in tempdir(). Can also be stored in the package (permanent = TRUE), or in a custom directory. In the latter case, this custom directory must be specified every time inference_stan is called. This will also be done by inference_stan, but this way can save some time if it is not already pre-compiled.
Usage
compile_stan(save = FALSE, permanent = FALSE, path = NULL)
Arguments
save |
Whether to save stan-file to location in package or not, defaults to |
permanent |
If |
path |
Only used if file cannot be saved in the package folder. This is a path to a folder where the file
is stored, do not specify a name for the file! (It will be called |
Details
Note that you will get a message saying something about integer division. The PC priors on variance proportions are represented by splines, and to evaluate them in Stan we look up values, and use integer division for this. This does not cause problems.
Value
Returns the stan-model invisibly.
Examples
if (interactive() && requireNamespace("rstan")){
compile_stan(save = TRUE) # saving in tempdir()
}