Learn R Programming

MSPRT (version 2.1)

overshoot.twoT: Error summary of the truncated Wald's SPRT in two-sample T-tests

Description

MSPRT is designed on the assumption that we can afford at most, say, N samples. This function calculates a summary of the Type 1 or Type 2 error committed by the Wald's SPRT when it is simply truncated at N in two-sample T-tests. This is done using parallel computation.

It is worth a mention that a case may remain inconclusive due to the truncation. The required sample size for reaching that decision is N.

Usage

overshoot.twoT(side, error.type, batch1.seq, batch2.seq, type1, gen.par,
               up, low, N1, N2, R, core.no, return.n = T)

Arguments

side

a character; direction of the alternative hypothesis H1.

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

error.type

a character; specifies which of the 2 types of errors need to be accounted for.

"type1" for Type 1 error.

"type2" for Type 2 error.

batch1.seq

a numeric vector; an increasing sequence of values until N1. Denotes the sequence of sample sizes where data is observed sequentially from Group-1.

First element should be at least 2. Last element should equal be to N1.

batch2.seq

a numeric vector; an increasing sequence of values until N2. Denotes the sequence of sample sizes where data is observed sequentially from Group-2.

First element should be at least 2. Last element should equal be to N2.

type1

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

gen.par

a numeric; observations from Group-1 and 2 are generated from the normal distributions with common variance 1, and means -gen.par and gen.par, respectively.

up

a numeric; value of a constant rejection threshold. Should be greater than low.

low

a numeric; value of a constant acceptance threshold. Should be smaller than up.

N1

a positive numeric (integer); maximum available number of samples from Group-1.

N2

a positive numeric (integer); maximum available number of samples from Group-2.

R

a positive numeric (integer); number of replications desired in the Monte Carlo study.

At least 1e+5 is required.

core.no

a numeric; number of cores this function can use for carrying out the Monte Carlo study using the parallel computing.

return.n

logical; if TRUE, this returns a vector of sample sizes required for reaching a decision in each of the R replications.

Value

If return.n = TRUE, a list with following components is returned:

count

a numeric; number of errors of error.type those are committed out of R replications.

inconclusive.vec

a numeric vector; a vector containing the likelihood ratio values at N which remained inconclusive at the last stage.

n.vec

a numeric vector; a vector of the required number of samples in each replications. This vector has length R.

If return.n = FALSE, the same list except n.vec is returned.

References

Wald, A., Sequential Tests of Statistical Hypotheses. Ann. of Math. Statist., vol. 16, no. 2, 1945, 117-186.

Examples

Run this code
# NOT RUN {
N1.max = 30
N2.max = 30
#overshoot.twoT( side="right", error.type= "type1", 
#                batch1.seq= 2:N1.max,  batch2.seq= 2:N2.max,
#                type1= 0.005, gen.par= 0, up= 160, low= 0.2,
#                N1= N1.max, N2= N2.max, R= 1e+6, core.no= 2, return.n = T)

#overshoot.twoT( side="right", error.type= "type2", 
#                batch1.seq= 2:N1.max,  batch2.seq= 2:N2.max,
#                type1= 0.005, gen.par= 1, up= 160, low= 0.2,
#                N1= N1.max, N2= N2.max, R= 1e+6, core.no= 2, return.n = T)

# }

Run the code above in your browser using DataLab