Learn R Programming

MSPRT (version 2.1)

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

Description

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

Usage

ovr.repl.twoT(side, error.type, batch1.seq, batch2.seq, type1, gen.par,
              up, low, N1, N2, seed)

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.

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
ovr.repl.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, seed= 1)

ovr.repl.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, seed= 1)

# }

Run the code above in your browser using DataLab