simulator: Simulation setup

Description Usage Arguments Details Value

View source: R/base.R

Description

This function applies rule (which takes in parameter settings and outputs a synthetic dataset) and criterion (which takes a synthetic dataset and outputs the results from estimators) to all the rows of df_param (which is a matrix that contains different parameter settings for each row). The distinction between rule and criterion is only made by the user, as the user can design exactly the same simulation that uses one but not the other.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
simulator(
  rule,
  criterion,
  df_param,
  ntrials = 10,
  specific_trials = NA,
  cores = 1,
  shuffle_group = NA,
  chunking_num = nrow(df_param),
  required_packages = NULL,
  filepath = NA,
  verbose = T
)

Arguments

rule

function

criterion

function

df_param

data frame

ntrials

number of trials for each row

specific_trials

vector of integers of specific trials to run

cores

number of cores, where if larger than 1, parallelization occurs

shuffle_group

either NA or a list where each element of the list is a vector containing unique integers ranging within 1:nrow(df_param)

chunking_num

integer, where if !is.na(chunking_num), dictatees how many intermediary files are saved during the simulation

required_packages

packages to load into the multisession if cores>1

filepath

string

verbose

boolean

Details

The input to rule must be a vector (a row from df_param), while the input to criterion must be first the output of rule and second a vector (the same row from df_param). Both these functions is allowed to output lists.

The output to simulator is a list, one element for each row of df_param. Each element of the list is typically a list or a matrix. This depends on how the user set up what criterion returns.

The function has a tryCatch call, so if an error happens, the result for that trial and row of df_param will be an NA.

The remaining inputs for simulator are cosmetic.

filepath is a filepath to the temporary save location. If set to not NA, simulator will save the results of every row of df_param there as it runs the simulations.

Value

list


linnykos/customSimulator documentation built on Dec. 21, 2021, 10:50 a.m.