sampling
: draw samples from Stan modelstanmodel
.
This method is a generic function of the S4 class stanmodel
.## S3 method for class 'stanmodel':
sampling(object, data = list(), pars = NA,
chains = 4, iter = 2000, warmup = floor(iter/2), thin = 1,
seed = sample.int(.Machine$integer.max, 1), init = 'random',
check_data = TRUE, sample_file = NULL, diagnostic_file = NULL, verbose = FALSE,
algorithm = c("NUTS", "HMC", "Fixed_param"), control = NULL, include = TRUE, cores = getOption("mc.cores", 1L),
open_progress = interactive() && !isatty(stdout()) &&
!identical(Sys.getenv("RSTUDIO"), "1"),
show_messages = TRUE, ...)
stanmodel
.list
or environment
providing the data for the model or a character vector
for all the names of objects used as data.
See the notes in stan
.NA
indicating all parameters in the model. If include = TRUE
, only
samples for parameters given in pars
are stored in the fitted re0
, string "0"
or "random"
,
a function that returns a list, or a list of initial parameter values with
which to indicate how the initial values of parameters are specified.
"0"
:TRUE
, the data would be preprocessed;
otherwise not. If the data is not checked and preprocessed, it is safe
to leave it to be the default TRUE
. See the notes in stan
tempdir()
is used.tempdir()
is used.
When there TRUE
or FALSE
: flag indicating whether
to print intermediate output from Stan on the console, which might
be helpful for model debugging.control
of function
stan
.TRUE
indicating
whether to include or exclude the parameters given by the
pars
argument. If FALSE
, only entire multidimensional
parameters can be excluded, rather than particmc.cores
option
to be as many processors as the hardware and RAM allow (up to the
number of chains).cores > 1
but is recommended to be TRUE
in interactive
use so that the progress of the chains will be redirected to a file
that is automatically opened for inspection. For verTRUE
)
indicating whether to print the summary of Informational Messages to
the screen after a chain is finished or a character string naming a path
where the summary is stored. Setting to chain_id
, init_r
,
test_grad
, append_samples
, refresh
,
enable_random_init
.
See the document in stan
stanfit
representing
the fitted results. Slot mode
for this object
indicates if the sampling is done or not.stanmodel
, stanfit
, stan
m <- stan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}')
f <- sampling(m, iter = 100)
Run the code above in your browser using DataLab