Learn R Programming

MSPRT (version 2.1)

OC.MSPRT: Operating characteristics for a MSPRT

Description

This function evaluates the operating characteristics (OC) for a MSPRT at any specified value of the hypothesized parameter. If the specified value lies in the region of the alternative hypothesis, this computes the Type 2 error probability of the MSPRT; otherwise this computes the Type 1 error probability. In both cases, this also computes the number of samples those are required on an average for making a decision.

Usage

OC.MSPRT(test.type, side, batch.seq, batch1.seq, batch2.seq,
         null, term.thresh, theta, sigma0, type1 = 0.005, type2 = 0.2,
         N.max, N1.max, N2.max, verbose = T, repl, 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.

null

a numeric; required only in one-sample 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 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.

term.thresh

a positive numeric; denotes the termination threshold of a MSPRT.

This is determined at the designing step of a MSPRT using design.MSPRT().

theta

a numeric; the value of hypothesized parameter where we want to evaluate the OC for the MSPRT.

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.

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.

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.

verbose

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

Default: TRUE.

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.

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

Returns a list with the following components:

In one-sample tests:

type1.est or type2.est

a numeric in (0,1); the Type 1 or Type 2 error probability of the MSPRT evaluated at theta, respectively.

avg.n0 or avg.n1

a positive numeric; the number of samples required on an average by the MSPRT for reaching a decision when theta is actually true.

n0.vec or n1.vec

a numeric vector; denotes a vector of sample sizes required for reaching a decision in each of the repl replications in the Monte-Carlo study when theta is actually true.

This is a vector of length repl .

In two-sample tests:

type1.est or type2.est

a numeric in (0,1); the Type 1 or Type 2 error probability of the MSPRT evaluated at theta, respectively.

avg.n1_0 & avg.n2_0, or avg.n1_1 & avg.n2_1

a positive numeric; the number of samples required on an average by the MSPRT from Group 1 and 2 for reaching a decision when theta is actually true.

n1_0.vec & n2_0.vec, or n1_1.vec & n2_1.vec

a numeric vector; denotes a vector of sample sizes required from Group 1 and 2 for reaching a decision in each of the repl replications in the Monte-Carlo study when theta is actually true.

This is a vector of length repl .

Details

For side="right", if theta>null then the Type 2 error is calculated, where as the Type 1 error is calculated when theta<=null; and vice versa.

To put it simply, if theta falls under the alternative hypothesis, then Type 2 error and avg.n1 (in one-sample tests) or avg.n1_1 & avg.n2_1 (in two-sample tests) are calculated; otherwise Type 1 error and avg.n0 (in one-sample tests) or avg.n1_0 & avg.n2_0 (in two-sample tests) are calculated.

Examples

Run this code
# NOT RUN {
# the termination thresholds are obtained from design.MSPRT()

## One-sample proportion test
## finding OC at theta = 0.3

# OC.MSPRT(test.type = "oneProp", null = 0.2,
#          term.thresh = 22.63, theta = 0.3, N.max = 30)



## One-sample Z-test
## finding OC at theta = 4

# OC.MSPRT(test.type = "oneZ", null = 3, sigma0 = 1.5,
#          term.thresh = 27.856, theta = 4, N.max = 30)


## One-sample T-test
## finding OC at theta = 4

# OC.MSPRT(test.type = "oneT", null = 3,
#          term.thresh = 33.152, theta = 4, N.max = 30)


## Two-sample Z-test
## finding OC at theta = 1

# OC.MSPRT(test.type = "twoZ", sigma0 = 1.5, term.thresh = 27.928,
#          theta = 1, N1.max = 30, N2.max = 30)


## Two-sample T-test
## finding OC at theta  = 1

# OC.MSPRT(test.type = "twoT", term.thresh = 32.972, 
#          theta = 1, N1.max = 30, N2.max = 30)

# }

Run the code above in your browser using DataLab