Simulate data for decision analysis

simulater(
  const = "",
  lnorm = "",
  norm = "",
  unif = "",
  discrete = "",
  binom = "",
  pois = "",
  sequ = "",
  grid = "",
  data = NULL,
  form = "",
  funcs = "",
  seed = NULL,
  nexact = FALSE,
  ncorr = NULL,
  name = "",
  nr = 1000,
  dataset = NULL,
  envir = parent.frame()
)

Arguments

const

A character vector listing the constants to include in the analysis (e.g., c("cost = 3", "size = 4"))

lnorm

A character vector listing the log-normally distributed random variables to include in the analysis (e.g., "demand 2000 1000" where the first number is the log-mean and the second is the log-standard deviation)

norm

A character vector listing the normally distributed random variables to include in the analysis (e.g., "demand 2000 1000" where the first number is the mean and the second is the standard deviation)

unif

A character vector listing the uniformly distributed random variables to include in the analysis (e.g., "demand 0 1" where the first number is the minimum value and the second is the maximum value)

discrete

A character vector listing the random variables with a discrete distribution to include in the analysis (e.g., "price 5 8 .3 .7" where the first set of numbers are the values and the second set the probabilities

binom

A character vector listing the random variables with a binomial distribution to include in the analysis (e.g., "crash 100 .01") where the first number is the number of trials and the second is the probability of success)

pois

A character vector listing the random variables with a poisson distribution to include in the analysis (e.g., "demand 10") where the number is the lambda value (i.e., the average number of events or the event rate)

sequ

A character vector listing the start and end for a sequence to include in the analysis (e.g., "trend 1 100 1"). The number of 'steps' is determined by the number of simulations

grid

A character vector listing the start, end, and step for a set of sequences to include in the analysis (e.g., "trend 1 100 1"). The number of rows in the expanded will over ride the number of simulations

data

Dataset to be used in the calculations

form

A character vector with the formula to evaluate (e.g., "profit = demand * (price - cost)")

funcs

A named list of user defined functions to apply to variables generated as part of the simulation

seed

Optional seed used in simulation

nexact

Logical to indicate if normally distributed random variables should be simulated to the exact specified values

ncorr

A string of correlations used for normally distributed random variables. The number of values should be equal to one or to the number of combinations of variables simulated

name

Deprecated argument

nr

Number of simulations

dataset

Data list from previous simulation. Used by repeater function

envir

Environment to extract data from

Value

A data.frame with the simulated data

Details

See https://radiant-rstats.github.io/docs/model/simulater.html for an example in Radiant

See also

summary.simulater to summarize results

plot.simulater to plot results

Examples

simulater( const = "cost 3", norm = "demand 2000 1000", discrete = "price 5 8 .3 .7", form = "profit = demand * (price - cost)", seed = 1234 ) %>% str()
#> Classes ‘simulater’ and 'data.frame': 1000 obs. of 4 variables: #> $ cost : num 3 3 3 3 3 3 3 3 3 3 ... #> $ demand: num 793 2277 3084 -346 2429 ... #> $ price : num 8 8 8 8 8 8 5 8 5 8 ... #> $ profit: num 3965 11387 15422 -1728 12146 ... #> - attr(*, "radiant_sim_call")=List of 18 #> ..$ const : chr "cost 3" #> ..$ lnorm : chr "" #> ..$ norm : chr "demand 2000 1000" #> ..$ unif : chr "" #> ..$ discrete: chr "price 5 8 .3 .7" #> ..$ binom : chr "" #> ..$ pois : chr "" #> ..$ sequ : chr "" #> ..$ grid : chr "" #> ..$ data : NULL #> ..$ form : chr "profit = demand * (price - cost)" #> ..$ funcs :length 0 expression() #> .. ..- attr(*, "srcref")= list() #> .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x9139198> #> .. ..- attr(*, "wholeSrcref")= 'srcref' int [1:8] 1 0 2 0 0 0 1 2 #> .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x9139198> #> ..$ seed : num 1234 #> ..$ nexact : logi FALSE #> ..$ name : chr "" #> ..$ nr : num 1000 #> ..$ dataset : NULL #> ..$ envir : language parent.frame() #> - attr(*, "description")= chr "\n### Simulated data\n\nFormulas:\n\nprofit = demand \\* (price - cost)\n\nDate: 2020-08-07 02:24:44"