Learn R Programming

adoptr (version 0.1.1)

evaluate: Evaluation of a score

Description

Both ConditionalScore as well as UnconditionalScore implement evaluate methods which handle the actual computation of the score given a design and (for conditional scores) an interim result.

Usage

evaluate(s, design, ...)

# S4 method for IntegralScore,TwoStageDesign evaluate(s, design, optimization = FALSE, subdivisions = 10000L, ...)

# S4 method for AffineScore,TwoStageDesign evaluate(s, design, ...)

# S4 method for Constraint,TwoStageDesign evaluate(s, design, optimization = FALSE, ...)

# S4 method for ConstraintsCollection,TwoStageDesign evaluate(s, design, optimization = FALSE, ...)

# S4 method for ConditionalPower,TwoStageDesign evaluate(s, design, x1, optimization = FALSE, ...)

# S4 method for ConditionalSampleSize,TwoStageDesign evaluate(s, design, x1, optimization = FALSE, ...)

# S4 method for AverageN2,TwoStageDesign evaluate(s, design, optimization = FALSE, subdivisions = 10000L, ...)

# S4 method for N1,TwoStageDesign evaluate(s, design, optimization = FALSE, ...)

Arguments

s

score

design

TwoStageDesign object

...

further optional arguments

optimization

logical, if TRUE uses a relaxation to real parameters of the underlying design; used for smooth optimization.

subdivisions

integer, number of subdivisions that is used for integration on the continuation region; results become more precise with increased number of subdivisions; default is 10000L.

x1

stage-one test statistic

Details

The method evaluate is preimplemented for all preimplemented scores in adoptr. An example on working with scores is presented here.

See Also

Conditional scores additionally implement an expected method to obtain the corresponding unconditional IntegralScore.

Examples

Run this code
# NOT RUN {
# create a dummy design
design <- TwoStageDesign(50, .0, 2.0, 50, 2.0, order = 5L)

# define type one error als IntegralScore
toer <- expected(ConditionalPower(Normal(), PointMassPrior(.0, 1)))

# evaluate
evaluate(toer, design)

# evaluate affine N1 score
aff_n1 <- N1() + 10
evaluate(
   aff_n1,
   OneStageDesign(50, 1.96)
) # 60

evaluate(
   expected(ConditionalPower(Normal(), PointMassPrior(.0, 1))) <= 0.05,
   OneStageDesign(50, 1.96)
) # -0.025

# define power at delta = 0.3 and type one error rate
pow  <- expected(ConditionalPower(Normal(), PointMassPrior(.3, 1)))
toer <- expected(ConditionalPower(Normal(), PointMassPrior(.0, 1)))
# evaluate if power >= 0.8 and toer <= 0.025
evaluate(
   subject_to(
      pow  >= 0.8,
      toer <= 0.025
   ),
   TwoStageDesign(50.0, 0.0, 2.0, rep(60.0, 5), seq(2.0, 0.0, length.out = 5))
)


# evaluate conditional power
evaluate(
   ConditionalPower(Normal(), PointMassPrior(.3, 1)),
   TwoStageDesign(50, .0, 2.0, 50, 2.0, order = 5L),
   x1 = 1
)

# evaluate conditional sample size
evaluate(
   ConditionalSampleSize(Normal(), PointMassPrior(.3, 1)),
   TwoStageDesign(50, .0, 2.0, 50, 2.0, order = 5L),
   x1 = 3
) # 50

evaluate(
   AverageN2(),
   TwoStageDesign(100, 0.5, 1.5, 60.0, 1.96, order = 5L)
) # 60

evaluate(
   N1(),
   TwoStageDesign(70, 0, 2, rep(60, 6), rep(1.7, 6))
) # 70

# }

Run the code above in your browser using DataLab