Generate a model.
This function executes the
make_model function provided by the user
and writes to file the resulting
Model object(s). For example,
when simulating regression with a fixed design,
X would be generated
in this function and
also be specified.
the name of the directory where directory named "files" exists
(or should be created) to save
a function that outputs an object of class
optional parameters that may be passed to make_model
an integer seed for the random number generator.
character vector with all elements contained in names(...) See description for more details.
make_model has arguments, these can be passed using
These will be passed directly to
make_model except for any arguments
vary_along. These arguments should be lists and a separate
model will be created for each combination of elements in these lists. For
vary_along = c("n", "p"), then we can pass
n=as.list(c(50, 100, 150)) and
p=as.list(c(10, 100)) and 6
models will be created, one for each pair of
p. For each
pair (n,p), a distinct extension is added to the end of the model name. This
extension is generated using a hash function so that different values of the
vary_along parameters will lead to different model name extensions. This
ensures that if one later decides to add more values of the vary_along
parameters, this will not lead to pre-existing files being overwritten
(unless the same values of the vary_along combination are used again.
object is a directory name, the function returns a reference or
list of references to the model(s) generated. If
object is a
Simulation, then function returns the same
but with references added to the new models created. These changes to the
Simulation object are saved to file.
make_model is called generating an object of class
model, which is saved to
name is the name attribute of
model). This file also contains the random number generator state and
other information such as the function
make_model itself and the date
model was created.
1 2 3 4 5 6 7 8 9 10
# initialize a new simulation sim <- new_simulation(name = "normal-example", label = "Normal Mean Estimation", dir = tempdir()) # generate a model (and add it to the simulation) sim <- generate_model(sim, make_my_example_model, n = 20) # generate a sequence of models (and add them to the simulation) sim <- generate_model(sim, make_my_example_model, n = list(10, 20, 30), vary_along = "n")
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.