Skip to content

Commit 16c3453

Browse files
committed
pkg update
1 parent b7fb201 commit 16c3453

File tree

5 files changed

+69
-58
lines changed

5 files changed

+69
-58
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: SimDesign
22
Title: Structure for Organizing Monte Carlo Simulation Designs
3-
Version: 2.13.10
3+
Version: 2.14
44
Authors@R: c(person("Phil", "Chalmers", email = "[email protected]", role = c("aut", "cre"),
55
comment = c(ORCID="0000-0001-5332-2810")),
66
person("Matthew", "Sigal", role = c("ctb")),

NEWS.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- `SimSolve()` function added to perform (stochastic) root-solving to estimate
66
specific criteria from simulation studies. Currently supports uni-root type
7-
problems for continuous or discrete variables via the the probabilistic
7+
problems for continuous or discrete variables via the probabilistic
88
bisection algorithm with bolstering and interpolations (ProBABLI),
99
Brent's method, and the classical bisection approach, the latter two of which
1010
can be problematic if the number of replications per iteration are too low
@@ -15,19 +15,20 @@
1515
via generalized linear models
1616

1717
- `runSimulation(..., store_results = TRUE)` is now the default to automatically
18-
store the results from `Analyse()` in the returned simulation. If RAM issues
19-
are suspected then `save_results = TRUE` is still the recommended approach
18+
store the results from `Analyse()` in the returned simulation object.
19+
If RAM issues are suspected then `save_results = TRUE` is still
20+
the recommended approach
2021

2122
- `convertWarnings()` wrapper/post-hoc function added to convert specific
2223
warning messages to errors during simulations. Useful when only a subset
2324
of warnings are known to be problematic, while other warning messages
2425
(whether known or not) are treated as provisionally innocuous
2526

2627
- `control` gains a `print_RAM` logical argument to suppress printing the RAM
27-
when `verbose = TRUE`. Disabling this can marginally improve execution speed
28-
as the garbage collector (`gc()`) calls are avoided, which is used to extract
29-
the current RAM state. Setting `verbose = FALSE` will automatically
30-
disable the RAM and `gc()` calls and their overhead as well
28+
when `verbose = TRUE`. Disabling this can reduce execution time
29+
as garbage collector (`gc()`) calls are avoided, which is required extract
30+
the current RAM state. Setting `verbose = FALSE` will also automatically
31+
disable the RAM and `gc()` calls and their overhead
3132

3233
- `Attach()` now accepts `matrix` input objects, and gains a `RStudio_flags`
3334
argument to generate syntax that suppresses false positives about variables

R/PBA.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ PBA <- function(f, interval, ..., p = .6,
290290

291291
if(verbose){
292292
if(integer)
293-
cat(sprintf("\rIter: %i; Median: %i", iter, med))
294-
else cat(sprintf("\rIter: %i; Median: %.3f", iter, med))
293+
cat(sprintf("\rIter: %i; Median = %i", iter, med))
294+
else cat(sprintf("\rIter: %i; Median = %.3f", iter, med))
295295
cat(sprintf("; E(f(x)) = %.2f", abs(e.froot)))
296296
if(!is.null(FromSimSolve))
297297
cat('; Total.reps =', sum(replications[1L:iter]))

R/SimSolve.R

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,21 @@
233233
#' # Must return a single number corresponding to f(x) in the
234234
#' # root equation f(x) = b
235235
#'
236-
#' ret <- EDR(results, alpha = condition$sig.level)
236+
#' ret <- c(power = EDR(results, alpha = condition$sig.level))
237237
#' ret
238238
#' }
239239
#'
240240
#' #~~~~~~~~~~~~~~~~~~~~~~~~
241241
#' #### Step 3 --- Optimize N over the rows in design
242-
#' # Initial search between N = [10,500] for each row using the default
243-
#' # integer solver (integer = TRUE)
244242
#'
245-
#' # In this example, b = target power
243+
#' # (For debugging) may want to see if simulation code works as intended first
244+
#' # for some given set of inputs
245+
#' runSimulation(design=createDesign(N=100, d=.8, sig.level=.05),
246+
#' replications=10, generate=Generate, analyse=Analyse,
247+
#' summarise=Summarise)
248+
#'
249+
#' # Initial search between N = [10,500] for each row using the default
250+
#' # integer solver (integer = TRUE). In this example, b = target power
246251
#' solved <- SimSolve(design=Design, b=.8, interval=c(10, 500),
247252
#' generate=Generate, analyse=Analyse,
248253
#' summarise=Summarise)
@@ -259,21 +264,21 @@
259264
#'
260265
#' # verify with true power from pwr package
261266
#' library(pwr)
262-
#' pwr.t.test(d=.2, power = .8, sig.level = .05)
263-
#' pwr.t.test(d=.5, power = .8, sig.level = .05)
264-
#' pwr.t.test(d=.8, power = .8, sig.level = .05)
267+
#' pwr.t.test(d=.2, power = .8) # sig.level/alpha = .05 by default
268+
#' pwr.t.test(d=.5, power = .8)
269+
#' pwr.t.test(d=.8, power = .8)
265270
#'
266271
#' # use estimated N results to see how close power was
267272
#' N <- solved$N
268-
#' pwr.t.test(d=.2, n=N[1], sig.level = .05)
269-
#' pwr.t.test(d=.5, n=N[2], sig.level = .05)
270-
#' pwr.t.test(d=.8, n=N[3], sig.level = .05)
273+
#' pwr.t.test(d=.2, n=N[1])
274+
#' pwr.t.test(d=.5, n=N[2])
275+
#' pwr.t.test(d=.8, n=N[3])
271276
#'
272277
#' # with rounding
273278
#' N <- ceiling(solved$N)
274-
#' pwr.t.test(d=.2, n=N[1], sig.level = .05)
275-
#' pwr.t.test(d=.5, n=N[2], sig.level = .05)
276-
#' pwr.t.test(d=.8, n=N[3], sig.level = .05)
279+
#' pwr.t.test(d=.2, n=N[1])
280+
#' pwr.t.test(d=.5, n=N[2])
281+
#' pwr.t.test(d=.8, n=N[3])
277282
#'
278283
#' # failing analytic formula, confirm results with more precise
279284
#' # simulation via runSimulation()
@@ -301,9 +306,9 @@
301306
#'
302307
#' # use estimated N results to see how close power was
303308
#' N <- solved_2min$N
304-
#' pwr.t.test(d=.2, n=N[1], sig.level = .05)
305-
#' pwr.t.test(d=.5, n=N[2], sig.level = .05)
306-
#' pwr.t.test(d=.8, n=N[3], sig.level = .05)
309+
#' pwr.t.test(d=.2, n=N[1])
310+
#' pwr.t.test(d=.5, n=N[2])
311+
#' pwr.t.test(d=.8, n=N[3])
307312
#'
308313
#' #------------------------------------------------
309314
#'
@@ -331,8 +336,8 @@
331336
#' # In this example, b = target power
332337
#' # note that integer = FALSE to allow smooth updates of d
333338
#' solved <- SimSolve(design=Design, b = .8, interval=c(.1, 2),
334-
#' generate=Generate, analyse=Analyse,
335-
#' summarise=Summarise, integer=FALSE)
339+
#' generate=Generate, analyse=Analyse,
340+
#' summarise=Summarise, integer=FALSE)
336341
#' solved
337342
#' summary(solved)
338343
#' plot(solved, 1)
@@ -346,14 +351,14 @@
346351
#'
347352
#' # verify with true power from pwr package
348353
#' library(pwr)
349-
#' pwr.t.test(n=100, power = .8, sig.level = .05)
350-
#' pwr.t.test(n=50, power = .8, sig.level = .05)
351-
#' pwr.t.test(n=25, power = .8, sig.level = .05)
354+
#' pwr.t.test(n=100, power = .8)
355+
#' pwr.t.test(n=50, power = .8)
356+
#' pwr.t.test(n=25, power = .8)
352357
#'
353358
#' # use estimated d results to see how close power was
354-
#' pwr.t.test(n=100, d = solved$d[1], sig.level = .05)
355-
#' pwr.t.test(n=50, d = solved$d[2], sig.level = .05)
356-
#' pwr.t.test(n=25, d = solved$d[3], sig.level = .05)
359+
#' pwr.t.test(n=100, d = solved$d[1])
360+
#' pwr.t.test(n=50, d = solved$d[2])
361+
#' pwr.t.test(n=25, d = solved$d[3])
357362
#'
358363
#' # failing analytic formula, confirm results with more precise
359364
#' # simulation via runSimulation()

man/SimSolve.Rd

Lines changed: 29 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)