Learn R Programming

mcmcsae (version 0.6.0)

transform_dc: Transform one or more draws components into a new one by applying a function

Description

Transform one or more draws components into a new one by applying a function

Usage

transform_dc(..., fun, to.matrix = FALSE, labels = NULL)

Arguments

...

draws component object(s).

fun

a function to apply. This function should take as many arguments as there are input objects. The arguments can be arbitrarily named, but they are assumed to be in the same order as the input objects. The function should return a vector.

to.matrix

if TRUE the output is in matrix format; otherwise it is a draws component object.

labels

optional labels for the output object.

Value

Either a matrix or a draws component.

Examples

Run this code
# NOT RUN {
ex <- mcmcsae_example(n=50)
sampler <- create_sampler(ex$model, data=ex$dat)
sim <- MCMCsim(sampler, burnin=100, n.iter=300, thin=2, n.chain=4, store.all=TRUE)
summary(sim$v_sigma)
summary(transform_dc(sim$v_sigma, fun=function(x) x^2))
summary(transform_dc(sim$u, sim$u_sigma, fun=function(x1, x2) abs(x1)/x2))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab