This brief vignette describes how to get started with the
After installing the package, open R and type.
library(simulator) <- "./sims" dir create(dir)
## New simulation template created! Go to ./sims/main.R to get started.
dir to be the path of a directory (that does not
yet exist) where you want your simulation code and files to be stored.
"./sims" would be a standard choice, where
"." refers to a directory containing files relevant to your
create command generates a skeleton of a
simulation.1 A look at the newly created directory shows
that several files have been created.
##  "eval_functions.R" "main.R" "method_functions.R" ##  "model_functions.R" "writeup.Rmd"
This is the template of a basic simulation.
model_functions.R, write code that defines the models under which you wish to simulate.
method_functions.R, add code for methods that you wish to compare in your simulation (note that by using
library, you can keep
method_functions.Rshort and to the point, focusing on calling
new_methodrather than putting the actual heart of algorithms in that file).
new_metricto define the ways in which your methods will be evaluated.
main.Rcontains the main entry point to the simulation. Running the code in this file determines which models/methods/metrics are computed, etc.
writeup.Rmdshows how all results can be presented in as a report. This document pulls all code from the
.Rfiles mentioned above, so that as
main.Rand other files develop, the report will remain up to date. To create an
htmlfile report, run the following command in R (which requires installing the package
Or if one is using RStudio, one can simply press the
Knit HTML button.
On a typical project, one starts by defining a model in
model_functions.R, one or two methods in
method_functions.R, and a few metrics in
eval_functions.R, and then one runs the code in
main.R. After looking at some of the results, one might add
an additional model or method or metric. One then returns to
main.R, adds some additional lines specifying that the
additional components should be run as well and looks at some more
The simplest way to look at results is by using the plot functions
plot_evals_by. In situations where you wish to investigate
results more deeply than just looking at aggregated plots, one can use
evals to get at all objects
generated through the course of the simulation.
The best way to get a sense of how to use the simulator is to look at examples. There are several vignettes that demonstrate how the simulator can be used to conduct simulations for some of the most famous statistical methods.
This function was inspired by the
devtools, which creates the skeleton of an R