# NOT RUN {
# }
# NOT RUN {
#SimFunctions()
Design <- data.frame(N = c(10, 20, 30))
Generate <- function(condition, fixed_objects = NULL){
dat <- with(condition, rnorm(N, 10, 5)) # distributed N(10, 5)
dat
}
Analyse <- function(condition, dat, fixed_objects = NULL){
CIs <- t.test(dat)$conf.int # t-based CIs
xbar <- mean(dat) # mean of the sample data vector
ret <- c(mean=xbar, lowerCI=CIs[1], upperCI=CIs[2])
ret
}
Summarise <- function(condition, results, fixed_objects = NULL){
ret <- c(mu=mean(results[,1]), SE=sd(results[,1]), # mean and SD summary of the sample means
coverage=ECR(results[,2:3], parameter = 10))
ret
}
res <- runSimulation(design=Design, replications=250, bootSE=TRUE,
generate=Generate, analyse=Analyse, summarise=Summarise)
res
SimBoot(res)
# larger R
res2 <- runSimulation(design=Design, replications=2500, bootSE=TRUE,
generate=Generate, analyse=Analyse, summarise=Summarise)
# point estimates more accurate, smaller BOOT_SE terms
res2
SimBoot(res2) # more reasonable CI range
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab