implement.MSPRT {MSPRT}R Documentation

Implementing the MSPRT

Description

This function implements the MSPRT for a sequentially observed data.

Usage

implement.MSPRT(obs, obs1, obs2, design.MSPRT.object, 
                termination.threshold, test.type, side = "right",
                theta0, Type1.target = 0.005, Type2.target = 0.2,
                N.max, N1.max, N2.max, 
                sigma = 1, sigma1 = 1, sigma2 = 1,
                batch.size, batch1.size, batch2.size,
                verbose = T, plot.it = 2)

Arguments

obs

Numeric vector. The vector of data in the order they are sequentially observed for one-sample tests. Note: Its length can't exceed the length of batch.size.

obs1

Numeric vector. The vector of data in the order they are sequentially observed from Group-1 for two-sample tests. Note: Its length can't exceed the length of batch1.size.

obs2

Numeric vector. The vector of data in the order they are sequentially observed from Group-2 for two-sample tests. Note: Its length can't exceed the length of batch2.size.

design.MSPRT.object

List. The output returned from design.MSPRT corresponding to the MSPRT for which the operating characteristics are desired.

termination.threshold

Positive numeric. Termination threshold of the designed MSPRT.

test.type

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

side

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

theta0

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

Type1.target

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

Type2.target

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

N.max

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

N1.max

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

N2.max

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

sigma

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

sigma1

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

sigma2

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

batch.size

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

batch1.size

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

batch2.size

Same as in design.MSPRT. Not required if design.MSPRT.object is provided.

verbose

Logical. If TRUE (default), returns messages of the current proceedings. Otherwise it doesn't.

plot.it

0, 1 or 2 (default).

  • if plot.it=0, no plot is returned.

  • if plot.it=1, only the ggplot object required to get a comparison plot is returned, but it's not plotted.

  • if plot.it=2, a comparison plot and the corresponding ggplot object is returned.

Details

If design.MSPRT.object is provided, one can only additionally provide nReplicate, nCore, verbose and seed (Easier option). Otherwise, just like in design.MSPRT, all the other arguments together with termination.threshold (obtained from design.MSPRT) needs to be provided adequately.

Value

List. The list has the following named components in case of one-sided one-sample tests:

n

Positive integer. Number of samples required to reach the decision.

decision

Character. The decision reached. The possibilities are 'accept', 'reject' and 'continue'. They respectively correspond to accepting H_0, rejecting H_0 and continue sampling.

RejectH0.threshold

Positive numeric. Threshold for rejecting H_0 in the MSPRT.

RejectH1.threshold

Positive numeric. Threshold for accepting H_1 in the MSPRT.

LR

Numeric vector. Vector of weighted likelihood ratios (proportion tests) or likelihood ratios (z tests) or Bayes factor (t tests) that are computed at each step of sequential analysis until either a decision is reached or the maximum available number of samples (N.max in one-sample tests, or N1.max and N2.max in two-sample tests) has been used.

UMPBT alternative

This stores the UMPBT alternative(s) as

  • UMPBT for proportion tests. Of the same type as it is returned by UMPBT.alt in these tests.

  • theta.UMPBT for z and t tests. This is a numeric in case of z tests and a numeric vector in case of t tests. For t tests the UMPBT alternative depends on the data. So the numeric vector returned in this case contains the UMPBT alternative computed at step of sequential analysis and is based on all data observed until that step.

In case of two-sample tests, the n output above is replaced by n1 and n2. They are positive integers and refer to the number of samples from Group-1 and 2 required to reach the decision.

In case of two-sided tests at level of significance \alpha, the MSPRT carries out a right and a left sided test simultaneously at level of significance \alpha/2. In this case the outputs are same as above with following changes in components in the returned list:

LR

List. It has two components named right and left corresponding to the right and left sided tests of size \alpha/2. Each of these components stores the vector of weighted likelihood ratios (proportion tests) or likelihood ratios (z tests) or Bayes factor (t tests) that are computed at each step of sequential analysis until either a decision is reached or the maximum available number of samples (N.max in one-sample tests, or N1.max and N2.max in two-sample tests) has been used for that sided test.

UMPBT or theta.UMPBT

List with two components named right and left corresponding to the right and left sided tests of size \alpha/2. Each of these contains the UMPBT alternative (of the same type as the output from UMPBT.alt for the test with respective sides.

Author(s)

Sandipan Pramanik, Valen E. Johnson and Anirban Bhattacharya

References

Pramanik S., Johnson V. E. and Bhattacharya A. (2020+). A Modified Sequential Probability Ratio Test. [Arxiv]

Examples


#################### one-sample proportion test ####################

#### right sided ####
### design
#design.oneprop.right = design.MSPRT(test.type = 'oneProp', side = 'right',
#                                    N.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0.5  # change effect size to experiment
#y = rbinom(20, 1, theta.gen)
#implement.oneprop.right = implement.MSPRT(obs = y, 
#                                          design.MSPRT.object = design.oneprop.right)

#### left sided ####
### design
#design.oneprop.left = design.MSPRT(test.type = 'oneProp', side = 'left',
#                                   N.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0.5  # change effect size to experiment
#y = rbinom(20, 1, theta.gen)
#implement.oneprop.left = implement.MSPRT(obs = y, 
#                                          design.MSPRT.object = design.oneprop.left)

#### both sided ####
### design
#design.oneprop.both = design.MSPRT(test.type = 'oneProp', side = 'both',
#                                   N.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0.5  # change effect size to experiment
#y = rbinom(20, 1, theta.gen)
#implement.oneprop.both = implement.MSPRT(obs = y, 
#                                         design.MSPRT.object = design.oneprop.both)


#################### one-sample z test ####################

#### right sided ####
### design
#design.onez.right = design.MSPRT(test.type = 'oneZ', side = 'right',
#                                 N.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y = rnorm(20, theta.gen, design.onez.right$sigma)
#implement.onez.right = implement.MSPRT(obs = y, 
#                                       design.MSPRT.object = design.onez.right)

#### left sided ####
### design
#design.onez.left = design.MSPRT(test.type = 'oneZ', side = 'left',
#                                N.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y = rnorm(20, theta.gen, design.onez.left$sigma)
#implement.onez.left = implement.MSPRT(obs = y, 
#                                      design.MSPRT.object = design.onez.left)

#### both sided ####
### design
#design.onez.both = design.MSPRT(test.type = 'oneZ', side = 'both',
#                                N.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y = rnorm(20, theta.gen, design.onez.both$sigma)
#implement.onez.both = implement.MSPRT(obs = y, 
#                                      design.MSPRT.object = design.onez.both)


#################### one-sample t test ####################

#### right sided ####
### design
#design.onet.right = design.MSPRT(test.type = 'oneT', side = 'right',
#                                 N.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y = rnorm(20, theta.gen, 1)
#implement.onet.right = implement.MSPRT(obs = y, 
#                                       design.MSPRT.object = design.onet.right)

#### left sided ####
### design
#design.onet.left = design.MSPRT(test.type = 'oneT', side = 'left',
#                                N.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y = rnorm(20, theta.gen, 1)
#implement.onet.left = implement.MSPRT(obs = y, 
#                                      design.MSPRT.object = design.onet.left)

#### both sided ####
### design
#design.onet.both = design.MSPRT(test.type = 'oneT', side = 'both',
#                                N.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y = rnorm(20, theta.gen, 1)
#implement.onet.both = implement.MSPRT(obs = y, 
#                                      design.MSPRT.object = design.onet.both)


#################### two-sample z test ####################

#### right sided ####
### design
#design.twoz.right = design.MSPRT(test.type = 'twoZ', side = 'right',
#                                 N1.max = 20, N2.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y1 = rnorm(20, theta.gen/2, design.twoz.right$sigma1)
#y2 = rnorm(20, -theta.gen/2, design.twoz.right$sigma2)
#implement.twoz.right = implement.MSPRT(obs1 = y1, obs2 = y2,
#                                       design.MSPRT.object = design.twoz.right)

#### left sided ####
### design
#design.twoz.left = design.MSPRT(test.type = 'twoZ', side = 'left',
#                                N1.max = 20, N2.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y1 = rnorm(20, theta.gen/2, design.twoz.left$sigma1)
#y2 = rnorm(20, -theta.gen/2, design.twoz.left$sigma2)
#implement.twoz.left = implement.MSPRT(obs1 = y1, obs2 = y2,
#                                      design.MSPRT.object = design.twoz.left)

#### both sided ####
### design
#design.twoz.both = design.MSPRT(test.type = 'twoZ', side = 'both',
#                                N1.max = 20, N2.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y1 = rnorm(20, theta.gen/2, design.twoz.both$sigma1)
#y2 = rnorm(20, -theta.gen/2, design.twoz.both$sigma2)
#implement.twoz.both = implement.MSPRT(obs1 = y1, obs2 = y2,
#                                      design.MSPRT.object = design.twoz.both)


#################### two-sample t test ####################

#### right sided ####
### design
#design.twot.right = design.MSPRT(test.type = 'twoT', side = 'right',
#                                 N1.max = 20, N2.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y1 = rnorm(20, theta.gen/2, 1)
#y2 = rnorm(20, -theta.gen/2, 1)
#implement.twot.right = implement.MSPRT(obs1 = y1, obs2 = y2,
#                                       design.MSPRT.object = design.twot.right)

#### left sided ####
### design
#design.twot.left = design.MSPRT(test.type = 'twoT', side = 'left',
#                                N1.max = 20, N2.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y1 = rnorm(20, theta.gen/2, 1)
#y2 = rnorm(20, -theta.gen/2, 1)
#implement.twot.left = implement.MSPRT(obs1 = y1, obs2 = y2,
#                                      design.MSPRT.object = design.twot.left)

#### both sided ####
### design
#design.twot.both = design.MSPRT(test.type = 'twoT', side = 'both',
#                                N1.max = 20, N2.max = 20)

### implementation
#set.seed(1)
#theta.gen = 0  # change effect size to experiment
#y1 = rnorm(20, theta.gen/2, 1)
#y2 = rnorm(20, -theta.gen/2, 1)
#implement.twot.both = implement.MSPRT(obs1 = y1, obs2 = y2,
#                                      design.MSPRT.object = design.twot.both)

[Package MSPRT version 3.0 Index]