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 FALSE. Must be in interactive session to save the object to a file.

permanent

If TRUE, the file is stored in the package directory. If FALSE (default), the file is saved in tempdir().

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 "full_file.rds", and should not be changed.) This argument makes the permanent argument being ignored.

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()
}


[Package makemyprior version 1.2.1 Index]