Title: | Adaptive Two-Stage Tests |
---|---|
Description: | The functions defined in this program serve for implementing adaptive two-stage tests. Currently, four tests are included: Bauer and Koehne (1994), Lehmacher and Wassmer (1999), Vandemeulebroecke (2006), and the horizontal conditional error function. User-defined tests can also be implemented. Reference: Vandemeulebroecke, An investigation of two-stage tests, Statistica Sinica 2006. |
Authors: | Marc Vandemeulebroecke [aut, cre] |
Maintainer: | Marc Vandemeulebroecke <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.2 |
Built: | 2025-02-16 03:44:54 UTC |
Source: | https://github.com/cran/adaptTest |
The functions defined in this program serve for implementing adaptive two-stage tests.
Package: | adaptTest |
Type: | Package |
Version: | 1.2 |
Date: | 2023-10-05 |
License: | GPL (version 2 or later) |
LazyLoad: | yes |
An adaptive two-stage test can be considered as a family of decreasing functions in the unit square. Each of these functions is a conditional error function, specifying the type I error conditional on the p-value
of the first stage. For example,
corresponds to Fisher's combination test (Bauer and Koehne, 1994). Based on this function family, the test can be put into practice by specifying the desired overall level
, stopping bounds
and a parameter
. After computing
, the test stops with or without rejection of the null hypothesis if
or
, respectively. Otherwise, the null hypothesis is rejected if and only if
holds for the p-value
of the second stage, where
is such that the local level of this latter test is
(e.g.,
for Fisher's combination test).
This package provides functions for handling conditional error functions, performing calculations among the different parameters (,
,
,
and
) and computing overall p-values, in addition to graphical visualization routines. Currently, four predefined tests are included: Bauer and Koehne (1994), Lehmacher and Wassmer (1999), Vandemeulebroecke (2006), and the horizontal conditional error function. User-defined tests can also be implemented.
This package contains the following functions:
The functions a1Table
, getpar
, parconv
and tsT
can handle the four predefined tests mentioned above. The functions CEF
, plotCEF
, pathCEF
and ovP
can also handle these, and user-defined tests in addition. The functions plotBounds
, eq
, ne
, ge
, gt
, le
and lt
do not directly handle tests.
Note that a family of conditional error functions can be parameterized in two alternative ways: more "traditionally" by some parameter that, in turn, depends on the local level
of the test after the second stage, or - perhaps more conveniently - by
itself.
In this implementation, early stopping bounds are not part of the conditional error function. Rather, they are specified separately and "imposed" on it.
I want to thank Niklas Hack for technical support.
Marc Vandemeulebroecke
Maintainer: Marc Vandemeulebroecke <vandemem(at)gmx.de>
Bauer, P., Koehne, K. (1994). Evaluation of experiments with adaptive interim analyses. Biometrics 50, 1029-1041.
Brannath, W., Posch, M., Bauer, P. (2002). Recursive combination tests. J. Amer. Statist. Assoc. 97, 236-244.
Lehmacher, W., Wassmer, G. (1999). Adaptive sample size calculations in group sequential trials. Biometrics 55, 1286-1290.
Vandemeulebroecke, M. (2006). An investigation of two-stage tests. Statistica Sinica 16, 933-951.
Vandemeulebroecke, M. (2006). A general approach to two-stage tests. Doctoral thesis, Otto-von-Guericke-Universitaet Magdeburg, http://www.dissertation.de
.
Vandemeulebroecke, M. (2008). Group sequential and adaptive designs - a review of basic concepts and points of discussion. Biometrical Journal 50, 541-557.
## Example from Bauer and Koehne (1994) alpha <- 0.1 alpha2 <- 0.1 alpha0 <- 0.5 alpha1 <- tsT(typ="b", a=alpha, a0=alpha0, a2=alpha2) plotCEF(typ="b", a2=alpha2, add=FALSE) plotBounds(alpha1, alpha0) CEF(typ="b", a2=alpha2)
## Example from Bauer and Koehne (1994) alpha <- 0.1 alpha2 <- 0.1 alpha0 <- 0.5 alpha1 <- tsT(typ="b", a=alpha, a0=alpha0, a2=alpha2) plotCEF(typ="b", a2=alpha2, add=FALSE) plotBounds(alpha1, alpha0) CEF(typ="b", a2=alpha2)
This function produces tables of for a grid of different choices of
and
.
a1Table(typ, a = NA, a0 = NA, Pocock = FALSE, round = FALSE)
a1Table(typ, a = NA, a0 = NA, Pocock = FALSE, round = FALSE)
typ |
type of test: |
a |
vector of different choices of |
a0 |
vector of different choices of |
Pocock |
logical determining whether the "Pocock-type" should be calculated or the full level should be applied after the second stage (see details; default: full level after second stage). |
round |
rounding specification, logical or integer (see details; default: no rounding) |
This function produces tables of on a grid spanned by the vectors
a
and a0
(i.e., and
). This is done either for the "Pocock-type" (i.e., under the condition
:
Pocock = TRUE
) or using the full level after the second stage (:
Pocock = FALSE
(the default)). The function a1Table
can be a convenient shortcut for a repeated use of tsT
; see this latter function for further details.
The result is rounded to round
digits after the comma (round = TRUE
rounds to 1 digit; round = FALSE
and round = 0
prevent rounding).
a1Table
returns a matrix of values, with the corresponding
and
values being displayed as dimnames.
Marc Vandemeulebroecke
Bauer, P., Koehne, K. (1994). Evaluation of experiments with adaptive interim analyses. Biometrics 50, 1029-1041.
Lehmacher, W., Wassmer, G. (1999). Adaptive sample size calculations in group sequential trials. Biometrics 55, 1286-1290.
Vandemeulebroecke, M. (2006). An investigation of two-stage tests. Statistica Sinica 16, 933-951.
adaptTest
package description, tsT
## Produce basic reference tables for the test by Vandemeulebroecke (2006) alpha <- c(0.1, 0.05, 0.025, 0.01) alpha0 <- 1:10/10 a1Table(typ="v", a=alpha, a0=alpha0, Pocock=FALSE) a1Table(typ="v", a=alpha, a0=alpha0, Pocock=TRUE)
## Produce basic reference tables for the test by Vandemeulebroecke (2006) alpha <- c(0.1, 0.05, 0.025, 0.01) alpha0 <- 1:10/10 a1Table(typ="v", a=alpha, a0=alpha0, Pocock=FALSE) a1Table(typ="v", a=alpha, a0=alpha0, Pocock=TRUE)
This function returns a conditional error function.
CEF(typ = NA, fun = NA, dis = NA, a2 = NA, c = NA, p1 = NA, p2 = p1)
CEF(typ = NA, fun = NA, dis = NA, a2 = NA, c = NA, p1 = NA, p2 = p1)
typ |
type of test: |
c |
the parameter |
a2 |
|
p1 |
the p-value |
p2 |
the p-value |
fun |
a conditional error function |
dis |
a distortion method for a supplied conditional error function (see details): |
There are two alternative ways of specifying the desired conditional error function:
through a type typ
, and either a parameter (either a2
or c
) or a point (p1,p2)
, OR
through an initial conditional error function fun
, and possibly a distortion method dis
together with either the parameter a2
or a point (p1,p2)
Most people will only need the first of these two ways; the second leads to user-defined non-standard tests.
If typ
is specified, a parameter a2
or c
or the point (p1,p2)
must be provided. In this case, CEF
returns the conditional error function of the chosen type with the given parameter or running through the given point.
If typ
is not specified, a conditional error function (i.e., a nonincreasing function defined on [0,1] with values in [0,1]) fun
must be provided. If no distortion method is selected (dis = NA
), fun
is returned unchanged. Otherwise, the function is distorted using the chosen distortion method, either to match a desired second stage level a2
or to run through a specified point (p1,p2)
(one of which must be provided). Currently, two distortion methods are implemented:
dis = "pl"
, Power lines: For an initial function , define
, r>0. Note that if
is a conditional error function of type
"b"
(Bauer and Koehne, 1994), so is .
dis = "pl"
, Vertical translation: The initial function is shifted vertically.
See parconv
for more information on the two alternative parameterizations by and
.
These functions return a conditional error function (see details).
Provide either typ
or fun
, not both! If typ
is provided, then also specify a2
, c
, or p1
(and possibly p2
). If fun
is provided, then also specify dis
and a2
, or dis
and p1
(and possibly p2
), or none of these.
Warning: Values of a2
close to 0 or 1 may not work for dis = "pl"
.
Note that in this implementation of adaptive two-stage tests, early stopping bounds are not part of the conditional error function. Rather, they are specified separately (see also tsT
).
Marc Vandemeulebroecke
Bauer, P., Koehne, K. (1994). Evaluation of experiments with adaptive interim analyses. Biometrics 50, 1029-1041.
Lehmacher, W., Wassmer, G. (1999). Adaptive sample size calculations in group sequential trials. Biometrics 55, 1286-1290.
Vandemeulebroecke, M. (2006). An investigation of two-stage tests. Statistica Sinica 16, 933-951.
adaptTest
package description, parconv
, plotCEF
, tsT
## Plot two conditional error functions of the Lehmacher-Wassmer (1999) type: ## one to the local level alpha2=0.1, and one that runs through (p1,p2)=(0.3,0.7) foo1 <- CEF(typ="l", a2=0.1) foo2 <- CEF(typ="l", p1=0.3, p2=0.7) plot(foo1, xlim=0:1) plot(foo2, add=TRUE) ## A different way of doing the same plotCEF(typ="l", a2=0.1, add=FALSE) plotCEF(typ="l", p1=0.3, p2=0.7, plt.pt=FALSE)
## Plot two conditional error functions of the Lehmacher-Wassmer (1999) type: ## one to the local level alpha2=0.1, and one that runs through (p1,p2)=(0.3,0.7) foo1 <- CEF(typ="l", a2=0.1) foo2 <- CEF(typ="l", p1=0.3, p2=0.7) plot(foo1, xlim=0:1) plot(foo2, add=TRUE) ## A different way of doing the same plotCEF(typ="l", a2=0.1, add=FALSE) plotCEF(typ="l", p1=0.3, p2=0.7, plt.pt=FALSE)
This function calculates the parameter that specifies the conditional error function running through a given point , based on a chosen family of conditional error functions.
getpar(typ, p1 = NA, p2 = p1, c = FALSE)
getpar(typ, p1 = NA, p2 = p1, c = FALSE)
typ |
type of test: |
p1 |
the p-value |
p2 |
the p-value |
c |
logical determining whether the parameter |
See parconv
for more information on the two alternative parameterizations by and
.
getpar
returns the parameter (either or
, depending on the chosen parameterization) that specifies the conditional error function running through
.
Marc Vandemeulebroecke
Bauer, P., Koehne, K. (1994). Evaluation of experiments with adaptive interim analyses. Biometrics 50, 1029-1041.
Lehmacher, W., Wassmer, G. (1999). Adaptive sample size calculations in group sequential trials. Biometrics 55, 1286-1290.
Vandemeulebroecke, M. (2006). An investigation of two-stage tests. Statistica Sinica 16, 933-951.
adaptTest
package description, parconv
, CEF
## Plot the conditional error function of the Lehmacher-Wassmer (1999) ## type that runs through (p1,p2)=(0.3,0.7) alpha2 <- getpar(typ="l", p1=0.3, p2=0.7) plotCEF(typ="l", a2=alpha2, add=FALSE) ## Other ways of doing the same as above plotCEF(typ="l", p1=0.3, p2=0.7, add=FALSE) plot(CEF(typ="l", p1=0.3, p2=0.7), xlim=0:1)
## Plot the conditional error function of the Lehmacher-Wassmer (1999) ## type that runs through (p1,p2)=(0.3,0.7) alpha2 <- getpar(typ="l", p1=0.3, p2=0.7) plotCEF(typ="l", a2=alpha2, add=FALSE) ## Other ways of doing the same as above plotCEF(typ="l", p1=0.3, p2=0.7, add=FALSE) plot(CEF(typ="l", p1=0.3, p2=0.7), xlim=0:1)
These functions perform simple order comparisons for two arguments, dealing with the machine inaccuracy for floating point arithmetics.
eq(x, y, tol = .Machine$double.eps^0.5) ne(x, y, tol = .Machine$double.eps^0.5) ge(x, y, tol = .Machine$double.eps^0.5) gt(x, y, tol = .Machine$double.eps^0.5) le(x, y, tol = .Machine$double.eps^0.5) lt(x, y, tol = .Machine$double.eps^0.5)
eq(x, y, tol = .Machine$double.eps^0.5) ne(x, y, tol = .Machine$double.eps^0.5) ge(x, y, tol = .Machine$double.eps^0.5) gt(x, y, tol = .Machine$double.eps^0.5) le(x, y, tol = .Machine$double.eps^0.5) lt(x, y, tol = .Machine$double.eps^0.5)
x |
first argument (must be a numeric scalar) |
y |
second argument (must be a numeric scalar) |
tol |
comparison tolerance; differences smaller than |
When comparing two numeric scalars (e.g., for equality), machine inaccuracy can be the source of obviously erroneous results. These functions perform binary order comparisons that are tolerant towards machine inaccuracy, as an alternative to the standard comparators ==
, !=
, >=
, >
, <=
and <
.
The functions return a logical TRUE
if their condition holds, and a logical FALSE
otherwise.
eq(x, y)
checks whether x
is equal to y
ne(x, y)
checks whether x
is not equal to y
ge(x, y)
checks whether x
is greater than or equal to y
gt(x, y)
checks whether x
is greater than y
le(x, y)
checks whether x
is less than or equal to y
lt(x, y)
checks whether x
is less than y
These functions cannot be used in a vectorized fashion.
Marc Vandemeulebroecke
v <- seq(0.7, 0.8, by=0.1) v[2]==0.8 eq(v[2], 0.8)
v <- seq(0.7, 0.8, by=0.1) v[2]==0.8 eq(v[2], 0.8)
This function computes and plots overall p-values for adaptive two-stage tests.
ovP(typ = NA, fun = NA, dis = NA, p1 = 1:49/50, p2 = p1, a1 = 0, a0 = 1, grid = FALSE, plt = FALSE, invisible = FALSE, wire = FALSE, round = FALSE)
ovP(typ = NA, fun = NA, dis = NA, p1 = 1:49/50, p2 = p1, a1 = 0, a0 = 1, grid = FALSE, plt = FALSE, invisible = FALSE, wire = FALSE, round = FALSE)
typ |
type of test: |
fun |
a conditional error function |
dis |
a distortion method for a supplied conditional error function (see details): |
p1 |
the p-value |
p2 |
the p-value |
a1 |
|
a0 |
|
grid |
logical determining whether a grid should be spanned by |
plt |
logical determining whether the overall p-values should be plotted or not (default: not) |
invisible |
logical determining whether the printing of the overall p-values should be suppressed or not (default: not) |
wire |
logical determining whether the overall p-values should be plotted in wireframe-style or in cloud-style (default: cloud-style) |
round |
rounding specification, logical or integer (see details; default: no rounding) |
The overall p-value for an adaptive two-stage test is computed as if
or
, and as
otherwise, where is the conditional error function (of a specified family) running through the observed pair of p-values
(p1,p2)
.
There are two alternative ways of specifying the family of conditional error functions (i.e., the test): through a type typ
, or through an initial conditional error function fun
and a distortion method dis
; see CEF
for details.
If p1 and p2 are of length 1, a single overall p-value is computed (and not plotted). Otherwise, the behavior of ovP
depends on grid
:
If grid = FALSE
, overall p-values are computed (and not plotted) for the elementwise pairs of p1
and p2
. Here, p1
and p2
must be of the same length.
If grid = TRUE
, a grid is spanned by p1
and p2
, and p-values are computed (and possibly plotted) over this grid. Here, p1
and p2
may be of different length. Plotting is triggered by plt = TRUE
, and the style of the plot (wireframe or cloud) is determined by wire
. invisible = TRUE
suppresses the printing of the p-values.
The p-values are rounded to round
digits after the comma (round = TRUE
rounds to 1 digit; round = FALSE
and round = 0
prevent rounding). The plot always shows unrounded values.
A p-value, a vector of p-values or a matrix of p-values.
Provide either typ
or fun
, not both! If fun
is provided, then also specify dis
.
Marc Vandemeulebroecke
Bauer, P., Koehne, K. (1994). Evaluation of experiments with adaptive interim analyses. Biometrics 50, 1029-1041.
Brannath, W., Posch, M., Bauer, P. (2002). Recursive combination tests. J. Amer. Statist. Assoc. 97, 236-244.
Lehmacher, W., Wassmer, G. (1999). Adaptive sample size calculations in group sequential trials. Biometrics 55, 1286-1290.
Vandemeulebroecke, M. (2006). An investigation of two-stage tests. Statistica Sinica 16, 933-951.
adaptTest
package description, CEF
## Visualize a Lehmacher Wassmer (1999) test to the overall level 0.1 ## and compute and visualize the overall p-value for an observed (p1,p2)=(0.3,0.7) alpha <- .1 alpha0 <- .5 alpha1 <- .05 plotBounds(a1=alpha1, a0=alpha0, add=FALSE) plotCEF(typ="l", a2=tsT(typ="l", a=alpha, a0=alpha0, a1=alpha1)) plotCEF(typ="l", p1=.3, p2=.7) ovP(typ="l", p1=.3, p2=.7, a1=alpha1, a0=alpha0) # The overall p-value is the area left of alpha1, plus the area below the # conditional error function running though (0.3,0.7) between alpha1 and alpha0. ## Investigate the p-values of the Lehmacher Wassmer (1999) test from above ovP(typ="l", a1=alpha1, a0=alpha0, grid=TRUE, p1=1:9/10, round=3) ovP(typ="l", a1=alpha1, a0=alpha0, grid=TRUE, plt=TRUE, invisible=TRUE, wire=TRUE)
## Visualize a Lehmacher Wassmer (1999) test to the overall level 0.1 ## and compute and visualize the overall p-value for an observed (p1,p2)=(0.3,0.7) alpha <- .1 alpha0 <- .5 alpha1 <- .05 plotBounds(a1=alpha1, a0=alpha0, add=FALSE) plotCEF(typ="l", a2=tsT(typ="l", a=alpha, a0=alpha0, a1=alpha1)) plotCEF(typ="l", p1=.3, p2=.7) ovP(typ="l", p1=.3, p2=.7, a1=alpha1, a0=alpha0) # The overall p-value is the area left of alpha1, plus the area below the # conditional error function running though (0.3,0.7) between alpha1 and alpha0. ## Investigate the p-values of the Lehmacher Wassmer (1999) test from above ovP(typ="l", a1=alpha1, a0=alpha0, grid=TRUE, p1=1:9/10, round=3) ovP(typ="l", a1=alpha1, a0=alpha0, grid=TRUE, plt=TRUE, invisible=TRUE, wire=TRUE)
This function converts between two different parameterizations of a family of conditional error functions: a (more ‘traditional’) parameter , and a (more convenient) parameter
specifying the local level of the test after the second stage.
parconv(typ, a2 = NA, c = NA)
parconv(typ, a2 = NA, c = NA)
typ |
type of test: |
a2 |
|
c |
the parameter |
Traditionally, a family of conditional error functions is often parameterized by some parameter that, in turn, depends on the local level
of the test after the second stage. However, it can be convenient to parameterize the family directly by
. The function
parconv
converts one parameter into the other: provide one, and it returns the other.
Essentially, the relation between the two parameterizations is implemented as:
for Fisher's combination test (Bauer and Koehne, 1994)
for the inverse normal method (Lehmacher and Wassmer, 1999)
for Vandemeulebroecke (2006)
for the family of horizontal conditional error functions
parconv
returns corresponding to the supplied
, or
corresponding to the supplied
.
Provide either a2
or c
, not both!
is the local level of the test after the second stage, and it equals the integral under the corresponding conditional error function:
where is the conditional error function (of a specified family) with parameter
.
Note that in this implementation of adaptive two-stage tests, early stopping bounds are not part of the conditional error function. Rather, they are specified separately (see also tsT
).
can take any value in
;
can take values in
for Fisher's combination test (Bauer and Koehne, 1994)
for the inverse normal method (Lehmacher and Wassmer, 1999)
for Vandemeulebroecke (2006)
for the family of horizontal conditional error functions
Marc Vandemeulebroecke
Bauer, P., Koehne, K. (1994). Evaluation of experiments with adaptive interim analyses. Biometrics 50, 1029-1041.
Lehmacher, W., Wassmer, G. (1999). Adaptive sample size calculations in group sequential trials. Biometrics 55, 1286-1290.
Vandemeulebroecke, M. (2006). An investigation of two-stage tests. Statistica Sinica 16, 933-951.
adaptTest
package description, getpar
, CEF
## Obtain the parameter c for Fisher's combination test, using ## the local level 0.05 for the test after the second stage parconv(typ="b", a2=0.05)
## Obtain the parameter c for Fisher's combination test, using ## the local level 0.05 for the test after the second stage parconv(typ="b", a2=0.05)
This function plots several conditional error functions of the same family such that each one runs through one of several given points.
pathCEF(typ = NA, fun = NA, dis = NA, p1 = 1:49/50, p2 = p1, x = 0:200/200, plt.pt = FALSE, plt.ptann = FALSE, xlab = NA, ylab = NA, ...)
pathCEF(typ = NA, fun = NA, dis = NA, p1 = 1:49/50, p2 = p1, x = 0:200/200, plt.pt = FALSE, plt.ptann = FALSE, xlab = NA, ylab = NA, ...)
typ |
type of test: |
fun |
a conditional error function |
dis |
a distortion method for a supplied conditional error function (see details): |
p1 |
a vector (at least of length 2) of p-values |
p2 |
a vector (at least of length 2) of p-values |
x |
vector on which the conditional error functions are plotted (should be relatively dense in [0,1]) |
plt.pt |
logical determining whether the points that the conditional error functions are made to run through should be plotted or not (default: not) |
plt.ptann |
logical determining whether the points that the conditional error functions are made to run through should be annotated or not (default: not) |
xlab |
a label for the x axis (default: no label) |
ylab |
a label for the y axis (default: no label) |
... |
arguments to be passed on to the underlying |
It can be instructive to plot not only one conditional error function, but to visualize a whole family. This can easily be done with pathCEF
. The function is used in a similar way as plotCEF
, but p1
and p2
are now vectors (of the same length, at least of length 2). Conditional error functions are plotted that run through the specified elementwise points (p1,p2)
(which by default lie on the main diagonal).
Internally, pathCEF
uses plotCEF
to plot the individual conditional error functions; see this latter function for further details.
The function pathCEF
is invoked for its plotting effect; it returns no meaningful value.
Provide either typ
or fun
, not both! If fun
is provided, then also specify dis
.
Unlike plotCEF
, it is not possible with pathCEF
to specify the conditional error functions by the parameter or the parameter
.
plt.ptann
is not considered if plt.pt = FALSE
.
Marc Vandemeulebroecke
Bauer, P., Koehne, K. (1994). Evaluation of experiments with adaptive interim analyses. Biometrics 50, 1029-1041.
Lehmacher, W., Wassmer, G. (1999). Adaptive sample size calculations in group sequential trials. Biometrics 55, 1286-1290.
Vandemeulebroecke, M. (2006). An investigation of two-stage tests. Statistica Sinica 16, 933-951.
adaptTest
package description, CEF
, plotCEF
, tsT
## Compare the tests by Bauer and Koehne (1994), ## Lehmacher and Wassmer (1999) and Vandemeulebroecke (2006) oldmfcol <- par(mfcol=c(1,3)) pathCEF(typ="b", main="BK 94") pathCEF(typ="l", main="LW 99") pathCEF(typ="v", main="V 06") par(oldmfcol)
## Compare the tests by Bauer and Koehne (1994), ## Lehmacher and Wassmer (1999) and Vandemeulebroecke (2006) oldmfcol <- par(mfcol=c(1,3)) pathCEF(typ="b", main="BK 94") pathCEF(typ="l", main="LW 99") pathCEF(typ="v", main="V 06") par(oldmfcol)
This function plots the stopping bounds of an adaptive two-stage test.
plotBounds(a1 = 0, a0 = 1, add = TRUE, xlab = NA, ylab = NA, ...)
plotBounds(a1 = 0, a0 = 1, add = TRUE, xlab = NA, ylab = NA, ...)
a1 |
|
a0 |
|
add |
logical determining whether the bounds should be added to an existing plot (default) or a new plot should be opened |
xlab |
a label for the x axis (default: no label) |
ylab |
a label for the y axis (default: no label) |
... |
arguments to be passed on to the underlying |
This function plots the stopping bounds and
of an adaptive two-stage test, either onto an existing plot or into a new plot.
The function plotBounds
is invoked for its plotting effect; it returns no meaningful value.
Note that in this implementation of adaptive two-stage tests, early stopping bounds are not part of the conditional error function. Rather, they are specified separately (see also tsT
).
Marc Vandemeulebroecke
adaptTest
package description, plotCEF
## Example from Bauer and Koehne (1994): full level after final stage, alpha0 = 0.5 alpha <- 0.1 alpha2 <- 0.1 alpha0 <- 0.5 alpha1 <- tsT(typ="b", a=alpha, a0=alpha0, a2=alpha2) plotCEF(typ="b", a2=alpha2, add=FALSE) plotBounds(alpha1, alpha0)
## Example from Bauer and Koehne (1994): full level after final stage, alpha0 = 0.5 alpha <- 0.1 alpha2 <- 0.1 alpha0 <- 0.5 alpha1 <- tsT(typ="b", a=alpha, a0=alpha0, a2=alpha2) plotCEF(typ="b", a2=alpha2, add=FALSE) plotBounds(alpha1, alpha0)
This function plots a conditional error function.
plotCEF(typ = NA, fun = NA, dis = NA, a2 = NA, c = NA, p1 = NA, p2 = p1, x = 0:200/200, add = TRUE, xlim = c(0, 1), ylim = c(0, 1), plt.pt = TRUE, plt.ptann = TRUE, xlab = NA, ylab = NA, ...)
plotCEF(typ = NA, fun = NA, dis = NA, a2 = NA, c = NA, p1 = NA, p2 = p1, x = 0:200/200, add = TRUE, xlim = c(0, 1), ylim = c(0, 1), plt.pt = TRUE, plt.ptann = TRUE, xlab = NA, ylab = NA, ...)
typ |
type of test: |
fun |
a conditional error function |
dis |
a distortion method for a supplied conditional error function (see details): |
a2 |
|
c |
the parameter |
p1 |
the p-value |
p2 |
the p-value |
x |
vector on which the conditional error function is plotted (should be relatively dense in [0,1]) |
add |
logical determining whether the bounds should be added to an existing plot (default) or a new plot should be opened |
xlim |
the x limits of the plot (default: |
ylim |
the y limits of the plot (default: |
plt.pt |
logical determining whether the point that the conditional error function is made to run through should be plotted or not (default: yes) |
plt.ptann |
logical determining whether the point that the conditional error function is made to run through should be annotated or not (default: yes) |
xlab |
a label for the x axis (default: no label) |
ylab |
a label for the y axis (default: no label) |
... |
arguments to be passed on to the underlying |
There are two alternative ways of specifying the desired conditional error function:
through a type typ
, and either a parameter (either a2
or c
) or a point (p1,p2)
, OR
through an initial conditional error function fun
, and possibly a distortion method dis
together with either the parameter a2
or a point (p1,p2)
Most people will only need the first of these two ways; the second leads to user-defined non-standard tests.
If typ
is specified, a parameter a2
or c
or the point (p1,p2)
must be provided. In this case, plotCEF
plots the conditional error function of the chosen type with the given parameter or running through the given point.
If typ
is not specified, a conditional error function (i.e., a nonincreasing function defined on [0,1] with values in [0,1]) fun
must be provided. If no distortion method is selected (dis = NA
), fun
is plotted unchanged. Otherwise, the function is distorted using the chosen distortion method, either to match a desired second stage level a2
or to run through a specified point (p1,p2)
(one of which must be provided). Currently, two distortion methods are implemented:
dis = "pl"
, Power lines: For an initial function fun
, define , r>0. Note that if
fun
is a conditional error function of type "b"
(Bauer and Koehne, 1994), so is f[r].
dis = "pl"
, Vertical translation: The initial function fun
is shifted vertically.
See parconv
for more information on the two alternative parameterizations by and
.
Internally, plotCEF
uses CEF
to compute the conditional error function that is to be plotted.
The function plotCEF
is invoked for its plotting effect; it returns no meaningful value.
Provide either typ
or fun
, not both! If typ
is provided, then also specify a2
, c
, or p1
(and possibly p2
). If fun
is provided, then also specify dis
and a2
, or dis
and p1
(and possibly p2
), or none of these.
Warning: Values of a2
close to 0 or 1 may not work for dis = "pl"
.
plt.pt
and plt.ptann
are not considered if p1 = NA
. plt.ptann
is not considered if plt.pt = FALSE
.
Note that in this implementation of adaptive two-stage tests, early stopping bounds are not part of the conditional error function. Rather, they are specified separately (see also tsT
).
Marc Vandemeulebroecke
Bauer, P., Koehne, K. (1994). Evaluation of experiments with adaptive interim analyses. Biometrics 50, 1029-1041.
Lehmacher, W., Wassmer, G. (1999). Adaptive sample size calculations in group sequential trials. Biometrics 55, 1286-1290.
Vandemeulebroecke, M. (2006). An investigation of two-stage tests. Statistica Sinica 16, 933-951.
adaptTest
package description, parconv
, CEF
, tsT
## Plot two conditional error functions of the Lehmacher-Wassmer (1999) type: ## one to the local level alpha2=0.1, and one that runs through (p1,p2)=(0.3,0.7) plotCEF(typ="l", a2=0.1, add=FALSE) plotCEF(typ="l", p1=0.3, p2=0.7) ## Plot an explicitly defined conditional error function, and distort it plotCEF(fun=function(x) ifelse(x<.5,(1-x)^2, (1-x)/2), add=FALSE) plotCEF(fun=function(x) ifelse(x<.5,(1-x)^2, (1-x)/2), dis="pl", a2=.5) foo <- CEF(fun=function(x) ifelse(x<.5,(1-x)^2, (1-x)/2), dis="pl", a2=.5) plotCEF(fun=foo, col="red")
## Plot two conditional error functions of the Lehmacher-Wassmer (1999) type: ## one to the local level alpha2=0.1, and one that runs through (p1,p2)=(0.3,0.7) plotCEF(typ="l", a2=0.1, add=FALSE) plotCEF(typ="l", p1=0.3, p2=0.7) ## Plot an explicitly defined conditional error function, and distort it plotCEF(fun=function(x) ifelse(x<.5,(1-x)^2, (1-x)/2), add=FALSE) plotCEF(fun=function(x) ifelse(x<.5,(1-x)^2, (1-x)/2), dis="pl", a2=.5) foo <- CEF(fun=function(x) ifelse(x<.5,(1-x)^2, (1-x)/2), dis="pl", a2=.5) plotCEF(fun=foo, col="red")
There are four key quantities for the specification of an adaptive two-stage test: the overall test level , stopping bounds
and the local level
of the test after the second stage. These quantities are interrelated through the overall level condition. The function
tsT
calculates any of these quantities based on the others.
tsT(typ, a = NA, a0 = NA, a1 = NA, a2 = NA)
tsT(typ, a = NA, a0 = NA, a1 = NA, a2 = NA)
typ |
type of test: |
a |
|
a0 |
|
a1 |
|
a2 |
|
An adaptive two-stage test can be viewed as a family of decreasing functions in the unit square. Each of these functions is a conditional error function, specifying the type I error conditional on the p-value
of the first stage. For example,
corresponds to Fisher's combination test (Bauer and Koehne, 1994). Based on this function family, the test can be put into practice by specifying the desired overall level
, stopping bounds
and a parameter
. After computing
, the test stops with or without rejection of the null hypothesis if
or
, respectively. Otherwise, the null hypothesis is rejected if and only if
holds for the p-value
of the second stage, where
is such that the local level of this latter test is
(e.g.,
for Fisher's combination test).
The four parameters ,
,
and
are interdependent: they must satisfy the level condition
where is the conditional error function (of a specified family) with parameter
. For example, this conditon translates to
for Fisher's combination test (assuming that ; Bauer and Koehne, 1994). The function
tsT
calculates any of the four parameters based on the remaining ones. Currently, this is implemented for the following four tests: Bauer and Koehne (1994), Lehmacher and Wassmer (1999), Vandemeulebroecke (2006), and the horizontal conditional error function.
If three of the four quantities ,
,
and
are provided,
tsT
returns the fourth. If only and
are provided,
tsT
returns under the condition
(the so-called "Pocock-type").
If the choice of arguments is not allowed (e.g., ) or when a test cannot be constructed with this choice of arguments (e.g.,
and
),
tsT
returns NA
.
IMPORTANT: When the result is (theoretically) not unique, tsT
returns the maximal , maximal
or minimal
.
In all cases, tsT
returns the result for the test specified by typ
.
The argument typ
, and either exactly three of ,
,
and
, or only
and
, must be provided to
tsT
.
Marc Vandemeulebroecke
Bauer, P., Koehne, K. (1994). Evaluation of experiments with adaptive interim analyses. Biometrics 50, 1029-1041.
Lehmacher, W., Wassmer, G. (1999). Adaptive sample size calculations in group sequential trials. Biometrics 55, 1286-1290.
Vandemeulebroecke, M. (2006). An investigation of two-stage tests. Statistica Sinica 16, 933-951.
Vandemeulebroecke, M. (2008). Group sequential and adaptive designs - a review of basic concepts and points of discussion. Biometrical Journal 50, 541-557.
adaptTest
package description
## Example from Bauer and Koehne (1994): full level after final stage, alpha0 = 0.5 alpha <- 0.1 alpha2 <- 0.1 alpha0 <- 0.5 alpha1 <- tsT(typ="b", a=alpha, a0=alpha0, a2=alpha2) plotCEF(typ="b", a2=alpha2, add=FALSE) plotBounds(alpha1, alpha0) ## See how similar Lehmacher and Wassmer (1999) and Vandemeulebroecke (2006) are alpha <- 0.1 alpha1 <- 0.05 alpha0 <- 0.5 alpha2l <- tsT(typ="l", a=alpha, a0=alpha0, a1=alpha1) alpha2v <- tsT(typ="v", a=alpha, a0=alpha0, a1=alpha1) plotCEF(typ="l", a2=alpha2l, add=FALSE) plotCEF(typ="v", a2=alpha2v, col="red") plotBounds(alpha1, alpha0) ## A remark about numerics tsT(typ="b", a=0.1, a1=0.05, a0=0.5) tsT(typ="b", a=0.1, a2=0.104877, a0=0.5) tsT(typ="b", a=0.1, a2=tsT(typ="b", a=0.1, a1=0.05, a0=0.5), a0=0.5) ## An example of non-uniqueness: the maximal alpha1 is returned; any ## smaller value would also be valid alpha <- 0.05 alpha0 <- 1 alpha2 <- 0.05 alpha1 <- tsT(typ="b", a=alpha, a0=alpha0, a2=alpha2) tsT(typ="b", a0=alpha0, a1=alpha1, a2=alpha2) tsT(typ="b", a0=alpha0, a1=alpha1/2, a2=alpha2)
## Example from Bauer and Koehne (1994): full level after final stage, alpha0 = 0.5 alpha <- 0.1 alpha2 <- 0.1 alpha0 <- 0.5 alpha1 <- tsT(typ="b", a=alpha, a0=alpha0, a2=alpha2) plotCEF(typ="b", a2=alpha2, add=FALSE) plotBounds(alpha1, alpha0) ## See how similar Lehmacher and Wassmer (1999) and Vandemeulebroecke (2006) are alpha <- 0.1 alpha1 <- 0.05 alpha0 <- 0.5 alpha2l <- tsT(typ="l", a=alpha, a0=alpha0, a1=alpha1) alpha2v <- tsT(typ="v", a=alpha, a0=alpha0, a1=alpha1) plotCEF(typ="l", a2=alpha2l, add=FALSE) plotCEF(typ="v", a2=alpha2v, col="red") plotBounds(alpha1, alpha0) ## A remark about numerics tsT(typ="b", a=0.1, a1=0.05, a0=0.5) tsT(typ="b", a=0.1, a2=0.104877, a0=0.5) tsT(typ="b", a=0.1, a2=tsT(typ="b", a=0.1, a1=0.05, a0=0.5), a0=0.5) ## An example of non-uniqueness: the maximal alpha1 is returned; any ## smaller value would also be valid alpha <- 0.05 alpha0 <- 1 alpha2 <- 0.05 alpha1 <- tsT(typ="b", a=alpha, a0=alpha0, a2=alpha2) tsT(typ="b", a0=alpha0, a1=alpha1, a2=alpha2) tsT(typ="b", a0=alpha0, a1=alpha1/2, a2=alpha2)