Skip to content

Commit

Permalink
Merge branch 'master' into 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmann committed Jun 3, 2019
2 parents 8fa2add + 6a6d8c4 commit 78aae4e
Show file tree
Hide file tree
Showing 19 changed files with 633 additions and 776 deletions.
4 changes: 2 additions & 2 deletions R/CompositeScore.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ setClass("CompositeConditionalScore",
#' @template dotdotdot
#'
#' @return an object of class \code{CompositeConditionalScore} or
#' \code{CompositeUnconditionalScore} depending of the class of the scores used
#' \code{CompositeUnconditionalScore} depending on the class of the scores used
#' in \code{expr}
#'
#' @seealso \link{Scores}
Expand All @@ -41,7 +41,7 @@ setClass("CompositeConditionalScore",
#' # linear combination:
#' composite({ess - 50*power})
#'
#' # control flow
#' # control flow (e.g. for and while loops)
#' composite({
#' res <- 0
#' for (i in 1:3) {
Expand Down
4 changes: 2 additions & 2 deletions R/adoptr.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' Adaptive Optimal Two-Stage Designs
#'
#' The \pkg{adoptr} package provides functionality to explore custom optimal
#' two-stage designs for one or two-arm superiority tests.
#' two-stage designs for one- or two-arm superiority tests.
#' Currently, only (asymptotically) normal test statistics are supported.
#' \pkg{adoptr} is makes heavy use of the S4 class system.
#' \pkg{adoptr} makes heavy use of the S4 class system.
#' A good place to start learning about it can be found
#' \href{http://adv-r.had.co.nz/OO-essentials.html}{here}.
#'
Expand Down
4 changes: 2 additions & 2 deletions man/adoptr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/composite.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 29 additions & 19 deletions tests/testthat/test_ConditionalScores.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
context("test sample size")




design <- TwoStageDesign(25, 0, 2, rep(40.0, 5), rep( 2, 5), 5L)
dist <- Normal()
prior <- ContinuousPrior(function(x) rep(1/10, length(x)), c(-4, 6))
z1 <- seq(-1, 3, .1)



test_that("conditional sample size maps to actual sample size", {

css <- ConditionalSampleSize()
Expand All @@ -14,44 +18,44 @@ test_that("conditional sample size maps to actual sample size", {

expect_equal(
evaluate(css, design, z1),
n(design, z1)
)
n(design, z1),
tolerance = 1e-4, scale = 1)

expect_equal(
evaluate(ess1, design),
evaluate(ess2, design)
)
evaluate(ess2, design),
tolerance = 1e-4, scale = 1)


}) # end 'conditional sample size maps to actual sample size'





context("Test Conditional Power")



test_that("Conditional Power is monotonous", {

# Define two simple designs
design1 <- TwoStageDesign(25, 0, 2, rep(40.0, 5), seq(2.0, 0.0, length.out = 5))
design2 <- TwoStageDesign(25, 0, 2, rep(60.0, 5), seq(2.0, 0.0, length.out = 5))

design1 <- TwoStageDesign(25, 0, 2, rep(40.0, 5), seq(2.0, 0.0, length.out = 5))
design2 <- TwoStageDesign(25, 0, 2, rep(60.0, 5), seq(2.0, 0.0, length.out = 5))
dist <- Normal()
null <- PointMassPrior(.0, 1)
alternative <- PointMassPrior(.4, 1)

cp <- ConditionalPower(dist, alternative)
cp <- ConditionalPower(dist, alternative)

# Conditional Power is monotonously increasing in n
expect_gt(
evaluate(cp, design2, 1),
evaluate(cp, design1, 1)
)
evaluate(cp, design1, 1))

# Conditional Power is monotonously increasing in z1
expect_gt(
evaluate(cp, design1, 1.5),
evaluate(cp, design1, 0.5)
)
evaluate(cp, design1, 0.5))

}) # end "Conditional Power is monotonous"

Expand All @@ -64,13 +68,14 @@ test_that("Conditional power has correct values outside continuation region",{

expect_equal(
evaluate(cp, design1, -1),
0.0
)
0.0,
tolerance = 1e-4, scale = 1)

expect_equal(
evaluate(cp, design1, 3),
1.0
)
1.0,
tolerance = 1e-4, scale = 1)

}) # end 'Conditional power has correct values outside continuation region'


Expand All @@ -82,14 +87,19 @@ test_that("Power works",{

expect_equal(
evaluate(pow1, design),
evaluate(pow2, design)
)
evaluate(pow2, design),
tolerance = 1e-4, scale = 1)

}) # end 'Power works'





context("Test class ConditionalScore")



test_that("Conditional scores are vectorized in z1", {

css <- ConditionalSampleSize()
Expand Down
Loading

0 comments on commit 78aae4e

Please sign in to comment.