Learn R Programming

SimDesign (version 1.13)

SimFunctions: Skeleton functions for simulations

Description

This function prints skeleton versions of the required SimDesign functions to run simulations, complete with the correct inputs, class of outputs, and optional comments to help with the initial definitions. Use this at the start of your Monte Carlo simulation study. The recommended approach is to save the template to the hard-drive by passing a suitable file name. However, for larger simulations, as well as when using the RStudio, two separate files will often be easier for debugging/sourcing the simulation code (achieved by passing singlefile = FALSE). For a didactic presentation of the package refer to Sigal and Chalmers (2016; 10.1080/10691898.2016.1246953), and see the associated wiki on Github (https://github.com/philchalmers/SimDesign/wiki) for other tutorial material, examples, and applications of SimDesign to real-world simulations.

Usage

SimFunctions(filename = NULL, dir = getwd(), comments = FALSE,
  singlefile = TRUE, summarise = TRUE, generate = TRUE,
  openFiles = TRUE)

Arguments

filename

a character vector indicating whether the output should be saved to two respective files containing the simulation design and the functional components, respectively. Using this option is generally the recommended approach when beginning to write a Monte Carlo simulation

dir

the directory to write the files to. Default is the working directory

comments

logical; include helpful comments? Default is FALSE

singlefile

logical; when filename is included, put output in one files? When FALSE the output is saved to two separate files containing the functions and design definitions. The two-file format often makes organization and debugging slightly easier, especially for larger Monte Carlo simulations. Default is TRUE

summarise

include summarise function? Default is TRUE

generate

include generate function? Default is TRUE

openFiles

logical; after files have been generated, open them in your text editor (e.g., if Rstudio is running the scripts will open in a new tab)?

References

Sigal, M. J., & Chalmers, R. P. (2016). Play it again: Teaching statistics with Monte Carlo simulation. Journal of Statistics Education, 24(3), 136-156. 10.1080/10691898.2016.1246953

Examples

Run this code
# NOT RUN {
SimFunctions()
SimFunctions(comments = TRUE) #with helpful comments

# }
# NOT RUN {
# write output to two files (recommended for larger MCSs)
SimFunctions('mysim', singlefile = FALSE)

# write output files to a single file with comments
SimFunctions('mysim', comments = TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab