Design <- createDesign(N = c(10, 20, 30))
Generate <- function(condition, fixed_objects) {
dat <- with(condition, rnorm(N, 10, 5)) # distributed N(10, 5)
dat
}
Analyse <- function(condition, dat, fixed_objects) {
ret <- c(mean=mean(dat), median=median(dat)) # mean/median of sample data
ret
}
Summarise <- function(condition, results, fixed_objects){
colMeans(results)
}
if (FALSE) {
# run the simulation
runSimulation(design=Design, replications=50,
generate=Generate, analyse=Analyse,
summarise=Summarise, save_results=TRUE,
save_details = list(save_results_dirname='simresults'))
res <- reSummarise(Summarise, dir = 'simresults/')
res
Summarise2 <- function(condition, results, fixed_objects){
ret <- c(mean_ests=colMeans(results), SE=colSDs(results))
ret
}
res2 <- reSummarise(Summarise2, dir = 'simresults/')
res2
SimClean(dir='simresults/')
}
###
# Similar, but with results stored within the final object
res <- runSimulation(design=Design, replications=50, store_results = TRUE,
generate=Generate, analyse=Analyse, summarise=Summarise)
res
# same summarise but with bootstrapping
res2 <- reSummarise(Summarise, results = res, boot_method = 'basic')
res2
Run the code above in your browser using DataLab