get_complex: Access internal simulation variables

View source: R/get_complex.R View source: R/get_complex.R

get_complexR Documentation

Access internal simulation variables

Description

Extract complex simulation data from a simulation object

Usage

get_complex(sim, sim_uid)

Arguments

sim

A simulation object of class sim_obj, usually created by new_sim

sim_uid

The unique identifier of a single simulation replicate. This corresponds to the sim_uid column in sim$results.

Value

The value of the complex simulation result data corresponding to the supplied sim_uid

Examples

sim <- new_sim()
create_data <- function(n) {
  x <- runif(n)
  y <- 3 + 2*x + rnorm(n)
  return(data.frame("x"=x, "y"=y))
}
sim %<>% set_levels("n"=c(10, 100, 1000))
sim %<>% set_config(num_sim=1)
sim %<>% set_script(function() {
  dat <- create_data(L$n)
  model <- lm(y~x, data=dat)
  return (list(
    "beta1_hat" = model$coefficients[[2]],
    ".complex" = model
  ))
})
sim %<>% run()
sim$results %>% print()
get_complex(sim, 1) %>% print()

Avi-Kenny/SimEngine documentation built on June 23, 2022, 11:09 a.m.