diff --git a/NAMESPACE b/NAMESPACE index 6ce14c2a..895d95c5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -41,6 +41,7 @@ export(SimFunctions) export(SimResults) export(SimShiny) export(SimSolve) +export(addMissing) export(add_missing) export(aggregate_simulations) export(bias) diff --git a/R/SFA.R b/R/SFA.R index 81edb6e6..7f6d6a47 100644 --- a/R/SFA.R +++ b/R/SFA.R @@ -87,7 +87,7 @@ #' #' sim <- runSimulation(design=Design, replications=10, #' generate=Generate, analyse=Analyse, -#' summarise=Summarise, store_results=TRUE, +#' summarise=Summarise, store_results=TRUE, save=FALSE, #' progress=FALSE, control=list(print_RAM=FALSE)) #' sim #' @@ -128,7 +128,7 @@ #' #' sim2 <- runSimulation(design=Design, replications=100, #' generate=Generate, analyse=Analyse, -#' summarise=Summarise, store_results=TRUE, +#' summarise=Summarise, store_results=TRUE, save=FALSE, #' progress=FALSE, control=list(print_RAM=FALSE)) #' sim2 #' sum(sim2$REPLICATIONS) # more replications in total @@ -168,7 +168,7 @@ #' #' sim3 <- runSimulation(design=Design, replications=50, #' generate=Generate, analyse=Analyse, -#' summarise=Summarise, store_results=TRUE, +#' summarise=Summarise, store_results=TRUE, save=FALSE, #' progress=FALSE, control=list(print_RAM=FALSE)) #' sim3 #' sum(sim3$REPLICATIONS) diff --git a/R/addMissing.R b/R/addMissing.R index c9d3b651..8694d0cd 100644 --- a/R/addMissing.R +++ b/R/addMissing.R @@ -48,7 +48,7 @@ #' Carlo simulation. \code{Journal of Statistics Education, 24}(3), 136-156. #' \doi{10.1080/10691898.2016.1246953} #' -#' @export add_missing +#' @export #' #' @author Phil Chalmers \email{rphilip.chalmers@@gmail.com} #' diff --git a/R/bootPredict.R b/R/bootPredict.R index b5a9e941..e1f949b3 100644 --- a/R/bootPredict.R +++ b/R/bootPredict.R @@ -69,8 +69,8 @@ #' } #' #' Summarise <- function(condition, results, fixed_objects) { -#' ret <- c(mu_bias = bias(results[,1], 0), -#' mu_coverage = ECR(results[,2:3], parameter = 0)) +#' ret <- c(mu_bias = bias(results[,"mean"], 0), +#' mu_coverage = ECR(results[,c("lower", "upper")], parameter = 0)) #' ret #' } #' @@ -103,7 +103,7 @@ #' (beta / .001)^2 #' } #' -bootPredict <- function(condition, generate, analyse, summarise, fixed_objects, ..., +bootPredict <- function(condition, generate, analyse, summarise, fixed_objects=NULL, ..., Rstar = seq(100, 500, by=100), boot_draws = 1000){ replications <- max(Rstar) results <- runSimulation(design=condition, generate=generate, analyse=analyse, diff --git a/R/reSummarise.R b/R/reSummarise.R index 105aee93..1ea9b589 100644 --- a/R/reSummarise.R +++ b/R/reSummarise.R @@ -97,7 +97,7 @@ #' res2 <- reSummarise(Summarise2, dir = 'simresults/') #' res2 #' -#' SimClean('simresults/') +#' SimClean(dir='simresults/') #' #' } #' diff --git a/R/summary_functions.R b/R/summary_functions.R index 274708cc..96ed7436 100644 --- a/R/summary_functions.R +++ b/R/summary_functions.R @@ -1028,10 +1028,8 @@ ECR <- function(CIs, parameter, tails = FALSE, CI_width = FALSE, if(is.data.frame(parameter)) parameter <- unlist(parameter) stopifnot(is.vector(parameter)) if(length(parameter) != 1L) stopifnot(length(parameter) == nrow(CIs)) - if(CIs[1,1] > CIs[1,2]){ - warning('First column not less than second. Temporarily switching') - CIs <- cbind(CIs[,2L], CIs[,1L]) - } + if(any(CIs[,1] > CIs[,2])) + stop('lower CIs higher than upper CIs. Please inspect') if(CI_width){ ret <- mean(CIs[,2L] - CIs[,1L]) if(!is.null(names)) diff --git a/man/SFA.Rd b/man/SFA.Rd index d1519db0..ee8fd17d 100644 --- a/man/SFA.Rd +++ b/man/SFA.Rd @@ -91,7 +91,7 @@ Summarise <- function(condition, results, fixed_objects) { sim <- runSimulation(design=Design, replications=10, generate=Generate, analyse=Analyse, - summarise=Summarise, store_results=TRUE, + summarise=Summarise, store_results=TRUE, save=FALSE, progress=FALSE, control=list(print_RAM=FALSE)) sim @@ -132,7 +132,7 @@ Design sim2 <- runSimulation(design=Design, replications=100, generate=Generate, analyse=Analyse, - summarise=Summarise, store_results=TRUE, + summarise=Summarise, store_results=TRUE, save=FALSE, progress=FALSE, control=list(print_RAM=FALSE)) sim2 sum(sim2$REPLICATIONS) # more replications in total @@ -172,7 +172,7 @@ Design sim3 <- runSimulation(design=Design, replications=50, generate=Generate, analyse=Analyse, - summarise=Summarise, store_results=TRUE, + summarise=Summarise, store_results=TRUE, save=FALSE, progress=FALSE, control=list(print_RAM=FALSE)) sim3 sum(sim3$REPLICATIONS) diff --git a/man/bootPredict.Rd b/man/bootPredict.Rd index 1d842404..a534c803 100644 --- a/man/bootPredict.Rd +++ b/man/bootPredict.Rd @@ -10,7 +10,7 @@ bootPredict( generate, analyse, summarise, - fixed_objects, + fixed_objects = NULL, ..., Rstar = seq(100, 500, by = 100), boot_draws = 1000 @@ -73,8 +73,8 @@ Analyse <- function(condition, dat, fixed_objects) { } Summarise <- function(condition, results, fixed_objects) { - ret <- c(mu_bias = bias(results[,1], 0), - mu_coverage = ECR(results[,2:3], parameter = 0)) + ret <- c(mu_bias = bias(results[,"mean"], 0), + mu_coverage = ECR(results[,c("lower", "upper")], parameter = 0)) ret } diff --git a/man/reSummarise.Rd b/man/reSummarise.Rd index ac025c00..1a37f54d 100644 --- a/man/reSummarise.Rd +++ b/man/reSummarise.Rd @@ -102,7 +102,7 @@ Summarise2 <- function(condition, results, fixed_objects){ res2 <- reSummarise(Summarise2, dir = 'simresults/') res2 -SimClean('simresults/') +SimClean(dir='simresults/') }