log_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.
# S4 method for stanfit
log_prob(object, upars, adjust_transform = TRUE, gradient = FALSE)
# S4 method for stanfit
grad_log_prob(object, upars, adjust_transform = TRUE)
# S4 method for stanfit
get_num_upars(object)
# S4 method for stanfit
constrain_pars(object, upars)
# S4 method for stanfit
unconstrain_pars(object, pars)
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.signature(object = "stanfit")
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. signature(object = "stanfit")
log_prob
as well as the log posterior. The latter is returned as
an attribute. signature(object = "stanfit")
signature(object = "stanfit")
signature(object = "stanfit")
constrained
, conert values of the parameters from constrained
to unconstrained space. log_prob
and grad_log_prob
functions
accept an adjust_transform
argument.