Construct trace function from a BridgeStan StanModel
object.
Source: R/bridges.R
trace_function_from_stan_model.Rd
Construct trace function from a BridgeStan StanModel
object.
Usage
trace_function_from_stan_model(
model,
include_log_density = TRUE,
include_generated_quantities = FALSE,
include_transformed_parameters = FALSE
)
Arguments
- model
Stan model object to use to generate (constrained) parameters to trace.
- include_log_density
Whether to include an entry
log_density
corresponding to current log density for target distribution in values returned by trace function.- include_generated_quantities
Whether to included generated quantities in Stan model definition in values returned by trace function.
- include_transformed_parameters
Whether to include transformed parameters in Stan model definition in values returned by trace function.
Value
A function which given chain_state
object returns a named vector of
values to trace during sampling. The constrained parameter values of model
will always be included.
Examples
model <- example_gaussian_stan_model()
trace_function <- trace_function_from_stan_model(model)
withr::with_seed(876287L, state <- chain_state(rnorm(model$param_unc_num())))
trace_function(state)
#> mu sigma log_density
#> -2.4372636 0.9944442 -118.6630971