stanmodel from a model
specified in Stan's modeling language. A stanmodel
can be used to draw samples from the model. If the model is
supplied in the Stan modeling language, it is first translated to
C++ code. The C++ code for the model plus other auxiliary
code is compiled into a dynamic shared object (DSO) and then loaded.
The loaded DSO for the model can be executed to draw samples, allowing
inference to be performed for the model and data.stan_model(file, model_name = "anon_model",
model_code = "", stanc_ret = NULL,
boost_lib = NULL, eigen_lib = NULL,
save_dso = TRUE, verbose = FALSE,
auto_write = rstan_options("auto_write"), ...)"anon_model". However, the model name would be derived from
file or model_code (if model_code is the name of a
character string object) if <file
or stanc_ret.stanc. The list can be used to specify the model
instead of using parameter file or model_code.TRUE: indication of whether the
dynamic shared object (DSO) compiled from the C++ code for the model
will be saved or not. If TRUE, we can draw samples from
the same model in another RsesTRUE or FALSE: indication of whether
to report intermediate output to the console,
which might be helpful for debugging.TRUE or FALSE: indication of whether to write the
object to the hard disk using saveRDS. By default, this argument
is FALSE, but we recommend to always avoid tstanc.stanmodel , which can be
used later for drawing samples by calling its sampling function.stan_model exists on the hard drive, its validity
is checked and then returned without recompiling. To avoid reading previously
compiled stan_models from the hard drive, supply the stanc_ret
argument rather than the file or model_code arguments.
More details of Stan, including the full user's guide and reference
manual can be found at There are three ways to specify the model's code for stan_model.
model_code, containing character string to
whose value is the Stan model specification,file, indicating a file (or a connection) from
which to read the Stan model specification, orstanc_ret, indicating the re-use of a model
generated in a previous call tostanc.stanmodel and stanstan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}')Run the code above in your browser using DataLab