Skip to content

Commit b63d2a6

Browse files
committed
First commit adding support for Poisson outcomes
1 parent 4cf719e commit b63d2a6

File tree

132 files changed

+9482
-1192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+9482
-1192
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: multiarm
22
Type: Package
33
Title: Design of single- and multi-stage multi-arm clinical trials
4-
Version: 0.11.3
4+
Version: 0.12.0
55
Authors@R: c(person(given = "Michael J", family = "Grayling",
66
email = "[email protected]",
77
role = c("aut", "cre")))
@@ -42,6 +42,6 @@ Imports:
4242
tibble,
4343
tidyr,
4444
xml2
45-
Date: 2020-09-16
45+
Date: 2020-12-15
4646
URL: http://github.com/mjg211/multiarm
4747
BugReports: http://github.com/mjg211/multiarm/issues

NAMESPACE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,47 @@
22

33
S3method(plot,multiarm_des_dtl_bern)
44
S3method(plot,multiarm_des_dtl_norm)
5+
S3method(plot,multiarm_des_dtl_pois)
56
S3method(plot,multiarm_des_gs_bern)
67
S3method(plot,multiarm_des_gs_norm)
8+
S3method(plot,multiarm_des_gs_pois)
79
S3method(plot,multiarm_des_ss_bern)
810
S3method(plot,multiarm_des_ss_norm)
11+
S3method(plot,multiarm_des_ss_pois)
912
export(build_dtl_bern)
1013
export(build_dtl_norm)
14+
export(build_dtl_pois)
1115
export(build_gs_bern)
1216
export(build_gs_norm)
17+
export(build_gs_pois)
1318
export(build_ss_bern)
1419
export(build_ss_norm)
20+
export(build_ss_pois)
1521
export(des_dtl_bern)
1622
export(des_dtl_norm)
23+
export(des_dtl_pois)
1724
export(des_gs_bern)
1825
export(des_gs_norm)
26+
export(des_gs_pois)
1927
export(des_ss_bern)
2028
export(des_ss_norm)
29+
export(des_ss_pois)
2130
export(gui)
2231
export(opchar_dtl_bern)
2332
export(opchar_dtl_norm)
33+
export(opchar_dtl_pois)
2434
export(opchar_gs_bern)
2535
export(opchar_gs_norm)
36+
export(opchar_gs_pois)
2637
export(opchar_ss_bern)
2738
export(opchar_ss_norm)
39+
export(opchar_ss_pois)
2840
export(sim_dtl_bern)
2941
export(sim_dtl_norm)
42+
export(sim_dtl_pois)
3043
export(sim_gs_bern)
3144
export(sim_gs_norm)
45+
export(sim_gs_pois)
3246
export(sim_ss_bern)
3347
export(sim_ss_norm)
48+
export(sim_ss_pois)

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# multiarm 0.12
2+
3+
* Support added for clinical trials with Poisson distributed outcomes
4+
(`build_dtl_pois()`, `build_gs_pois()`, `build_ss_pois()`, `des_dtl_pois()`,
5+
`des_gs_pois()`, `des_ss_pois()`, `opchar_dtl_pois()`, `opchar_gs_pois()`,
6+
`opchar_ss_pois()`, `plot.multiarm_des_dtl_pois()`,
7+
`plot.multiarm_des_gs_pois()`, `plot.multiarm_des_ss_pois()`, `sim_dtl_pois()`,
8+
`sim_gs_pois()`, `sim_ss_pois()`).
9+
110
# multiarm 0.11
211

312
* Analysis functions removed; focus purely on design for now.

R/build_dtl_pois.R

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#' Build a multi-stage drop-the-losers multi-arm clinical trial for a Poisson
2+
#' distributed primary outcome
3+
#'
4+
#' \code{build_dtl_pois()} builds a multi-stage drop-the-losers multi-arm
5+
#' clinical trial design object assuming the primary outcome variable is
6+
#' Poisson distributed, like those returned by \code{\link{des_dtl_pois}}.
7+
#'
8+
#' @param n1 A \code{\link{numeric}} indicating the chosen value for
9+
#' \ifelse{html}{\out{<i>n</i><sub>1</sub>}}{\eqn{n_1}}, the total sample size
10+
#' required in stage one of the trial. Defaults to \code{147}.
11+
#' @param n10 A \code{\link{numeric}} indicating the chosen value for
12+
#' \ifelse{html}{\out{<i>n</i><sub>10</sub>}}{\eqn{n_{10}}}, the sample size
13+
#' required in the control arm in stage one of the trial. Defaults to \code{49}.
14+
#' @param e A \code{\link{numeric}} indicating the chosen value for
15+
#' \ifelse{html}{\out{<i>e</i>}}{\eqn{e}}, the critical rejection boundary for
16+
#' the final analysis. Defaults to \code{2.17}.
17+
#' @param Kv A \code{\link{numeric}} \code{\link{vector}} of strictly decreasing
18+
#' values, indicating the chosen value for
19+
#' \ifelse{html}{\out{<b><i>K</i></b>}}{\eqn{\bold{K}}}, the number of
20+
#' experimental treatment arms present in each stage. Defaults to
21+
#' \code{c(2, 1)}.
22+
#' @param alpha A \code{\link{numeric}} indicating the chosen value for
23+
#' \ifelse{html}{\out{<i>&alpha;</i>}}{\eqn{\alpha}}, the significance level
24+
#' (family-wise error-rate). Defaults to \code{0.025}.
25+
#' @param beta A \code{\link{numeric}} indicating the chosen value for
26+
#' \ifelse{html}{\out{<i>&beta;</i>}}{\eqn{\beta}}, used in the definition of
27+
#' the desired power. Defaults to \code{0.1}.
28+
#' @param lambda0 A \code{\link{numeric}} indicating the chosen value for
29+
#' \ifelse{html}{\out{<i>&lambda;</i><sub>0</sub>}}{\eqn{\lambda_0}}, the
30+
#' event rate in the control arm. Defaults to \code{5}.
31+
#' @param delta1 A \code{\link{numeric}} indicating the chosen value for
32+
#' \ifelse{html}{\out{<i>&delta;</i><sub>1</sub>}}{\eqn{\delta_1}}, the
33+
#' 'interesting' treatment effect. Defaults to \code{1}.
34+
#' @param delta0 A \code{\link{numeric}} indicating the chosen value for
35+
#' \ifelse{html}{\out{<i>&delta;</i><sub>0</sub>}}{\eqn{\delta_0}}, the
36+
#' 'uninteresting' treatment effect. Defaults to \code{0}.
37+
#' @param ratio A \code{\link{numeric}} indicating the chosen value for
38+
#' \ifelse{html}{\out{<i>r</i>}}{\eqn{r}}, the stage-wise allocation ratio to
39+
#' present experimental arms. Defaults to \code{1}.
40+
#' @param power A \code{\link{character}} string indicating the chosen type of
41+
#' power to design the trial for. Can be \code{"disjunctive"} or
42+
#' \code{"marginal"}. Defaults to \code{"marginal"}.
43+
#' @param type A \code{\link{character}} string indicating the choice for the
44+
#' stage-wise sample size. Can be \code{"variable"} or \code{"fixed"}. Defaults
45+
#' to \code{"variable"}.
46+
#' @param summary A \code{\link{logical}} variable indicating whether a summary
47+
#' of the function's progress should be printed to the console. Defaults to
48+
#' \code{FALSE}.
49+
#' @return A \code{\link{list}}, with additional class
50+
#' \code{"multiarm_des_dtl_pois"}, containing the following elements:
51+
#' \itemize{
52+
#' \item A \code{\link{tibble}} in the slot \code{$opchar} summarising the
53+
#' operating characteristics of the identified design.
54+
#' \item A \code{\link{numeric}} in the slot \code{$maxN} specifying
55+
#' \ifelse{html}{\out{<i>N</i>}}{\eqn{N}}, the trial's total required sample
56+
#' size.
57+
#' \item A \code{\link{numeric}} in the slot \code{$n_factor}, for internal use
58+
#' in other functions.
59+
#' \item Each of the input variables.
60+
#' }
61+
#' @examples
62+
#' # The design for the default parameters
63+
#' des <- build_dtl_pois()
64+
#' @seealso \code{\link{des_dtl_pois}}, \code{\link{gui}},
65+
#' \code{\link{opchar_dtl_pois}}, \code{\link{plot.multiarm_des_dtl_pois}},
66+
#' \code{\link{sim_dtl_pois}}.
67+
#' @export
68+
build_dtl_pois <- function(n1 = 210, n10 = 70, e = 2.17, Kv = c(2, 1),
69+
alpha = 0.025, beta = 0.1, lambda0 = 5, delta1 = 1,
70+
delta0 = 0, ratio = 1, power = "marginal",
71+
type = "variable", summary = FALSE) {
72+
73+
##### Check input variables ##################################################
74+
75+
#check_n1_n10(n1, n10, "n1", "n10", int = F)
76+
check_real_range_strict(e, "e", c(-Inf, Inf), 1)
77+
Kv <- check_Kv(Kv, "Kv")
78+
J <- length(Kv)
79+
check_real_range_strict(alpha, "alpha", c(0, 1), 1)
80+
check_real_range_strict(beta, "beta", c(0, 1), 1)
81+
check_real_range_strict(lambda0, "lambda0", c(0, Inf), 1)
82+
check_delta0_delta1(delta0, delta1, "delta0", "delta1", lambda0 = lambda0,
83+
name_lambda0 = "lambda0")
84+
check_real_range_strict(ratio, "ratio", c(0, Inf), 1)
85+
check_belong(power, "power", c("disjunctive", "marginal"), 1)
86+
check_belong(type, "type", c("fixed", "variable"), 1)
87+
check_logical(summary, "summary")
88+
89+
##### Print summary ##########################################################
90+
91+
if (summary) {
92+
#summary_build_dtl_pois(n1, n10, e, Kv, alpha, beta, lambda0, delta1, delta0,
93+
# ratio, power, stopping, type)
94+
message("")
95+
}
96+
97+
##### Perform main computations ##############################################
98+
99+
if (summary) {
100+
message(" Building outputs..")
101+
}
102+
integer <- all(c(n1, n10)%%1 == 0)
103+
if (type == "variable") {
104+
n_factor <- n10
105+
} else {
106+
n_factor <- n1
107+
}
108+
comp <- components_dtl_init(alpha, beta, delta0, delta1, integer, Kv,
109+
power, ratio, summary, type,
110+
lambda0 = lambda0, n_factor = n_factor,
111+
e = e)
112+
tau <- rbind(numeric(Kv[1]), rep(delta1, Kv[1]),
113+
matrix(delta0, Kv[1], Kv[1]) +
114+
(delta1 - delta0)*diag(Kv[1]))
115+
comp <- components_dtl_update(comp, tau,
116+
lambda = cbind(lambda0, tau + lambda0))
117+
comp <- opchar_dtl_internal(comp)
118+
119+
##### Outputting #############################################################
120+
121+
if (summary) {
122+
message("..outputting.")
123+
}
124+
output <- list(alpha = alpha,
125+
beta = beta,
126+
delta0 = delta0,
127+
delta1 = delta1,
128+
e = e,
129+
integer = integer,
130+
Kv = Kv,
131+
lambda0 = lambda0,
132+
maxN = comp$opchar$maxN[1],
133+
n_factor = n_factor,
134+
n1 = n1,
135+
n10 = n10,
136+
opchar = comp$opchar,
137+
power = power,
138+
ratio = ratio,
139+
summary = summary,
140+
type = type)
141+
class(output) <- c("multiarm_des_dtl_pois", class(output))
142+
output
143+
144+
}

R/build_gs_pois.R

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#' Build a multi-stage group-sequential multi-arm clinical trial for a Poisson
2+
#' distributed primary outcome
3+
#'
4+
#' \code{build_gs_pois()} builds a multi-stage group-sequential multi-arm
5+
#' clinical trial design object assuming the primary outcome variable is
6+
#' Poisson distributed, like those returned by \code{\link{des_gs_pois}}.
7+
#'
8+
#' @param n1 A \code{\link{numeric}} indicating the chosen value for
9+
#' \ifelse{html}{\out{<i>n</i><sub>1</sub>}}{\eqn{n_1}}, the total sample size
10+
#' required in stage one of the trial. Defaults to \code{162}.
11+
#' @param n10 A \code{\link{numeric}} indicating the chosen value for
12+
#' \ifelse{html}{\out{<i>n</i><sub>10</sub>}}{\eqn{n_{10}}}, the sample size
13+
#' required in the control arm in stage one of the trial. Defaults to \code{54}.
14+
#' @param e A \code{\link{numeric}} \code{\link{vector}} indicating the chosen
15+
#' value for \ifelse{html}{\out{<b><i>e</i></b>}}{\eqn{\bold{e}}}, the efficacy
16+
#' (upper) stopping boundaries. Defaults to \code{c(2.42, 2.42)}.
17+
#' @param f A \code{\link{numeric}} \code{\link{vector}} indicating the chosen
18+
#' value for \ifelse{html}{\out{<b><i>f</i></b>}}{\eqn{\bold{f}}}, the futility
19+
#' (lower) stopping boundaries. Defaults to \code{c(-2.42, 2.42)}.
20+
#' @param K A \code{\link{numeric}} indicating the chosen value for
21+
#' \ifelse{html}{\out{<i>K</i>}}{\eqn{\bold{K}}}, the (initial) number of
22+
#' experimental treatment arms. Defaults to \code{2}.
23+
#' @param alpha A \code{\link{numeric}} indicating the chosen value for
24+
#' \ifelse{html}{\out{<i>&alpha;</i>}}{\eqn{\alpha}}, the significance level
25+
#' (family-wise error-rate). Defaults to \code{0.025}.
26+
#' @param beta A \code{\link{numeric}} indicating the chosen value for
27+
#' \ifelse{html}{\out{<i>&beta;</i>}}{\eqn{\beta}}, used in the definition of
28+
#' the desired power. Defaults to \code{0.1}.
29+
#' @param lambda0 A \code{\link{numeric}} indicating the chosen value for
30+
#' \ifelse{html}{\out{<i>&lambda;</i><sub>0</sub>}}{\eqn{\lambda_0}}, the
31+
#' event rate in the control arm. Defaults to \code{5}.
32+
#' @param delta1 A \code{\link{numeric}} indicating the chosen value for
33+
#' \ifelse{html}{\out{<i>&delta;</i><sub>1</sub>}}{\eqn{\delta_1}}, the
34+
#' 'interesting' treatment effect. Defaults to \code{1}.
35+
#' @param delta0 A \code{\link{numeric}} indicating the chosen value for
36+
#' \ifelse{html}{\out{<i>&delta;</i><sub>0</sub>}}{\eqn{\delta_0}}, the
37+
#' 'uninteresting' treatment effect. Defaults to \code{0}.
38+
#' @param ratio A \code{\link{numeric}} indicating the chosen value for
39+
#' \ifelse{html}{\out{<i>r</i>}}{\eqn{r}}, the stage-wise allocation ratio to
40+
#' present experimental arms. Defaults to \code{1}.
41+
#' @param power A \code{\link{character}} string indicating the chosen type of
42+
#' power to design the trial for. Can be \code{"disjunctive"} or
43+
#' \code{"marginal"}. Defaults to \code{"marginal"}.
44+
#' @param stopping A \code{\link{character}} string indicating the chosen type
45+
#' of stopping rule. Can be \code{"separate"} or \code{"simultaneous"}. Defaults
46+
#' to \code{"simultaneous"}.
47+
#' @param type A \code{\link{character}} string indicating the choice for the
48+
#' stage-wise sample size. Can be \code{"variable"} or \code{"fixed"}. Defaults
49+
#' to \code{"variable"}.
50+
#' @param summary A \code{\link{logical}} variable indicating whether a summary
51+
#' of the function's progress should be printed to the console. Defaults to
52+
#' \code{FALSE}.
53+
#' @return A \code{\link{list}}, with additional class
54+
#' \code{"multiarm_des_gs_pois"}, containing the following elements:
55+
#' \itemize{
56+
#' \item A \code{\link{tibble}} in the slot \code{$opchar} summarising the
57+
#' operating characteristics of the identified design.
58+
#' \item A \code{\link{tibble}} in the slot \code{$pmf_N} summarising the
59+
#' probability mass function of the random required sample size under key
60+
#' scenarios.
61+
#' \item A \code{\link{numeric}} in the slot \code{$maxN} specifying
62+
#' \ifelse{html}{\out{max <i>N</i>}}{max \eqn{N}}, the trial's maximum required
63+
#' sample size.
64+
#' \item A \code{\link{numeric}} in the slot \code{$n_factor}, for internal use
65+
#' in other functions.
66+
#' \item Each of the input variables.
67+
#' }
68+
#' @examples
69+
#' # The design for the default parameters
70+
#' des <- build_gs_pois()
71+
#' @seealso \code{\link{des_gs_pois}}, \code{\link{gui}},
72+
#' \code{\link{opchar_gs_pois}}, \code{\link{plot.multiarm_des_gs_pois}},
73+
#' \code{\link{sim_gs_pois}}.
74+
#' @export
75+
build_gs_pois <- function(n1 = 231, n10 = 77, e = c(2.42, 2.42),
76+
f = c(-2.42, 2.42), K = 2, alpha = 0.025, beta = 0.1,
77+
lambda0 = 5, delta1 = 1, delta0 = 0, ratio = 1,
78+
power = "marginal", stopping = "simultaneous",
79+
type = "variable", summary = F) {
80+
81+
##### Check input variables ##################################################
82+
83+
#check_n1_n10(n1, n10, "n1", "n10", int = F)
84+
#check_ef(e, f, "e", "f")
85+
J <- length(e)
86+
K <- check_integer_range(K, "K", c(1, Inf), 1)
87+
check_real_range_strict(alpha, "alpha", c(0, 1), 1)
88+
check_real_range_strict(beta, "beta", c(0, 1), 1)
89+
check_real_range_strict(lambda0, "lambda0", c(0, Inf), 1)
90+
check_delta0_delta1(delta0, delta1, "delta0", "delta1", lambda0 = lambda0,
91+
name_lambda0 = "lambda0")
92+
check_real_range_strict(ratio, "ratio", c(0, Inf), 1)
93+
check_belong(power, "power", c("conjunctive", "disjunctive", "marginal"), 1)
94+
check_belong(stopping, "stopping", c("simultaneous", "separate"), 1)
95+
check_belong(type, "type", c("fixed", "variable"), 1)
96+
check_logical(summary, "summary")
97+
98+
##### Print summary ##########################################################
99+
100+
if (summary) {
101+
#summary_build_gs_pois(n1, n10, e, f, K, alpha, beta, lambda0, delta1,
102+
# delta0, ratio, power, stopping, type)
103+
message("")
104+
}
105+
106+
##### Perform main computations ##############################################
107+
108+
if (summary) {
109+
message(" Building outputs..")
110+
}
111+
integer <- all(c(n1, n10)%%1 == 0)
112+
if (type == "variable") {
113+
n_factor <- n10
114+
} else {
115+
n_factor <- n1
116+
}
117+
comp <- components_gs_init(alpha, beta, delta0, delta1, NA, NA, NA, NA,
118+
integer, J, K, power, ratio, stopping,
119+
summary, type, lambda0 = lambda0,
120+
n_factor = n_factor, f = f, e = e)
121+
tau <- rbind(numeric(K), rep(delta1, K),
122+
matrix(delta0, K, K) + (delta1 - delta0)*diag(K))
123+
comp <- components_gs_update(comp, tau,
124+
lambda = cbind(lambda0, tau + lambda0))
125+
comp <- opchar_gs_internal(comp)
126+
127+
##### Outputting #############################################################
128+
129+
if (summary) {
130+
message("..outputting.")
131+
}
132+
output <- list(alpha = alpha,
133+
beta = beta,
134+
delta0 = delta0,
135+
delta1 = delta1,
136+
e = comp$e,
137+
efix = NA,
138+
eshape = NA,
139+
f = comp$f,
140+
ffix = NA,
141+
fshape = NA,
142+
integer = integer,
143+
J = J,
144+
K = K,
145+
lambda0 = lambda0,
146+
n_factor = comp$n_factor,
147+
n10 = n10,
148+
n1 = n1,
149+
opchar = comp$opchar,
150+
pmf_N = comp$pmf_N,
151+
power = power,
152+
ratio = ratio,
153+
stopping = stopping,
154+
summary = summary,
155+
type = type)
156+
class(output) <- c("multiarm_des_gs_pois", class(output))
157+
output
158+
159+
}

0 commit comments

Comments
 (0)