Learn R Programming

MSPRT (version 2.1)

overshoot.oneZ: Error summary of the truncated Wald's SPRT in one-sample Z-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 one-sample Z-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.oneZ(error.type, batch.seq, null, gen.par, alt.LR,
               up, low, N, R, core.no, return.n = T)

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; the hypothesized value of population mean under the simple null hypothesis.

gen.par

a numeric vector of length 2; the first component is the value of the population mean and second component is the known standard deviation (sd).

Observations are generated from a normal distribution with this mean and sd.

alt.LR

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

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

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.

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 values of \(L_N\) which remained inconclusive at the last stage

n.vec

a numeric vector; a vector of the required number of samples; this is of 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 {
N.max = 30
#overshoot.oneZ( error.type= "type1", batch.seq= 1:N.max, null= 0,
#                gen.par= c(0,1), alt.LR= 1, up= 160, low= 0.2, N= N.max,
#                R= 1e+6, core.no= 2, return.n = T)

#overshoot.oneZ( error.type= "type2", batch.seq= 1:N.max, null= 0,
#                gen.par= c(1.5,1), alt.LR= 1, up= 160, low= 0.2, N= N.max,
#                R= 1e+6, core.no= 2, return.n = T)
# }

Run the code above in your browser using DataLab