| SimExtract | R Documentation |
Extracts any error or warnings messages, the seeds associated with any error or warning messages, and any analysis results that were stored in the final simulation object.
SimExtract(object, what, fuzzy = TRUE, append = TRUE)
object |
object returned from |
what |
character vector indicating what information to extract, written in agnostic casing
(e.g.,
,
Note that |
fuzzy |
logical; use fuzzy string matching to reduce effectively identical messages? For example, when attempting to invert a matrix the error message "System is computationally singular: reciprocal condition number = 1.92747e-17" and "System is computationally singular: reciprocal condition number = 2.15321e-16" are effectively the same, and likely should be reported in the same columns of the extracted output |
append |
logical; append the design conditions when extracting error/warning messages? |
Phil Chalmers rphilip.chalmers@gmail.com
Chalmers, R. P., & Adkins, M. C. (2020). Writing Effective and Reliable Monte Carlo Simulations
with the SimDesign Package. The Quantitative Methods for Psychology, 16(4), 248-280.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.20982/tqmp.16.4.p248")}
Sigal, M. J., & Chalmers, R. P. (2016). Play it again: Teaching statistics with Monte
Carlo simulation. Journal of Statistics Education, 24(3), 136-156.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10691898.2016.1246953")}
SimErrors, SimWarnings
## Not run:
Generate <- function(condition, fixed_objects) {
int <- sample(1:10, 1)
if(int > 5) warning('GENERATE WARNING: int greater than 5')
if(int == 1) stop('GENERATE ERROR: integer is 1')
rnorm(5)
}
Analyse <- function(condition, dat, fixed_objects) {
int <- sample(1:10, 1)
if(int > 5) warning('ANALYSE WARNING: int greater than 5')
if(int == 1) stop('ANALYSE ERROR: int is 1')
c(ret = 1)
}
Summarise <- function(condition, results, fixed_objects) {
mean(results)
}
res <- runSimulation(replications = 100, seed=1234,
generate=Generate, analyse=Analyse, summarise=Summarise)
res
SimExtract(res, what = 'errors') # see also SimErrors()
SimExtract(res, what = 'warnings') # see also SimWarnings()
seeds <- SimExtract(res, what = 'error_seeds')
seeds[,1:3]
# replicate a specific error for debugging (type Q to exit debugger)
res <- runSimulation(replications = 100, load_seed=seeds[,1], debug='analyse-1',
generate=Generate, analyse=Analyse, summarise=Summarise)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.