How to Use RStan
The rest of this document assumes that you have already installed RStan by following the instructions above.
Loading the package
The package name is rstan (all lowercase), so we start by executing
library("rstan") # observe startup messages
As the startup message says, if you are using rstan locally on a multicore machine and have plenty of RAM to estimate your model in parallel, at this point execute
options(mc.cores = parallel::detectCores())
In addition, you should follow the second startup message that says to execute
rstan_options(auto_write = TRUE)
which allows you to automatically save a bare version of a compiled Stan program to the hard disk so that it does not need to be recompiled (unless you change it).
Finally, if you use Windows, there will be a third startup message saying to execute
Sys.setenv(LOCAL_CPPFLAGS = '-march=native')
which is not necessary if you followed the C++ toolchain configuration advice in the previous section.


雷达卡
京公网安备 11010802022788号







