PSSample | R Documentation |
Stan
Sample from the posterior distribution by calling stan
.
Check stan
for details of the arguments.
PSSample(
file,
model_name = "anon_model",
model_code = "",
fit = NA,
data = list(),
pars = NA,
chains = 4,
iter = 2000,
warmup = floor(iter/2),
thin = 1,
init = "random",
seed = sample.int(.Machine$integer.max, 1),
algorithm = c("NUTS", "HMC", "Fixed_param"),
control = NULL,
sample_file = NULL,
diagnostic_file = NULL,
save_dso = TRUE,
verbose = FALSE,
include = TRUE,
cores = getOption("mc.cores", 1L),
open_progress = interactive() && !isatty(stdout()) && !identical(Sys.getenv("RSTUDIO"),
"1"),
...,
boost_lib = NULL,
eigen_lib = NULL
)
file |
The path to the Stan program to use.
A model may also be specified directly as a character string using the
The |
model_name |
A string to use as the name of the model; defaults
to |
model_code |
A character string either containing the model definition or the name of
a character string object in the workspace. This argument is used only
if arguments |
fit |
An instance of S4 class |
data |
A named |
pars |
A character vector specifying parameters of interest to be saved.
The default is to save all parameters from the model.
If |
chains |
A positive integer specifying the number of Markov chains. The default is 4. |
iter |
A positive integer specifying the number of iterations for each chain (including warmup). The default is 2000. |
warmup |
A positive integer specifying the number of warmup (aka burnin)
iterations per chain. If step-size adaptation is on (which it is by default),
this also controls the number of iterations for which adaptation is run (and
hence these warmup samples should not be used for inference). The number of
warmup iterations should be smaller than |
thin |
A positive integer specifying the period for saving samples. The default is 1, which is usually the recommended value. Unless your posterior distribution takes up too much memory we do not recommend thinning as it throws away information. The tradition of thinning when running MCMC stems primarily from the use of samplers that require a large number of iterations to achieve the desired effective sample size. Because of the efficiency (effective samples per second) of Hamiltonian Monte Carlo, rarely should this be necessary when using Stan. |
init |
Specification of initial values for all or some parameters.
Can be the digit
When specifying initial values via a |
seed |
The seed for random number generation. The default is generated
from 1 to the maximum integer supported by R on the machine. Even if
multiple chains are used, only one seed is needed, with other chains having
seeds derived from that of the first chain to avoid dependent samples.
When a seed is specified by a number, Using R's |
algorithm |
One of the sampling algorithms that are implemented in Stan.
The default and preferred algorithm is |
control |
A named
In addition, algorithm HMC (called 'static HMC' in Stan) and NUTS share the following parameters:
For algorithm NUTS, we can also set:
For algorithm HMC, we can also set:
For
|
sample_file |
An optional character string providing the name of a file.
If specified the draws for all parameters and other saved quantities
will be written to the file. If not provided, files are not created.
When the folder specified is not writable, |
diagnostic_file |
An optional character string providing the name of a file.
If specified the diagnostics data for all parameters will be written
to the file. If not provided, files are not created. When the folder specified
is not writable, |
save_dso |
Logical, with default |
verbose |
|
include |
Logical scalar defaulting to |
cores |
The number of cores to use when executing the Markov chains in parallel.
The default is to use the value of the |
open_progress |
Logical scalar that only takes effect if
|
... |
Other optional parameters:
Deprecated:
|
boost_lib |
The path for an alternative version of the Boost C++ to use instead of the one in the BH package. |
eigen_lib |
The path for an alternative version of the Eigen C++ library to the one in RcppEigen. |
An object of S4 class rstan::stanfit
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.