(Un)conditional Scores inadoptr
There are two fundamental ways of scoring a two-stage design: First,one may assess the performance before observing any data, i.e., at theplanning stage. Classical examples for such scores would be power,type-one-error rate, or expected sample size. There is, however, asecond perspective. After observing the stage-one outcome, one might beinclined to consider conditional properties of a design. The mostprominent example being conditional power (probability to reject thenull under the alternative given stage-one outcome). We consider thefollowing example design
design<-TwoStageDesign( n1=100, c1f=.0, c1e=2.0, n2_pivots=rep(150,5), c2_pivots=sapply(1+adoptr:::GaussLegendreRule(5)$nodes,function(x)-x+2))plot(design)
In adoptr, scores are instances of their respective score class. Themost important ones are:ConditionalScore,UnconditionalScore, andIntegralScore. Anobject of classConditionalScore can evaluate a design fora particular stage-one outcome. AConditionalScore is afunctionevaluating a designat a stage-one outcome.Some conditional scores might depend on the data distribution(conditional power) others do not (conditional sample size). Conditionalscore evaluation is completely vectorized:
uniform_prior<-ContinuousPrior(function(x)numeric(length(x))+1/.2, support=c(.3,.5))cp<-ConditionalPower(Normal(),uniform_prior)css<-ConditionalSampleSize()x1<-c(0,.5,1)evaluate(cp,design,x1)#> [1] 0.8312538 0.9303985 0.9772962evaluate(css,design,x1)#> [1] 250 250 250Conditional scores can also be plotted directly for a given design byincluding them in theplot() call.
plot(design,"Conditional Power"=cp)
Any conditional score can be integrated with respect to a prior anddata distribution to obtain an unconditional score. Note that forconditional scores which depend on a specification of thesedistributions (e.g., conditional power) these arguments must beconsistent! The resulting score is of classIntegralScore,a specific subclass ofUnconditionalScore and evaluatesdesigns independent of a particular,i.e., unconditionally
Power at a point alternative can be obtained by forming the expectedvalue with respect to a point prior. For convenience, we include aconstructor for power directly, e.g., both variants are equivalent andgive power at.
power1<-expected(ConditionalPower(Normal(),PointMassPrior(.4,1.0)),Normal(),PointMassPrior(.4,1.0))power2<-Power(Normal(),PointMassPrior(.4,1.0))evaluate(power1,design)#> [1] 0.9967857evaluate(power2,design)#> [1] 0.9967857Similarly,ExpectedSampleSize is a shorthand constructorfor expected conditional sample size, i.e., the overall expected samplesize:
ess1<-expected(ConditionalSampleSize(),Normal(),uniform_prior)ess2<-ExpectedSampleSize(Normal(),uniform_prior)evaluate(ess1,design)#> [1] 134.9135evaluate(ess2,design)#> [1] 134.9135Conditional Constraints
The same syntax for constraint specification as for unconditionalconstraints (power etc.) can be used for conditional scores(e.g. conditional power) as well. Currently, these constraints apply tothe continuation area only. E.g.,
cp>=0.7#> -Pr[x2>=c2(x1)|x1] (x1) <= -0.7 for x1 in [c1f,c1e]imposes a constraint on the minimal conditional power uponcontinuation. Inter-score comparisons are also supported, e.g.
cp>=ConditionalPower(Normal(),PointMassPrior(0,1))#> Pr[x2>=c2(x1)|x1] - Pr[x2>=c2(x1)|x1] (x1) <= 0 for x1 in [c1f,c1e]Would enforce that conditional power is always larger thanconditional error.
