-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating DESCRIPTION to add links to GitHub site
- Loading branch information
Michael J. Grayling
committed
May 14, 2018
0 parents
commit fb828c3
Showing
109 changed files
with
17,287 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^build-history$ | ||
^README\.Rmd$ | ||
^README-.*\.png$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Package: singlearm | ||
Type: Package | ||
Title: Design and analysis of single-arm clinical trials | ||
Version: 1.0 | ||
Authors@R: c(person(given = "Michael", family = "Grayling", | ||
email = "[email protected]", | ||
role = c("aut", "cre"))) | ||
Description: This package provides a suite of functions for designing, | ||
analysing, and visualising single-arm clinical trials. | ||
License: GPL-3 | ||
Encoding: UTF-8 | ||
LazyData: true | ||
Depends: R (>= 3.3.2) | ||
Imports: Rcpp (>= 0.12.14), | ||
tibble, | ||
dplyr, | ||
ggplot2 (>= 2.2.1), | ||
ggthemes, | ||
iterpc | ||
Enhances: clinfun, OneArmPhaseTwoStudy | ||
LinkingTo: Rcpp | ||
Date: 2018-03-24 | ||
URL: http://github.com/mjg211/singlearm | ||
BugReports: http://github.com/mjg211/singlearm/issues | ||
RoxygenNote: 6.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
S3method(plot,sa_ci_fixed) | ||
S3method(plot,sa_ci_gs) | ||
S3method(plot,sa_des_adaptive) | ||
S3method(plot,sa_des_admissable) | ||
S3method(plot,sa_des_bayesfreq) | ||
S3method(plot,sa_des_curtailed) | ||
S3method(plot,sa_des_fixed) | ||
S3method(plot,sa_des_gs) | ||
S3method(plot,sa_est_fixed) | ||
S3method(plot,sa_est_gs) | ||
S3method(plot,sa_opchar_adaptive) | ||
S3method(plot,sa_opchar_admissable) | ||
S3method(plot,sa_opchar_bayesfreq) | ||
S3method(plot,sa_opchar_curtailed) | ||
S3method(plot,sa_opchar_fixed) | ||
S3method(plot,sa_opchar_gs) | ||
S3method(plot,sa_pval_fixed) | ||
S3method(plot,sa_pval_gs) | ||
export(ci_fixed) | ||
export(ci_gs) | ||
export(des_adaptive) | ||
export(des_admissable) | ||
export(des_bayesfreq) | ||
export(des_curtailed) | ||
export(des_fixed) | ||
export(des_gehan) | ||
export(des_gs) | ||
export(est_fixed) | ||
export(est_gs) | ||
export(opchar_adaptive) | ||
export(opchar_admissable) | ||
export(opchar_bayesfreq) | ||
export(opchar_curtailed) | ||
export(opchar_fixed) | ||
export(opchar_gs) | ||
export(pval_fixed) | ||
export(pval_gs) | ||
importFrom(Rcpp,sourceCpp) | ||
useDynLib(singlearm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
News: singlearm | ||
|
||
Version 1.0 | ||
|
||
- Package launched with support for the design, analysis, and visualisation of | ||
single-stage and group sequential single-arm clinical trials with a single | ||
binary endpoint (des_fixed(), opchar_fixed(), est_fixed(), ci_fixed(), | ||
pval_fixed(), des_gs(), opchar_gs(), est_gs(), ci_gs(), pval_gs(), | ||
des_admissable(), opchar_admissable(), and their associated S3 plotting | ||
functions). Support is also available for the design and visualisation of | ||
adaptive two-stage, bayesian-frequentist, two-stage Gehan, and curtailed | ||
single-arm trials with a single binary endpoint (des_adaptive(), | ||
opchar_adaptive(), des_bayesfreq(), opchar_bayesfreq(), des_gehan(), | ||
des_curtailed(), opchar_curtailed(), and their associated S3 | ||
plotting functions). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# News: singlearm | ||
|
||
## Version 1.0 | ||
|
||
- Package launched with support for the design, analysis, and visualisation of | ||
single-stage and group sequential single-arm clinical trials with a single | ||
binary endpoint (`des_fixed()`, `opchar_fixed()`, `est_fixed()`, `ci_fixed()`, | ||
`pval_fixed()`, `des_gs()`, `opchar_gs()`, `est_gs()`, `ci_gs()`, `pval_gs()`, | ||
`des_admissable()`, `opchar_admissable()`, and their associated S3 plotting | ||
functions). Support is also available for the design and visualisation of | ||
adaptive two-stage, bayesian-frequentist, two-stage Gehan, and curtailed | ||
single-arm trials with a single binary endpoint (`des_adaptive()`, | ||
`opchar_adaptive()`, `des_bayesfreq()`, `opchar_bayesfreq()`, `des_gehan()`, `des_curtailed()`, `opchar_curtailed()`, and their associated | ||
S3 plotting functions). |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by using Rcpp::compileAttributes() -> do not edit by hand | ||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
saBivariateBD <- function(J, alphaR, alphaT, beta, Nmin, Nmax, equal_n, dbivar_00_list, dbivar_01_list, dbivar_10_list, dbivar_11_min_list, dbivar_11_max_list, summary) { | ||
.Call('_singlearm_saBivariateBD', PACKAGE = 'singlearm', J, alphaR, alphaT, beta, Nmin, Nmax, equal_n, dbivar_00_list, dbivar_01_list, dbivar_10_list, dbivar_11_min_list, dbivar_11_max_list, summary) | ||
} | ||
|
||
saBivariateCP <- function(J, alphaL, alphaG, beta, Nmin, Nmax, equal_n, dbivar_00_list, dbivar_01_list, dbivar_10_list, dbivar_11_list, dbivar_max1_list, dbivar_max2_list, summary) { | ||
.Call('_singlearm_saBivariateCP', PACKAGE = 'singlearm', J, alphaL, alphaG, beta, Nmin, Nmax, equal_n, dbivar_00_list, dbivar_01_list, dbivar_10_list, dbivar_11_list, dbivar_max1_list, dbivar_max2_list, summary) | ||
} | ||
|
||
saGS <- function(J, pi0, pi1, alpha, beta, Nmin, Nmax, futility, efficacy, equal_n, ensign, summary) { | ||
.Call('_singlearm_saGS', PACKAGE = 'singlearm', J, pi0, pi1, alpha, beta, Nmin, Nmax, futility, efficacy, equal_n, ensign, summary) | ||
} | ||
|
||
saVariable <- function(J, pi0, pi1, alpha, beta, v, Nmin, Nmax, equal_n) { | ||
.Call('_singlearm_saVariable', PACKAGE = 'singlearm', J, pi0, pi1, alpha, beta, v, Nmin, Nmax, equal_n) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
#' Determine confidence intervals in a single-stage single-arm trial design for | ||
#' a single binary endpoint | ||
#' | ||
#' Determines all possible confidence intervals at the end of a single-stage | ||
#' single-arm trial for a single binary endpoint, as determined | ||
#' using \code{des_fixed()}. Support is available to compute confidence | ||
#' intervals using the Agresti-Coull, Clopper-Pearson, Jeffreys, Mid-p, Wald, | ||
#' and Wilson Score approaches. | ||
#' | ||
#' In addition, the performance of the chosen confidence interval determination | ||
#' procedures (including their coverage and expected length) for each value of | ||
#' \ifelse{html}{\out{<i>pi</i>}}{\eqn{\pi}} in the supplied vector | ||
#' \ifelse{html}{\out{<b><i>pi</i></b>}}{\eqn{\bold{\pi}}}, will also be | ||
#' evaluated. | ||
#' | ||
#' @param des An object of class \code{"sa_des_fixed"}, as returned by | ||
#' \code{des_fixed()}. | ||
#' @param pi A vector of response probabilities to evaluate the expected | ||
#' performance of the confidence interval calculation procedure at. This will | ||
#' internally default to be the | ||
#' \ifelse{html}{\out{<i>π</i><sub>0</sub>}}{\deqn{\pi_0}} and | ||
#' \ifelse{html}{\out{<i>π</i><sub>1</sub>}}{\deqn{\pi_1}} from \code{des} if | ||
#' it is left unspecified. | ||
#' @param alpha \ifelse{html}{\out{<i>α</i>}}{\deqn{\alpha}}-level to use | ||
#' in confidence interval construction. Defaults to the value of | ||
#' \ifelse{html}{\out{<i>α</i>}}{\deqn{\alpha}} used in the construction | ||
#' of \code{des} (i.e., \code{des$alpha}). | ||
#' @param method A vector of methods to use to construct p-values. Currently, | ||
#' support is available to use the Agresti-Coull (\code{"agresti_coull"}), | ||
#' Clopper-Pearson (\code{"clopper_pearson"}), Jeffreys (\code{"jeffreys"}), | ||
#' Mid-p (\code{"mid_p"}), Wald (\code{"wald"}), and Wilson Score | ||
#' (\code{"wilson"}) approaches to confidence interval determination. | ||
#' @param summary A logical variable indicating whether a summary of the | ||
#' function's progress should be printed to the console. | ||
#' @return A list of class \code{"sa_ci_fixed"} containing the following | ||
#' elements | ||
#' \itemize{ | ||
#' \item A tibble in the slot \code{$ci} summarising the possible confidence | ||
#' intervals at the end of the trial for the supplied design, according to the | ||
#' chosen methods. | ||
#' \item A tibble in the slot \code{$perf} summarising the performance of the | ||
#' chosen confidence interval determination procedures for each specified value | ||
#' of \ifelse{html}{\out{<i>π</i>}}{\deqn{\pi}}. | ||
#' \item Each of the input variables as specified, subject to internal | ||
#' modification. | ||
#' } | ||
#' @examples | ||
#' # Find the optimal single-stage design for the default parameters | ||
#' des <- des_fixed() | ||
#' # Determine the performance of all supported confidence interval | ||
#' # determination procedures for a range of possible response probabilities | ||
#' ci <- ci_fixed(des, pi = seq(0, 1, 0.01)) | ||
#' @seealso \code{\link{des_fixed}}, \code{\link{opchar_fixed}}, | ||
#' \code{\link{est_fixed}}, \code{\link{pval_fixed}}, and their associated | ||
#' \code{plot} family of functions. | ||
#' @export | ||
ci_fixed <- function(des, pi, alpha = des$alpha, | ||
method = c("agresti_coull", "clopper_pearson", "jeffreys", | ||
"mid_p", "wald", "wilson"), summary = F) { | ||
|
||
##### Input Checking ######################################################### | ||
|
||
check_sa_des_fixed(des, "des") | ||
check_real_range_strict(alpha, "alpha", c(0, 1), 1) | ||
if (!missing(pi)) { | ||
check_pi(pi, "any") | ||
} else { | ||
pi <- c(des$des$pi0, des$des$pi1) | ||
} | ||
check_belong(method, "method", c("agresti_coull", "clopper_pearson", | ||
"jeffreys", "mid_p", "wald", "wilson"), | ||
"any") | ||
check_logical(summary, "summary") | ||
|
||
##### Print Summary ########################################################## | ||
|
||
if (summary){ | ||
message(rep("-", 10)) | ||
message("Confidence interval determination for single-stage single-arm trials with a single binary endpoint") | ||
message(rep("-", 10)) | ||
Sys.sleep(2) | ||
message("You have chosen to use the following methods to construct confidence intervals\n") | ||
if ("aggresti_coull" %in% method) { | ||
message(" • Aggresti-Coull.") | ||
} | ||
if ("clopper_pearson" %in% method) { | ||
message(" • Clopper-Pearson.") | ||
} | ||
if ("jeffreys" %in% method) { | ||
message(" • Jeffreys.") | ||
} | ||
if ("mid_p" %in% method) { | ||
message(" • Mid-p.") | ||
} | ||
if ("wald" %in% method) { | ||
message(" • Wald.") | ||
} | ||
if ("wilson" %in% method) { | ||
message(" • Wilson.") | ||
} | ||
Sys.sleep(2) | ||
message("\nNow beginning the required calculations...") | ||
} | ||
|
||
##### Main Computations ###################################################### | ||
|
||
ci <- tibble::tibble(s = rep(0:des$des$n, each = length(method)), | ||
m = rep(des$des$n, (des$des$n + 1)*length(method)), | ||
method = factor(rep(method, des$des$n + 1), | ||
levels = method), `clow(s,m)` = NA, | ||
`cupp(s,m)` = NA) | ||
for (i in 1:nrow(ci)) { | ||
ci[i, 4:5] <- switch(as.character(ci$method[i]), | ||
agresti_coull = ci_fixed_agresti_coull(ci$s[i], | ||
ci$m[i], | ||
alpha), | ||
clopper_pearson = ci_fixed_clopper_pearson(ci$s[i], | ||
ci$m[i], | ||
alpha), | ||
jeffreys = ci_fixed_jeffreys(ci$s[i], ci$m[i], | ||
alpha), | ||
mid_p = ci_fixed_mid_p(ci$s[i], ci$m[i], | ||
alpha), | ||
wald = ci_fixed_wald(ci$s[i], ci$m[i], | ||
alpha), | ||
wilson = ci_fixed_wilson(ci$s[i], ci$m[i], | ||
alpha)) | ||
if (all(summary, i%%100 == 0)) { | ||
message("...", i, " confidence intervals determined...") | ||
} | ||
} | ||
ci <- dplyr::mutate(ci, `l(s,m)` = `cupp(s,m)` - `clow(s,m)`) | ||
len_pi <- length(pi) | ||
pmf <- pmf_fixed(pi, des$des$n) | ||
perf <- tibble::tibble(pi = rep(pi, length(method)), | ||
method = factor(rep(method, each = len_pi), method), | ||
`bar(L)` = NA, `max(L)` = NA, `E(L|pi)` = NA, | ||
`Var(L|pi)` = NA, `Cover(C|pi)` = 0) | ||
for (i in 1:nrow(perf)) { | ||
ci_i <- dplyr::filter(ci, method == perf$method[i]) | ||
pmf_i <- dplyr::filter(pmf, pi == perf$pi[i]) | ||
perf$`E(L|pi)`[i] <- sum(pmf_i$`f(s,m|pi)`*ci_i$`l(s,m)`) | ||
perf$`Var(L|pi)`[i] <- sum(pmf_i$`f(s,m|pi)`*ci_i$`l(s,m)`^2) - | ||
perf$`E(L|pi)`[i]^2 | ||
perf$`bar(L)`[i] <- mean(ci_i$`l(s,m)`) | ||
perf$`max(L)`[i] <- max(ci_i$`l(s,m)`) | ||
coverage <- dplyr::filter(ci_i, `clow(s,m)` <= perf$pi[i] & | ||
`cupp(s,m)` >= perf$pi[i]) | ||
if (nrow(coverage) > 0) { | ||
perf$`Cover(C|pi)`[i] <- sum(dplyr::filter(pmf_i, | ||
s %in% coverage$s)$`f(s,m|pi)`) | ||
} | ||
if (all(summary, i%%100 == 0)) { | ||
message("...performance for ", i, " pi-method combinations evaluated...") | ||
} | ||
} | ||
|
||
##### Outputting ############################################################# | ||
|
||
if (summary) { | ||
message("...outputting.") | ||
} | ||
output <- list(ci = ci, perf = perf, des = des, pi = pi, alpha = alpha, | ||
summary = summary) | ||
class(output) <- "sa_ci_fixed" | ||
return(output) | ||
} |
Oops, something went wrong.