run_method | R Documentation |
Given a Method
object or list of Method
objects,
this function runs the method(s) on the draws passed through object
.
The output of each method is saved to file.
run_method(object, methods, out_loc = "out", parallel = NULL)
object |
an object of class |
methods |
a list of |
out_loc |
(optional) a length-1 character vector that gives location (relative to model's path) that method outputs are stored.This can be useful for staying organized when multiple simulations are based on the same Model and Draws objects. |
parallel |
either |
This function creates objects of class Output
and saves each to
file (at dir/model_name/<out_loc>/r<index>_<method_name>.Rdata. If parallel
is not NULL, then it must be a list containing socket_names
, which can
either be a positive integer specifying the number of copies to run on
localhost or else a character vector of machine names (e.g.,
"mycluster-0-0"). The list parallel
can also contain
libraries
, a character vector of R packages that will be needed on the
slaves and save_locally
, a logical that indicates whether the files
generated should be saved on the slaves (i.e., locally) or on the master.
Before running each method on index i, the RNG state is restored to what it
was at the end of calling simulate_from_model
on this index.
This is only relevant for randomized methods. The choice to do this ensures
that one will get identical results regardless of the order in which methods
and indices are run in. When ExtendedMethod
objects are
passed, these are run after all Method
objects have been run. This is
because each ExtendedMethod
object depends on the output of its base
method. Furthermore, before an ExtendedMethod
is called, the RNG
state is restored to what it was after the base method had been called.
generate_model
simulate_from_model
## Not run: # suppose previously we had run the following: sim <- new_simulation(name = "normal-example", label = "Normal Mean Estimation", dir = tempdir()) %>% generate_model(make_my_example_model, n = 20) %>% simulate_from_model(nsim = 50, index = 1:3) # then we could add sim <- run_method(sim, my_example_method) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.