transform_dc {mcmcsae}R Documentation

Transform one or more draws component objects into a new one by applying a function

Description

Transform one or more draws component objects into a new one by applying a function

Usage

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

Arguments

...

draws component object(s) of class dc.

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 object.

Examples


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))



[Package mcmcsae version 0.7.7 Index]