log_prob
and grad_log_prob
functionslog_prob
and grad_log_prob
take values from the
unconstrained space of model parameters and (by default) return values in
the same space. Sometimes we need to convert the values of parameters from
their support defined in the parameters block (which might be constrained,
and for simplicity, we call it the constrained space) to the unconstrained
space and vice versa. The constrain_pars
and unconstrain_pars
functions are used for this purpose.
"log_prob"(object, upars, adjust_transform = TRUE, gradient = FALSE) "grad_log_prob"(object, upars, adjust_transform = TRUE) "get_num_upars"(object) "constrain_pars"(object, upars) "unconstrain_pars"(object, pars)
stanfit
.FALSE
to make the
function return the same values as Stan's lp__
output.
log_prob
returns a value (up to an additive constant) the log posterior.
If gradient
is TRUE
, the gradients are also returned as an
attribute with name gradient
.grad_log_prob
returns a vector of the gradients. Additionally, the vector
has an attribute named log_prob
being the value the same as log_prob
is called for the input parameters.get_num_upars
returns the number of parameters on the unconstrained space.constrain_pars
returns a list and unconstrain_pars
returns a vector.
lp__
) for the model represented by a stanfit
object. Note that,
by default, log_prob
returns the log posterior in the unconstrained
space; set adjust_transform = FALSE
to make the values match Stan's
output. Compute the gradients
for log_prob
as well as the log posterior. The latter is returned as
an attribute. Get the number
of unconstrained parameters. Convert values
of the parameter from unconstrained space (given as a vector) to their
constrained space (returned as a named list).
Contrary to
constrained
, conert values of the parameters from constrained
to unconstrained space. log_prob
and grad_log_prob
functions
accept an adjust_transform
argument.
stanfit