optimizing
: obtain a point estimate by maximizing the joint posteriorstanmodel
.
This method is a generic function of the S4 class stanmodel
.## S3 method for class 'stanmodel':
optimizing(object, data = list(),
seed = sample.int(.Machine$integer.max, 1), init = 'random',
check_data = TRUE, sample_file = NULL,
algorithm = c("LBFGS", "BFGS", "Newton"),
verbose = FALSE, hessian = FALSE, as_vector = TRUE,
draws = 0, constrained = 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
.as.integer
will be applied to
it. If as.integer
produc0
, string "0"
or "random"
,
a function that returns a list, or a named list of initial parameter
values.
"0"
: initialize all to be zero on the unconstrained support;
"
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.TRUE
or FALSE
: flag indicating whether
to print intermediate output from Stan on the console.TRUE
or FALSE
(the default): flag indicating
whether to calculate the Hessian (via numeric differentiation of the
gradient function in the unconstrained parameter space)TRUE
(the default) or FALSE
: flag indicating
whether a vector is used to for the point estimate found. A list can be used
instead by specifying it to be FALSE
draws > 0
, whether
the draws should be transformed to the constrained space defined in the
parameters block of the Stan program. Defaults to TRUE
.iter
(integer
), the maximum number of iterationssave_iterations
(logical), whether to save the iterationsas_vector
."lp__"
in Stan) corresponding to par
.hessian
is TRUE
draws > 0
draws > 0
, a vector of length draws that contains
the value of the log-posterior evaluated at each row of theta_tilde
draws > 0
, a vector of length draws that contains
the value of the logarithm of the multivariate normal density evaluated
at each row of theta_tilde
NULL
.stanmodel
m <- stan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}')
f <- optimizing(m, hessian = TRUE)
Run the code above in your browser using DataLab