Learn R Programming

MSPRT (version 2.1)

ovr.repl.twoZ: A particular replication step in overshoot.twoZ()

Description

In two-sample Z-tests this function simulates a data, computes the likelihood ratios, and compares with the acceptance and rejection thresholds. overshoot.twoZ() carries out a Monte Carlo method by repeating this function for R number of times.

Usage

ovr.repl.twoZ(error.type, batch1.seq, batch2.seq, alt.LR, gen.par,
              up, low, N1, N2, seed)

Arguments

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.

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.

Last element should equal be to N2.

gen.par

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

alt.LR

a numeric; the simple alternative in favor of which the likelihood ratios are calculated sequentially.

The UMPBT point alternative is used in case of a MSPRT. This is same with the output u from umpbt.twoZ().

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.

seed

a positive integer; used in set.seed() to recreate the simulated data.

Value

Returns a list with following components:

incr.count

either 0 or 1; 1 if and only if an error of error.type is made.

inconclusive

a numeric; the value of \(L_N\) if and only if it remains inconclusive after truncating Wald's SPRT at N; otherwise a numeric of length 0 is returned.

n

a numeric; number of samples required for reaching the decision. In an inconclusive case, this value is N.

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

## common sd 1

# both groups have mean 0
ovr.repl.twoZ( error.type= "type1", batch1.seq= 1:N1.max,  batch2.seq= 1:N2.max,
               gen.par= c(0,1), alt.LR = 1, up= 160, low= 0.2,
               N1= N1.max, N2= N2.max, seed= 1)

# Group-1 & 2 have mean -1 and 1, respectively
ovr.repl.twoZ( error.type= "type2", batch1.seq= 1:N1.max,  batch2.seq= 1:N2.max,
               gen.par= c(1,1), alt.LR = 1, up= 160, low= 0.2,
               N1= N1.max, N2= N2.max, seed= 1)

# }

Run the code above in your browser using DataLab