Learn R Programming

VisualizeSimon2Stage (version 0.1.5)

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, n1, n, r1, prob)

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\)

n1, n

positive integer scalars, Stage-1 sample size \(n_1\) and total sample size \(n\)

r1

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

prob

double scalar, true response rate \(p\)

Details

Function r_simon generates \(R\) copies of the number of responses \(y\) in the 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 in r_simon.

Examples

Run this code
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')))

Run the code above in your browser using DataLab