From f0fbe12d0700fd274efe1ab44993d0487fabd9d7 Mon Sep 17 00:00:00 2001 From: karissawhiting Date: Fri, 7 Apr 2023 14:03:00 -0400 Subject: [PATCH 1/2] simon 2 stage roxygen --- DESCRIPTION | 3 ++ R/ph2simon.R | 53 +++++++++++++++++++++++++++++++++ man/ph2simon.Rd | 78 ++++++++++++++++++++++++------------------------- 3 files changed, 94 insertions(+), 40 deletions(-) mode change 100755 => 100644 man/ph2simon.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 66a77bc..13cb2e5 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,3 +19,6 @@ Maintainer: Venkatraman E. Seshan License: GPL (>= 2) NeedsCompilation: yes VignetteBuilder: knitr +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.2.3 +Encoding: UTF-8 diff --git a/R/ph2simon.R b/R/ph2simon.R index 82dba4e..9a579e6 100755 --- a/R/ph2simon.R +++ b/R/ph2simon.R @@ -1,3 +1,37 @@ +#' Simon's 2-stage Phase II design +#' +#' Calculates Optimal and Minimax 2-stage Phase II designs given by Richard +#' Simon +#' +#' @aliases ph2simon print.ph2simon plot.ph2simon +#' @param pu unacceptable response rate +#' @param pa response rate that is desirable +#' @param ep1 threshold for the probability of declaring drug desirable under +#' p0 +#' @param ep2 threshold for the probability of rejecting the drug under p1 +#' @param nmax maximum total sample size (default 100; can be at most 500) +#' @return ph2simon returns a list with pu, pa, alpha, beta and nmax as above +#' and: \item{out}{matrix of best 2 stage designs for each value of total +#' sample size n. the 6 columns are: r1, n1, r, n, EN(p0), PET(p0)} +#' +#' Trial is stopped early if <= r1 responses are seen in the first stage and +#' treatment is considered desirable only when >r responses seen. +#' +#' The "print" method formats and returns the minimax and optimal designs. +#' +#' @seealso \code{\link{twostage.inference}}, \code{\link{oc.twostage.bdry}} +#' @references Simon R. (1989). Optimal Two-Stage Designs for Phase II +#' Clinical Trials. \emph{Controlled Clinical Trials} 10, 1-10. +#' +#' Jung SH, Carey M and Kim KM. (2001). Graphical Search for Two-Stage Designs +#' for Phase II Clinical Trials. \emph{Controlled Clinical Trials} 22, 367-372. +#' @keywords design design +#' @examples +#' +#' ph2simon(0.2, 0.4, 0.1, 0.1) +#' ph2simon(0.2, 0.35, 0.05, 0.05) +#' ph2simon(0.2, 0.35, 0.05, 0.05, nmax=150) +#' ph2simon <- function(pu, pa, ep1, ep2, nmax = 100) { if(nmax > 1000) stop("nmax cannot exceed 1000") nmax1 <- nmax + 1 @@ -46,6 +80,15 @@ ph2simon <- function(pu, pa, ep1, ep2, nmax = 100) { ph2 } +#' Title +#' +#' @param x +#' @param ... +#' +#' @return +#' @export +#' +#' @examples print.ph2simon <- function(x, ...) { xout <- x$out nmax <- x$nmax @@ -62,6 +105,16 @@ print.ph2simon <- function(x, ...) { if(xopt[1,4]>nmax-10) warning(paste(" Optimal sample size too close to nmax. \n Try increasing nmax (current value = ",nmax,")\n",sep="")) } +#' Plots `ph2simon` object +#' +#' @param x object returned by ph2simon +#' @param ... arguments to be passed onto plot and print commands called within +#' +#' @return Plots the expected sample size agains the maximum sample size as in +#' Jung et al., 2001 +#' @export +#' +#' @examples plot.ph2simon <- function(x, ...) { xout <- x$out n <- nrow(xout) diff --git a/man/ph2simon.Rd b/man/ph2simon.Rd old mode 100755 new mode 100644 index a7c02ce..967720a --- a/man/ph2simon.Rd +++ b/man/ph2simon.Rd @@ -1,62 +1,60 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ph2simon.R \name{ph2simon} -\title{Simon's 2-stage Phase II design} \alias{ph2simon} \alias{print.ph2simon} \alias{plot.ph2simon} -\keyword{design} -\description{ - Calculates Optimal and Minimax 2-stage Phase II designs given by - Richard Simon -} +\title{Simon's 2-stage Phase II design} \usage{ -ph2simon(pu, pa, ep1, ep2, nmax=100) -\method{print}{ph2simon}(x, \dots) -\method{plot}{ph2simon}(x, \dots) +ph2simon(pu, pa, ep1, ep2, nmax = 100) } \arguments{ - \item{pu}{unacceptable response rate} - \item{pa}{response rate that is desirable} - \item{ep1}{threshold for the probability of declaring drug desirable - under p0} - \item{ep2}{threshold for the probability of rejecting the drug under - p1} - \item{nmax}{maximum total sample size (default 100; can be at most - 500)} - \item{x}{object returned by ph2simon} - \item{...}{arguments to be passed onto plot and print commands called - within} +\item{pu}{unacceptable response rate} + +\item{pa}{response rate that is desirable} + +\item{ep1}{threshold for the probability of declaring drug desirable under +p0} + +\item{ep2}{threshold for the probability of rejecting the drug under p1} + +\item{nmax}{maximum total sample size (default 100; can be at most 500)} + +\item{x}{object returned by ph2simon} + +\item{...}{arguments to be passed onto plot and print commands called within} } \value{ - ph2simon returns a list with pu, pa, alpha, beta and nmax as above - and: - \item{out}{matrix of best 2 stage designs for each value of total - sample size n. the 6 columns are: r1, n1, r, n, EN(p0), PET(p0)} +ph2simon returns a list with pu, pa, alpha, beta and nmax as above +and: \item{out}{matrix of best 2 stage designs for each value of total +sample size n. the 6 columns are: r1, n1, r, n, EN(p0), PET(p0)} - Trial is stopped early if <= r1 responses are seen in the first stage - and treatment is considered desirable only when >r responses seen. +Trial is stopped early if <= r1 responses are seen in the first stage and +treatment is considered desirable only when >r responses seen. - The "print" method formats and returns the minimax and optimal - designs. The "plot" plots the expected sample size agains the maximum - sample size as in Jung et al., 2001 +The "print" method formats and returns the minimax and optimal designs. The +"plot" plots the expected sample size agains the maximum sample size as in +Jung et al., 2001 } - -\seealso{ - \code{\link{twostage.inference}}, \code{\link{oc.twostage.bdry}} +\description{ +Calculates Optimal and Minimax 2-stage Phase II designs given by Richard +Simon } - \examples{ + ph2simon(0.2, 0.4, 0.1, 0.1) ph2simon(0.2, 0.35, 0.05, 0.05) ph2simon(0.2, 0.35, 0.05, 0.05, nmax=150) -} +} \references{ - Simon R. (1989). Optimal Two-Stage Designs for Phase II Clinical - Trials. \emph{Controlled Clinical Trials} 10, 1-10. +Simon R. (1989). Optimal Two-Stage Designs for Phase II +Clinical Trials. \emph{Controlled Clinical Trials} 10, 1-10. - Jung SH, Carey M and Kim KM. (2001). Graphical Search for Two-Stage - Designs for Phase II Clinical Trials. \emph{Controlled Clinical - Trials} 22, 367-372. +Jung SH, Carey M and Kim KM. (2001). Graphical Search for Two-Stage Designs +for Phase II Clinical Trials. \emph{Controlled Clinical Trials} 22, 367-372. +} +\seealso{ +\code{\link{twostage.inference}}, \code{\link{oc.twostage.bdry}} } - \keyword{design} From d3950452e7fb37a0ae53207247d9b6e2658ac364 Mon Sep 17 00:00:00 2001 From: karissawhiting Date: Fri, 7 Apr 2023 14:44:51 -0400 Subject: [PATCH 2/2] Update plot and print docs for ph2simon --- R/ph2simon.R | 29 +++++++++++++---------------- man/ph2simon.Rd | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/R/ph2simon.R b/R/ph2simon.R index 9a579e6..8884a0b 100755 --- a/R/ph2simon.R +++ b/R/ph2simon.R @@ -3,23 +3,22 @@ #' Calculates Optimal and Minimax 2-stage Phase II designs given by Richard #' Simon #' -#' @aliases ph2simon print.ph2simon plot.ph2simon #' @param pu unacceptable response rate #' @param pa response rate that is desirable #' @param ep1 threshold for the probability of declaring drug desirable under #' p0 #' @param ep2 threshold for the probability of rejecting the drug under p1 #' @param nmax maximum total sample size (default 100; can be at most 500) -#' @return ph2simon returns a list with pu, pa, alpha, beta and nmax as above +#' @return `ph2simon()` returns a list with pu, pa, alpha, beta and nmax as above #' and: \item{out}{matrix of best 2 stage designs for each value of total #' sample size n. the 6 columns are: r1, n1, r, n, EN(p0), PET(p0)} #' #' Trial is stopped early if <= r1 responses are seen in the first stage and #' treatment is considered desirable only when >r responses seen. #' -#' The "print" method formats and returns the minimax and optimal designs. #' -#' @seealso \code{\link{twostage.inference}}, \code{\link{oc.twostage.bdry}} +#' @seealso [twostage.inference] [oc.twostage.bdry] +#' @family ph2simon #' @references Simon R. (1989). Optimal Two-Stage Designs for Phase II #' Clinical Trials. \emph{Controlled Clinical Trials} 10, 1-10. #' @@ -28,9 +27,9 @@ #' @keywords design design #' @examples #' -#' ph2simon(0.2, 0.4, 0.1, 0.1) -#' ph2simon(0.2, 0.35, 0.05, 0.05) -#' ph2simon(0.2, 0.35, 0.05, 0.05, nmax=150) +#' ph2simon(0.2, 0.4, 0.1, 0.1) +#' ph2simon(0.2, 0.35, 0.05, 0.05) +#' ph2simon(0.2, 0.35, 0.05, 0.05, nmax=150) #' ph2simon <- function(pu, pa, ep1, ep2, nmax = 100) { if(nmax > 1000) stop("nmax cannot exceed 1000") @@ -80,15 +79,8 @@ ph2simon <- function(pu, pa, ep1, ep2, nmax = 100) { ph2 } -#' Title -#' -#' @param x -#' @param ... -#' -#' @return +#' @rdname ph2simon #' @export -#' -#' @examples print.ph2simon <- function(x, ...) { xout <- x$out nmax <- x$nmax @@ -110,11 +102,16 @@ print.ph2simon <- function(x, ...) { #' @param x object returned by ph2simon #' @param ... arguments to be passed onto plot and print commands called within #' -#' @return Plots the expected sample size agains the maximum sample size as in +#' @return `plot.ph2simon()` returns a plot with the expected sample size against the maximum sample size as in #' Jung et al., 2001 +#' @family ph2simon +#' @rdname ph2simon #' @export #' #' @examples +#' ex <- ph2simon(0.2, 0.4, 0.1, 0.1) +#' plot(ex) +#' plot.ph2simon <- function(x, ...) { xout <- x$out n <- nrow(xout) diff --git a/man/ph2simon.Rd b/man/ph2simon.Rd index 967720a..6d89a5f 100644 --- a/man/ph2simon.Rd +++ b/man/ph2simon.Rd @@ -7,6 +7,10 @@ \title{Simon's 2-stage Phase II design} \usage{ ph2simon(pu, pa, ep1, ep2, nmax = 100) + +\method{print}{ph2simon}(x, ...) + +\method{plot}{ph2simon}(x, ...) } \arguments{ \item{pu}{unacceptable response rate} @@ -32,8 +36,7 @@ sample size n. the 6 columns are: r1, n1, r, n, EN(p0), PET(p0)} Trial is stopped early if <= r1 responses are seen in the first stage and treatment is considered desirable only when >r responses seen. -The "print" method formats and returns the minimax and optimal designs. The -"plot" plots the expected sample size agains the maximum sample size as in +Plots the expected sample size against the maximum sample size as in Jung et al., 2001 } \description{ @@ -42,9 +45,12 @@ Simon } \examples{ - ph2simon(0.2, 0.4, 0.1, 0.1) - ph2simon(0.2, 0.35, 0.05, 0.05) - ph2simon(0.2, 0.35, 0.05, 0.05, nmax=150) +ph2simon(0.2, 0.4, 0.1, 0.1) +ph2simon(0.2, 0.35, 0.05, 0.05) +ph2simon(0.2, 0.35, 0.05, 0.05, nmax=150) + +ex <- ph2simon(0.2, 0.4, 0.1, 0.1) +plot(ex) } \references{ @@ -55,6 +61,7 @@ Jung SH, Carey M and Kim KM. (2001). Graphical Search for Two-Stage Designs for Phase II Clinical Trials. \emph{Controlled Clinical Trials} 22, 367-372. } \seealso{ -\code{\link{twostage.inference}}, \code{\link{oc.twostage.bdry}} +\link{twostage.inference} \link{oc.twostage.bdry} } +\concept{ph2simon} \keyword{design}