r_simon {VisualizeSimon2Stage}R Documentation

Random Generator based on Simon's Two-Stage Design

Description

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

Usage

r_simon(R, n1, n, r1, prob)

Arguments

R

positive integer scalar, number of trials RR

n1, n

positive integer scalars, Stage-1 sample size n1n_1 and total sample size nn

r1

non-negative integer scalar, number of response in Stage-1 r1r_1 required exclusively, i.e., passing Stage-1 indicates observing >r1>r_1 responses

prob

double scalar, true response rate pp

Details

Function r_simon generates RR copies of the number of responses yy in the Simon's two-stage design. The conclusion of the trials are,

yr1y \leq r_1

indicates early termination

r1<yrr_1 < y \leq r

indicates failure to reject H0H_0

y>ry > r

indicates success to reject H0H_0

Here rr is not needed to generate the random number of responses yy. Instead, rr is needed to determine if the trial is a failure or a success. Therefore, rr is not a parameter in r_simon.

Value

Function r_simon returns an integer vector of length RR, which are the RR copies of the number of responses in the Simon's two-stage design.

Examples

library(clinfun)
ph2simon(pu = .2, pa = .4, ep1 = .05, ep2 = .1) # using 'Optimal'
# set.seed if needed 
(ys = r_simon(R = 10L, n1 = 19L, n = 54L, r1 = 4L, prob = .3))
table(cut.default(ys, breaks = c(0, 4L, 15L, 54L), right = TRUE,
  labels = c('early-termination', 'fail', 'success')))


[Package VisualizeSimon2Stage version 0.1.5 Index]