Title: | Visualize Simon's Two-Stage Design |
---|---|
Description: | To visualize the probabilities of early termination, fail and success of Simon's two-stage design. To evaluate and visualize the operating characteristics of Simon's two-stage design. |
Authors: | Tingting Zhan [aut, cre, cph] |
Maintainer: | Tingting Zhan <[email protected]> |
License: | GPL-2 |
Version: | 0.1.6 |
Built: | 2024-10-28 11:21:02 UTC |
Source: | CRAN |
Functions for visualizing the probabilities of early termination, fail and success of Simon's two-stage design. Functions for evaluating and visualizing the operating characteristics of Simon's two-stage design.
Maintainer: Tingting Zhan [email protected] (ORCID) [copyright holder]
doi:10.1016/0197-2456(89)90015-9
https://www.ncss.com/software/pass/
Plot ph2simon object using ggplot2.
## S3 method for class 'ph2simon' autoplot(object, ...) ## S3 method for class 'ph2simon' autolayer( object, type = c("minimax", "optimal", "n1", "maximax"), n1 = stop("must provide `n1`"), n = stop("must provide `n`"), r1 = stop("must provide `r1`"), r = stop("must provide `r`"), pu = stop("must provide `pu`"), pa = stop("must provide `pa`"), ... )
## S3 method for class 'ph2simon' autoplot(object, ...) ## S3 method for class 'ph2simon' autolayer( object, type = c("minimax", "optimal", "n1", "maximax"), n1 = stop("must provide `n1`"), n = stop("must provide `n`"), r1 = stop("must provide `r1`"), r = stop("must provide `r`"), pu = stop("must provide `pu`"), pa = stop("must provide `pa`"), ... )
object |
ph2simon object |
... |
potential parameters, currently not in use |
type |
character scalar, one of
|
n1 , n
|
(optional) integer scalars, Stage-1 sample size |
r1 , r
|
(optional) integer scalars, number of response
in Stage-1 |
pu , pa
|
Function autoplot.ph2simon returns a ggplot object.
Function autolayer.ph2simon returns a list of ggproto and labels.
library(clinfun) (x = ph2simon(pu = .2, pa = .4, ep1 = .05, ep2 = .1)) class(x) autoplot(x, type = 'minimax') autoplot(x, type = 'optimal') autoplot(x, type = 'n1') autoplot(x, type = 'maximax') # example with r1 = 0 (des = ph2simon(pu = .05, pa = .3, ep1 = .05, ep2 = .2)) autoplot(des, type = 'optimal') autoplot(des, type = 'minimax')
library(clinfun) (x = ph2simon(pu = .2, pa = .4, ep1 = .05, ep2 = .1)) class(x) autoplot(x, type = 'minimax') autoplot(x, type = 'optimal') autoplot(x, type = 'n1') autoplot(x, type = 'maximax') # example with r1 = 0 (des = ph2simon(pu = .05, pa = .3, ep1 = .05, ep2 = .2)) autoplot(des, type = 'optimal') autoplot(des, type = 'minimax')
An alternate print method for ph2simon object.
print_ph2simon(x, ...)
print_ph2simon(x, ...)
x |
a ph2simon object |
... |
additional parameters, currently not in use |
Function print_ph2simon does not have a returned value.
We do not overwrite function clinfun:::print.ph2simon
.
library(clinfun) (x = ph2simon(pu = .2, pa = .4, ep1 = .05, ep2 = .1)) print_ph2simon(x)
library(clinfun) (x = ph2simon(pu = .2, pa = .4, ep1 = .05, ep2 = .1)) print_ph2simon(x)
Random generator based on Simon's two-stage design.
r_simon(R, n1, n, r1, prob)
r_simon(R, n1, n, r1, prob)
R |
positive integer scalar, number of trials |
n1 , n
|
positive integer scalars, Stage-1 sample size |
r1 |
non-negative integer scalar, number of response
in Stage-1 |
prob |
double scalar, true response rate |
Function r_simon generates copies of the number of responses
in the Simon's two-stage design.
The conclusion of the trials are,
indicates early termination
indicates failure to reject
indicates success to reject
Here is not needed to generate the random number of responses
.
Instead,
is needed to determine if the trial is a failure or a success.
Therefore,
is not a parameter in r_simon.
Function r_simon returns an integer vector of length ,
which are the
copies of the number of responses in the Simon's two-stage design.
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')))
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')))
Operating characteristics of Simon's two-stage design.
Simon_oc( prob, simon, type = c("minimax", "optimal", "n1", "maximax"), R = 10000L, n1 = stop("must provide `n1`"), n = stop("must provide `n`"), r1 = stop("must provide `r1`"), r = stop("must provide `r`"), ... )
Simon_oc( prob, simon, type = c("minimax", "optimal", "n1", "maximax"), R = 10000L, n1 = stop("must provide `n1`"), n = stop("must provide `n`"), r1 = stop("must provide `r1`"), r = stop("must provide `r`"), ... )
prob |
named double vector,
true response rate(s) |
simon |
ph2simon object |
type |
character scalar, type of Simon's two-stage design.
Currently supports
|
R |
integer scalar, number of simulations. Default |
n1 , n
|
(optional) integer scalars, Stage-1 sample size |
r1 , r
|
(optional) integer scalars, number of response
in Stage-1 |
... |
potential parameters, currently not in use |
..
Function Simon_oc returns Simon_oc object.
maxResp
integer vector of same length as ,
the frequencies of each regime having maximum response.
The summation of
maxResp
is the number of simulation copies.
Simon_maxResp
integer vector of same length as ,
the frequencies of each regime having maximum response and success in Simon's two-stage trial.
library(clinfun) (x = ph2simon(pu = .2, pa = .4, ep1 = .05, ep2 = .1)) Simon_oc(prob = c(A = .3, B = .2, C = .15), simon = x, type = 'minimax', R = 1e3L) Simon_oc(prob = c(A = .3, B = .2, C = .15), simon = x, type = 'optimal', R = 1e3L)
library(clinfun) (x = ph2simon(pu = .2, pa = .4, ep1 = .05, ep2 = .1)) Simon_oc(prob = c(A = .3, B = .2, C = .15), simon = x, type = 'minimax', R = 1e3L) Simon_oc(prob = c(A = .3, B = .2, C = .15), simon = x, type = 'optimal', R = 1e3L)
Probability of frail (i.e., early termination), fail (to reject the null) and success (to reject the null) of a Simon's two-stage design, at given true response rate(s).
Simon_pr(prob, n1, n, r1, r)
Simon_pr(prob, n1, n, r1, r)
prob |
|
n1 , n
|
positive integer scalars, Stage-1 sample size |
r1 , r
|
non-negative integer scalars, number of response
in Stage-1 |
Given the Simon's two-stage design , for a response rate
, we have the number of Stage-1 positive responses
and the number of Stage-2 positive responses
.
Obviously
and
are independent.
The probability of early termination is .
The probability of failure to reject is
The probability of rejecting is
Parameters nomenclature of n1
, n
, r1
and r
follows that of
PASS and function ph2simon.
Function Simon_pr returns Simon_pr object.
.Data
ncol-3 double matrix, probability of frail
(i.e., early termination), fail (to reject the null) and success (to reject the null), at each
response rate given in
@prob
eN
numeric vector, expected sample size(s) for each of response rate(s)
prob
Simon_pr(prob = c(.2, .4), n1 = 15L, r1 = 3L, n = 24L, r = 7L)
Simon_pr(prob = c(.2, .4), n1 = 15L, r1 = 3L, n = 24L, r = 7L)
Summarize a Simon's two-stage design
## S3 method for class 'ph2simon' summary(object, ...)
## S3 method for class 'ph2simon' summary(object, ...)
object |
ph2simon object |
... |
potential parameters, currently not in use |
Function summary.ph2simon returns a list with three (3) elements
library(clinfun) (x = ph2simon(pu = .2, pa = .4, ep1 = .05, ep2 = .1)) summary(x)
library(clinfun) (x = ph2simon(pu = .2, pa = .4, ep1 = .05, ep2 = .1)) summary(x)