Learn R Programming

VisualizeSimon2Stage (version 0.1.7)

r_simon: Random Generator based on Simon's Two-Stage Design

Description

Random generator based on Simon's two-stage design.

Usage

r_simon(R, prob, object, ...)

# S3 method for ph2simon r_simon(R, prob, object, ...)

# S3 method for ph2simon4 r_simon( R, prob, object, ..., r1 = object@r1, n1 = object@n1, r = object@r, n = object@n )

Value

Function r_simon() returns an integer

vector of length \(R\), which are the \(R\) copies of the number of responses in the Simon's two-stage design.

Arguments

R

positive integer scalar, number of trials \(R\)

prob

double scalar, true response rate \(p\)

object

a ph2simon or ph2simon4 object

...

parameters of function ph2simon4(), most importantly type

r1, n1, r, n

(optional) integer scalars, see ph2simon4.

Details

Function r_simon() generates \(R\) copies of the number of responses \(y\) in one Simon's two-stage design. The conclusion of the trials are,

\(y \leq r_1\)

indicates early termination

\(r_1 < y \leq r\)

indicates failure to reject \(H_0\)

\(y > r\)

indicates success to reject \(H_0\)

Here \(r\) is not needed to generate the random number of responses \(y\). Instead, \(r\) is needed to determine if the trial is a failure or a success. Therefore, \(r\) is not a parameter of function r_simon().

Examples

Run this code
(x = clinfun::ph2simon(pu = .2, pa = .4, ep1 = .05, ep2 = .1)) 
set.seed(1532); r = r_simon(R = 1e2L, prob = .2, object = x)
set.seed(1532); r1 = r_simon.ph2simon4(R = 1e2L, prob = .2, r1 = 5L, n1 = 24L, r = 13L, n = 45L)
stopifnot(identical(r, r1))
table(attr(r, 'dx')) # look at beta, <10%
set.seed(24315); r2 = r_simon(R = 1e2L, prob = .4, object = x)
table(attr(r2, 'dx')) # look at alpha, <5%

Run the code above in your browser using DataLab