Repeated simulation
repeater( dataset, nr = 12, vars = "", grid = "", sum_vars = "", byvar = ".sim", fun = "sum", form = "", seed = NULL, name = "", envir = parent.frame() )
dataset | Return value from the simulater function |
---|---|
nr | Number times to repeat the simulation |
vars | Variables to use in repeated simulation |
grid | Character vector of expressions to use in grid search for constants |
sum_vars | (Numeric) variables to summaries |
byvar | Variable(s) to group data by before summarizing |
fun | Functions to use for summarizing |
form | A character vector with the formula to apply to the summarized data |
seed | Seed for the repeated simulation |
name | Deprecated argument |
envir | Environment to extract data from |
summary.repeater
to summarize results from repeated simulation
plot.repeater
to plot results from repeated simulation
simdat <- simulater( const = c("var_cost 5","fixed_cost 1000"), norm = "E 0 100;", discrete = "price 6 8 .3 .7;", form = c( "demand = 1000 - 50*price + E", "profit = demand*(price-var_cost) - fixed_cost", "profit_small = profit < 100" ), seed = 1234 ) repdat <- repeater( simdat, nr = 12, vars = c("E","price"), sum_vars = "profit", byvar = ".sim", form = "profit_365 = profit_sum < 36500", seed = 1234, ) head(repdat)#> .sim profit_sum profit_365 #> 1 1 7998.972 TRUE #> 2 2 7450.843 TRUE #> 3 3 5747.208 TRUE #> 4 4 2773.283 TRUE #> 5 5 6401.404 TRUE #> 6 6 6750.054 TRUEsummary(repdat)#> Repeated simulation #> Simulations : 1,000 #> Repetitions : 12 #> Re-simulated : E, price #> Group by : Simulation #> Function : sum #> Random seed : 1234 #> Simulated data: simdat #> Repeat data : repdat #> Formulas : #> profit_365 = profit_sum < 36500 #> #> Variables: #> variable n_obs mean sd min p25 median #> profit_sum 1,000 5,644.9274 2,007.1863 -223.6821 4,372.1464 5,741.6681 #> p75 max #> 7,043.5267 11,255.2636 #> #> Logicals: #> TRUE (nr) TRUE (prop) #> profit_365 1,000 1 #>plot(repdat)