This vignette demonstrates one of the newer features in the SimDesign package pertaining to multiple analysis function definitions that can be selected for each Design condition or whenever they are applicable. The purpose of providing multiple analysis functions is to

  1. Remove the less readable if-then-else combinations that can appear when writing simulation code, where specific analysis functions are not intended to be used on a given generated dataset,
  2. Provide better automatic naming of the analysis results across independent subroutines,
  3. Construct more readable code when the Analyse() function contains too much code to easily track, and to
  4. Create a more modular approach to isolating the analysis functions for the purpose of redistribution or reusing in related projects

Functionality speaking, this type of organization does not change how SimDesign generally operates. For that reason, the coding style presented in this vignette can be considered optional. However, if any of the above points resonate well with you then following the details of this coding organization style may prove useful.

1 Description of structure

The usual work-flow with SimDesign requires first calling SimFunctions() to generate a working template, such as the following.

SimDesign::SimFunctions()
## #-------------------------------------------------------------------
## 
## library(SimDesign)
## 
## Design <- createDesign(factor1 = NA,
##                        factor2 = NA)
## 
## #-------------------------------------------------------------------
## 
## Generate <- function(condition, fixed_objects = NULL) {
##     dat <- data.frame()
##     dat
## }
## 
## Analyse <- function(condition, dat, fixed_objects = NULL) {
##     ret <- c(stat1 = NaN, stat2 = NaN)
##     ret
## }
## 
## Summarise <- function(condition, results, fixed_objects = NULL) {
##     ret <- c(bias = NaN, RMSE = NaN)
##     ret
## }
## 
## #-------------------------------------------------------------------
## 
## res <- runSimulation(design=Design, replications=1000, generate=Generate, 
##                      analyse=Analyse, summarise=Summarise)
## res

which uses the default nA