View source: R/derived-quantities.R
derived_quantities | R Documentation |
When the expression contains non-library functions/objects, and parallel processing
is enabled, those must be
named in the .globals
parameter (hopefully we'll be able to detect those
automatically in the future). Note that recompute_SBC_statistics()
currently
does not use parallel processing, so .globals
don't need to be set.
derived_quantities(..., .globals = list())
... |
named expressions representing the quantitites |
.globals |
A list of names of objects that are defined
in the global environment and need to present for the gen. quants. to evaluate.
It is added to the |
# Derived quantity computing the total log likelihood of a normal distribution
# with known sd = 1
normal_lpdf <- function(y, mu, sigma) {
sum(dnorm(y, mean = mu, sd = sigma, log = TRUE))
}
# Note the use of .globals to make the normal_lpdf function available
# within the expression
log_lik_dq <- derived_quantities(log_lik = normal_lpdf(y, mu, 1),
.globals = "normal_lpdf" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.