mutate.functions: Mutate functions to be used with runjags summary methods

mutate.functionsR Documentation

Mutate functions to be used with runjags summary methods

Description

Objects of class runjags-class have specialised options available for print, plot and summary. These methods allow a mutate function to be specified which produces additional variables based on the monitor variables. These functions are examples of valid syntax, and may be useful in their own right.

Usage

contrasts.mcmc(x, vars)

prec2sd(x, vars)

Arguments

x

an object of class MCMC.

vars

an optional character vector of variable names. If supplied, only variable names in the object supplied with a partial match to anything in 'vars' will be used. Note that regular expressions are not allowed, but the caret (^) token can be used to specify the match at the start of a variable name, and a quoted vars will be matched exactly. Default NA meaning all variables available are returned.

Details

The contrasts.mcmc and prec2sd functions are two common applications of the mutate argument to add.summary and run.jags and can be used as examples of the expected inputs and permitted return values. They must take an MCMC object as input, and return an MCMC object or named list with the same length. This can be used to add new variables to the posterior chains that are derived from the directly monitored variables in JAGS. This allows the variables to be summarised or extracted as part of the MCMC objects as if they had been calculated in JAGS, but without the computational or storage overheads associated with calculating them in JAGS directly. The contrasts.mcmc and prec2sd functions are examples of valid objects (but both require an argument, so will have to be passed as e.g. mutate=list('contrasts.mcmc', 'variabletocontrast')). See the mutate argument to add.summary.

Value

An MCMC object.

References

Matthew J. Denwood (2016). runjags: An R Package Providing Interface Utilities, Model Templates, Parallel Computing Methods and Additional Distributions for MCMC Models in JAGS. Journal of Statistical Software, 71(9), 1-25. doi:10.18637/jss.v071.i09

See Also

add.summary for an applciation of these functions.


runjags documentation built on May 29, 2024, 4:34 a.m.