Learn R Programming

MSPRT (version 2.1)

design.MSPRT: Designing a MSPRT

Description

Given the desired values of Type 1 & Type 2 error probabilities and the maximum available number of samples (N), this function designs the MSPRT (by finding the 'Termination Threshold' \(\gamma\)). \(\gamma\) is the smallest possible value so that the Type 1 error of the MSPRT is maintained at the desired level. This function designs the MSPRT for one-sample proportion tests, one-sample Z and T-tests, and two-sample Z and T-tests.

By default (that is, if alt.comp is missing or FALSE) this provides the operating characteristics (OC) for the obtained MSPRT at the null hypothesized value. Otherwise, this also finds the OC at a user desired point alternative. This point alternative is specified through alt.comp.

In general, OC.MSPRT() can also be used to find the OC of the MSPRT at any desired parameter value.

Usage

design.MSPRT(test.type, side, batch.seq, batch1.seq, batch2.seq, 
             type1 = 0.005, type2 = 0.2, null, sigma0 = 1, 
             N.max, N1.max, N2.max, alt.comp, repl, 
             verbose = T, core.no)

Arguments

test.type

a character; denotes the type of test.

``oneProp'' for a one-sample binomial proportion test.

``oneZ'' for a one-sample Z-test.

``oneT'' for a one-sample T-test.

``twoZ'' for a two-sample Z-test.

``twoT'' for a two-sample T-test.

side

a character; direction of the alternative hypothesis H1.

Has to be one of "right" or "left".

Default: "right".

batch.seq

a numeric vector; required only in one-sample tests. Sizes of sequentially observed batches in a group sequential design.

Required only if the design is group sequential, that is when data are observed in batches. Otherwise, only need to provide N.max.

batch1.seq

a numeric vector; required only in two-sample tests. Sizes of sequentially observed batches from Group-1 in a group sequential design.

Required only if the design is group sequential, that is when data from Group-1 are observed in batches. Otherwise, only need to provide N1.max.

batch2.seq

a numeric vector; required only in two-sample tests. Sizes of sequentially observed batches from Group-2 in a group sequential design.

Required only if the design is group sequential, that is when data from Group-2 are observed in batches. Otherwise, only need to provide N2.max.

type1

a numeric in (0,1); the probability at which we want to control the Type 1 error of the MSPRT.

Default: 0.005.

type2

a numeric in (0,1); the probability at which we want to control the Type 2 error of the MSPRT.

Default: 0.2.

null

a numeric; required only in one-sample proportion and Z-tests. Denotes value of the hypothesized parameter under the null hypothesis.

The hypothesized parameters are proportion in one-sample binomial proportion test, population mean in one-sample Z & T-tests, and difference between the population means of Group-2 and Group-1 in two-sample Z & T-tests.

In one-sample T-tests and two-sample tests, only null=0 is allowed. This is done automatically. This argument is ignored in these cases.

Default: 0.5 in one-sample binomial proportion test, and 0 in one-sample Z-tests.

sigma0

a positive numeric; required only in one & two-sample Z-tests. Known population standard deviation in one-sample tests and known common population standard deviation in two-sample tests.

Default: 1.

N.max

a positive numeric (integer); required only in one-sample tests. Maximum number of samples that we can afford in the one-sample test.

In a group sequential design, this should be equal to sum(batch.seq). So in that case, it's enough to provide only batch.seq and not N.max.

N1.max

a positive numeric (integer); required only in two-sample tests. Maximum number of samples from Group-1 that we can afford in the two-sample test.

In a group sequential design, this should be equal to sum(batch1.seq). So in that case, it's enough to provide only batch1.seq and not N1.max.

N2.max

a positive numeric (integer); required only in two-sample tests. Maximum number of samples from Group-2 that we can afford in the two-sample test.

In a group sequential design, this should be equal to sum(batch2.seq). So in that case, it's enough to provide only batch2.seq and not N2.max.

alt.comp

missing, FALSE or TRUE, or a numeric;

If missing or FALSE, the OC of the MSPRT are obtained only at the null;

If TRUE, the OC of the MSPRT are computed at the null and the 'fixed design alternative';

If a numeric, it can be any value under the alternative (consistent with the "side"). Then OC of the MSPRT are obtained at the null and this point.

repl

a positve numeric (integer); total number of replications to be used in Monte Carlo method to calculate the OC of the MSPRT.

Default (Recommended): 2e+6 in a one-sample proportion test; 1e+6 otherwise. Should be at least 1e+5.

verbose

a logical; if TRUE, returns messages of the current proceedings; otherwise it doesn't.

Default: TRUE.

core.no

a numeric; number of cores this function can use for carrying out a parallel computation.

Default: 1 if there are at most 2 cores, otherwise (number of cores -1).

Value

Let us first look at the outputs in one-sample tests.

If alt.comp is missing or FALSE (default), this computes the OC of the obtained MSPRT under the null hypothesis, and returns a list with the following components:

type1.est

a numeric in (0,1); the Type 1 error probability of the MSPRT.

avg.n0

a positive numeric; the number of samples required on an average by the MSPRT for coming to a decision when the null hypothesis is true.

umpbt.alt

a numeric or a numeric vector of length 2; In one-sample proportion tests, this is usually of length 2. They specify the two points of the UMPBT alternative. In one & two-sample Z-tests, this is the UMPBT point alternative. In one & two-sample T-tests, this is not returned.

psi.umpbt

a numeric in (0,1); returned only in case of one-sample proportion tests. This denotes the probability of the first component in umpbt.alt.

rej.threshold

a numeric; the constant value of Wald's rejection threshold.

acc.threshold

a numeric; the constant value of Wald's acceptance threshold.

term.thresh

a positive numeric; denotes the Termination Threshold (\(\gamma\)) of a MSPRT.

If alt.comp equals TRUE, this additionally computes the OC of the obtained MSPRT at the 'fixed design alternative'. In this case, the function returns a list with the following components in addition to the previously mentioned components:

type2.est

a numeric in (0,1); the Type 2 error probability of the obtained MSPRT at the alternative.

avg.n1

a positive numeric; the number of samples required on an average by the MSPRT for coming to a decision when the alternative is true.

alt

a numeric; the point alternative where the performance is computed. In this case, this is the 'fixed design alternative'.

alt.type2

a numeric in (0,1); the Type 2 error probability of the fixed design test at alt. In this case this is exactly type2.

If alt.comp is numeric, then this computes the list exactly it was for alt.comp = TRUE with type2.est, avg.n1, alt and alt.type2 now computed at this user specified value.

In two-sample tests we get similar outputs as in one-sample tests above, except avg.n0 and avg.n1 is replaced by avg.n1_0, avg.n2_0 and avg.n1_1, avg.n2_1, respectively.

avg.n1_0

a positive numeric; the number of samples from Group-1 required on an average by the MSPRT for coming to a decision when the null hypothesis is true.

avg.n2_0

a positive numeric; the number of samples from Group-2 required on an average by the MSPRT for coming to a decision when the null hypothesis is true.

avg.n1_1

a positive numeric; the number of samples from Group-1 required on an average by the MSPRT for coming to a decision when the alternative hypothesis is true.

avg.n2_1

a positive numeric; the number of samples from Group-2 required on an average by the MSPRT for coming to a decision when the alternative hypothesis is true.

Details

In two-sample tests, the hypothesized parameter is (population mean of Group-2 - population mean of Group-1). So null=0 implies that these two means are equal under the null hypothesis; side="right" implies that the population mean of Group-2 is larger under this alternative hypothesis; side="left" implies that the population mean of Group-1 is larger under this alternative hypothesis.

For a user guide, please refer to the supplemental information.

References

MSPRT: Main article and Supplemental file

Johnson, Valen E., Uniformly most powerful Bayesian tests., Ann. of Stat., 41, (4), 2013, pp. 1716-1741

Johnson, Valen E., Revised standards for statistical evidence., Proceedings of the National Academy of Sciences, 16, 1945.

Daniel J. Benjamin, James O. Berger, Magnus Johannesson, et al. Redefine statistical significance. Nature Human Behaviour, 2017.

Examples

Run this code
# NOT RUN {
## right-sided one-sample proportion test

# can observe data after each sample sequentially. Max available
# sample size is 30
# design.MSPRT(test.type="oneProp", null = 0.2, N.max = 30)


# can observe data at every fifth sample sequentially. Max available
# sample size is 30. So there are 6 batches each of size 5.
# design.MSPRT(test.type="oneProp", null = 0.2, N.max = 30,
#              batch.seq = rep(5,6))
               

               
## right-sided one-sample Z-test

# can observe data after each sample sequentially. Max available
# sample size is 30
# design.MSPRT(test.type="oneZ", null = 3, sigma0 = 1.5,
#              N.max = 30)


# can observe data at every fifth sample sequentially. Max available
# sample size is 30. So there are 6 batches each of size 5.
# design.MSPRT(test.type="oneZ", null = 3, sigma0 = 1.5,
#              N.max = 30, batch.seq = rep(5,6))
               


## right-sided one-sample T-test

# can observe data after each sample sequentially. Max available
# sample size is 30
# design.MSPRT(test.type="oneT", N.max = 30)


# can observe data at every fifth sample sequentially. Max available
# sample size is 30. So there are 6 batches each of size 5.
# design.MSPRT(test.type="oneT", N.max = 30, batch.seq = rep(5,6))


               
## right-sided two-sample Z-test

# can observe data after each sample for each group sequentially.
# Max available sample size is 30 for both groups
# design.MSPRT(test.type="twoZ", sigma0 = 1.5, N1.max = 30, N2.max = 30)


# can observe data at every fifth sample for each group sequentially.
# Max available sample size is 30 for both groups. So there are 6 batches
# each of size 5 for each group.
# design.MSPRT(test.type="twoZ", sigma0 = 1.5,
#              batch1.seq = rep(5,6), batch2.seq = rep(5,6),
#              N1.max = 30, N2.max = 30)
               

               
## right-sided two-sample T-test

# can observe data after each sample for each group sequentially.
# Max available sample size is 30 for both groups
# design.MSPRT(test.type="twoT", N1.max = 30, N2.max = 30)


# can observe data at every fifth sample for each group sequentially.
# Max available sample size is 30 for both groups. So there are 6 batches
# each of size 5 for each group.
# design.MSPRT(test.type="twoT", N1.max = 30, N2.max = 30,
#              batch1.seq = rep(5,6), batch2.seq = rep(5,6))
# }

Run the code above in your browser using DataLab