sma_derive: Apply R code to derive new variables.

View source: R/simanalyse-derive.R

sma_deriveR Documentation

Apply R code to derive new variables.

Description

Apply R code to derive new variables.

Usage

sma_derive(
  object = NULL,
  code,
  monitor = ".*",
  values = list(),
  progress = FALSE,
  options = furrr::furrr_options()
)

Arguments

object

An object of class (or that can be coerced to) mcmcrs, mcmcr, nlists or nlist.

code

A string of R code to derive posterior samples for new parameters. E.g. "var = sigma^2".

monitor

A character vector (or regular expression if a string) specifying the names of the variables in object and/or code to monitor. By default all variables are included.

values

A named list of additional R objects to evaluate in the R expression.

progress

A flag specifying whether to print a progress bar.

options

The future specific options to use with the workers.

Value

An object of the same class as object

Examples

set.seed(10L)
code <- "for(i in 1:10){x[i] ~ dnorm(0,1/variance)}"
parameters = nlist(variance=4)
dat <- sims::sims_simulate(code, parameters = parameters, nsims=2)
res <- sma_analyse(dat, code, code.add = "variance ~ dunif(0,10)", 
mode=sma_set_mode("quick"), monitor="variance")
sma_derive(res, "sd=sqrt(variance)")
sma_derive(parameters, "sd=sqrt(variance)")


audrey-b/simanalyse documentation built on May 20, 2022, 7:45 p.m.