update_sim | R Documentation |
This function updates a previously run simulation. After a
simulation has been run
, you can alter the levels of the
resulting object of class sim_obj
using set_levels
,
or change the configuration (including the number of simulation
replicates) using set_config
. Executing update_sim
on
this simulation object will only run the added levels/replicates, without
repeating anything that has already been run.
update_sim(sim, keep_errors = TRUE, keep_extra = FALSE)
sim |
A simulation object of class |
keep_errors |
logical ( |
keep_extra |
logical ( |
It is not possible to add new level variables, only new levels of the existing variables. Because of this, it is best practice to include all potential level variables before initially running a simulation, even if some of them only contain a single level. This way, additional levels can be added later.
In general, if num_sim
has been reduced prior to running
update_sim
, it is best to use the default option
keep_extra = FALSE
. Otherwise, some simulation levels will have more
replicates than others, which makes comparison difficult.
The original simulation object with additional simulation replicates
in results
or errors
sim <- new_sim() create_data <- function(n) { rpois(n, lambda=5) } est_mean <- function(dat, type) { if (type=="M") { return(mean(dat)) } if (type=="V") { return(var(dat)) } } sim %<>% set_levels(n=c(10,100), est="M") sim %<>% set_config(num_sim=10) sim %<>% set_script(function() { dat <- create_data(L$n) lambda_hat <- est_mean(dat=dat, type=L$est) return (list("lambda_hat"=lambda_hat)) }) sim %<>% run() sim %<>% set_levels(n=c(10,100,1000), est=c("M","V")) sim %<>% set_config(num_sim=5) sim %<>% update_sim()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.