Learn R Programming

MSPRT (version 2.1)

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

Description

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

Usage

ovr.repl.oneProp(error.type, batch.seq, null, gen.par, alt.LR, alt.psi,
                 up, low, N, 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.

batch.seq

a numeric vector; an increasing sequence of values until N. Denotes the sequence of sample sizes where a user will observe data sequentially.

Last element should equal to N.

null

a numeric in (0,1); the hypothesized value of proportion under the simple null hypothesis.

gen.par

a numeric; the value of proportion from which the data needs to be generated from.

alt.LR

a numeric vector of lenth 2; this consists of the 2 UMPBT alternative points. The sequence of weighted likelihood ratios (\(L_n\)) is computed in favour of this alternative.

This is same with the output u from umpbt.oneProp().

alt.psi

a numeric in (0,1); the mixing probability corresponding to the first component of alt.LR in the UMPBT alternative.

This is same with the output psi from umpbt.oneProp().

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.

N

a positive numeric (integer); number of samples where truncation of Wald's SPRT is required.

In a MSPRT, this is the maximum available sample size.

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 {
N.max = 30
ovr.repl.oneProp( error.type= "type1", batch.seq= 1:N.max, null= 0.5, gen.par= 0.5,
                  alt.LR= c(0.5,0.55), alt.psi= 0.4, up= 160, low= 0.2, N= N.max,
                  seed= 1)
               
ovr.repl.oneProp( error.type= "type2", batch.seq= 1:N.max, null= 0.5, gen.par= 0.7,
                  alt.LR= c(0.5,0.55), alt.psi= 0.4, up= 160, low= 0.2, N= N.max, 
                  seed= 1)

# }

Run the code above in your browser using DataLab