Skip to content

Commit

Permalink
Collaborative effort to fix R CMD Check
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-imbi committed Jul 10, 2024
1 parent 5ff20d4 commit 48c436d
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 242 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Authors@R:c(person("Jan", "Meis", role = c("aut", "cre"), email = "meis@imbi.uni
person("Martin", "Maechler", role = c("cph"), email = "maechler@stat.math.ethz.ch", comment = c(ORCID = "0000-0002-8685-9910", "Original author of monoSpl.c (from the 'stats' package).")))
Description:
Methods to evaluate the performance characteristics of
various point and interval estimators for optimal adaptive two-stage designs.
various point and interval estimators for optimal adaptive two-stage designs as described
in Meis et al. (2024) <doi:10.1002/sim.10020>.
Specifically, this package is written to work with trial designs created by the 'adoptr' package
(Kunzmann et al. (2021) <doi:10.18637/jss.v098.i09>; Pilz et al. (2021) <doi:10.1002/sim.8953>)).
Apart from the a priori evaluation of performance characteristics, this package also allows for the
Expand All @@ -24,7 +25,8 @@ LazyData: true
VignetteBuilder: knitr
RoxygenNote: 7.2.3
Depends:
R (>= 4.0.0)
R (>= 4.0.0),
adoptr
Imports:
methods,
stats,
Expand All @@ -36,7 +38,6 @@ Imports:
latex2exp,
forcats,
future.apply,
pracma,
progressr,
Rdpack
Suggests:
Expand Down
5 changes: 1 addition & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export(NaiveCI)
export(NaivePValue)
export(NeymanPearsonOrderingCI)
export(NeymanPearsonOrderingPValue)
export(Normal)
export(NormalPrior)
export(OverestimationProbability)
export(PValue)
Expand All @@ -43,7 +42,6 @@ export(ScoreTestOrderingPValue)
export(SoftCoverage)
export(StagewiseCombinationFunctionOrderingCI)
export(StagewiseCombinationFunctionOrderingPValue)
export(Student)
export(TestAgreement)
export(UniformPrior)
export(Variance)
Expand All @@ -61,8 +59,8 @@ exportClasses(IntervalEstimator)
exportClasses(PValue)
exportClasses(PointEstimator)
exportClasses(Statistic)
exportClasses(TwoStageDesign)
exportMethods(plot)
import(adoptr)
import(ggplot2)
import(methods)
importFrom(Rdpack,reprompt)
Expand All @@ -83,7 +81,6 @@ importFrom(ggpubr,theme_pubr)
importFrom(grDevices,xy.coords)
importFrom(graphics,plot.default)
importFrom(latex2exp,TeX)
importFrom(pracma,gaussLegendre)
importFrom(progressr,progressor)
importFrom(scales,percent)
importFrom(stats,dchisq)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# adestr 0.5.2

* Preparing new CRAN release: adoptr back on CRAN, adding the
collaborative produced test cases and vignettes

# adestr 0.5.1

* Replaced raster graphics in vignettes with vector graphics.
Expand Down
2 changes: 1 addition & 1 deletion R/adestr_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#'
#' @docType package
#' @name adestr
#' @import methods
#' @import methods adoptr
#' @importFrom stats dnorm pnorm qnorm dt pt qt dchisq pchisq qchisq integrate uniroot var
#' @importFrom cubature hcubature
#' @importFrom Rdpack reprompt
Expand Down
4 changes: 4 additions & 0 deletions R/fastmonoHFC.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Myregularize.values <- function (x, y, ties, warn.collapsing = TRUE, na.rm = TRU
}
list(x = x, y = y, keptNA = keptNA, notNA = if (keptNA) ok)
}

# This is isn't used anywhere, but maybe someone needs it sometime
#nocov start
fastmonoH.FC_function <- function(x, y=NULL, ties = mean, extrapol = c("linear", "cubic")) {
x <- Myregularize.values(x, y, ties, missing(ties))
y <- x$y
Expand Down Expand Up @@ -104,6 +107,7 @@ fastmonoH.FC_function <- function(x, y=NULL, ties = mean, extrapol = c("linear",
res
}
}
#nocov end

fastmonoH.FC_coefficients <- function(x, y=NULL, ties = mean, extrapol = c("linear", "cubic")){
x <- Myregularize.values(x, y, ties, missing(ties))
Expand Down
2 changes: 2 additions & 0 deletions R/fisher_information.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nocov start
fisher_information <- function(design, mu, sigma, two_armed) {
sapply(mu, \(x)
integrate_over_sample_space(
Expand All @@ -23,3 +24,4 @@ make_inverse_fisher_information_table <- function(designs, mu, sigma, two_armed)
}
do.call(rbind, res_list)
}
#nocov end
113 changes: 0 additions & 113 deletions R/twostagedesign_with_cache.R
Original file line number Diff line number Diff line change
@@ -1,116 +1,3 @@
### Remove some of this once adoptr is back on CRAN ###

#' Re-export of two-stage design class
#'
#' This is a re-export of the \code{TwoStageDesign} class from the
#' \code{adoptr} \insertCite{kunzmann2021adoptr}{adestr} package.
#'
#' This function is currently re-exported here to resolve CRAN conflicts.
#' For details, please refer to the paper \insertCite{kunzmann2021adoptr}{adestr}
#' and the original github repository \url{https://github.com/kkmann/adoptr}.
#'
#' @slot n1 (numeric) first-stage sample size.
#' @slot c1f (numeric) first-stage futility boundary.
#' @slot c1e (numeric) first-stage early efficacy boundary.
#' @slot n2_pivots (numeric) vector containing the values of the n2 spline function.
#' @slot c2_pivots (numeric) vector containing the values of the second-stage
#' rejection boundary spline c2
#' @slot x1_norm_pivots (numeric) vector containing the x-axis (z-sclae) points
#' for the n2 and c2 splines
#' @slot weights (numeric) vector containing integration weights
#' @slot tunable (logical) vector determining whether desing paramters are to be optimized
#'
#' @seealso The original implementation of the adoptr package by Kevin Kunzmann and
#' Maximilian Pilz is available at \url{https://github.com/kkmann/adoptr}.
#'
#' @exportClass TwoStageDesign
#' @importFrom pracma gaussLegendre
setClass("TwoStageDesign", representation(
n1 = "numeric",
c1f = "numeric",
c1e = "numeric",
n2_pivots = "numeric",
c2_pivots = "numeric",
x1_norm_pivots = "numeric",
weights = "numeric",
tunable = "logical"
))
TwoStageDesign <- function(n1, c1f, c1e, n2_pivots, c2_pivots, order = length(c2_pivots)) {
if (order != length(c2_pivots)) {
stop("order needs to be same length as c2_pivots")
}
if (length(n2_pivots) != length(c2_pivots) && length(n2_pivots)!=1) {
stop("n2_pivots needs to be the same length as c2_pivots or of length 1.")
}
if (length(n2_pivots)==1L)
n2_pivots <- rep(n2_pivots, order)
glr <- gaussLegendre(order, -1, 1)
tunable <- c("n1" = TRUE, "c1f" = TRUE, "c1e" = TRUE, "n2_pivots" = TRUE, "c2_pivots" = TRUE,
"x1_norm_pivots" = FALSE, "weights" = FALSE, "tunable" = FALSE)
new("TwoStageDesign", n1 = n1, c1f = c1f, c1e = c1e, n2_pivots = n2_pivots,
c2_pivots = c2_pivots, x1_norm_pivots = glr$x, weights = glr$w,
tunable = tunable)
}
setClass("DataDistribution", representation(
two_armed = "logical")
)
setClass("Normal", contains = "DataDistribution")
#' Normally distributed data with known variance
#'
#' This function creates an object representing the distributional assumptions
#' of the data: normally distributed outcomes sample from a trial with
#' one or two arms (depending on the value of the parameter \code{two_armed}),
#' under the assumption of known variance.
#'
#' @param two_armed (logical) determines whether one or two-armed trials are assumed.
#'
#' @export
#' @returns an object of class \code{Normal}. This object encodes the distributional
#' assumptions of the data for usage in the functions
#' \code{\link{evaluate_estimator}} and \code{\link{analyze}}.
#' @examples
#' evaluate_estimator(
#' score = MSE(),
#' estimator = SampleMean(),
#' data_distribution = Normal(FALSE),
#' design = get_example_design(),
#' mu = c(0, 0.3, 0.6),
#' sigma = 1,
#' exact = FALSE
#' )
#'
#'
Normal <- function(two_armed = TRUE) new("Normal", two_armed = two_armed)
setClass("Student", contains = "DataDistribution")

#' Normally distributed data with unknown variance
#'
#' This function creates an object representing the distributional assumptions
#' of the data: normally distributed outcomes sample from a trial with
#' one or two arms (depending on the value of the parameter \code{two_armed}),
#' under the assumption of known variance.
#'
#' @param two_armed (logical) determines whether one or two-armed trials are assumed.
#' @returns an object of class \code{Student}. This object encodes the distributional
#' assumptions of the data for usage in the functions
#' \code{\link{evaluate_estimator}} and \code{\link{analyze}}.
#'
#' @export
#' @examples
#' evaluate_estimator(
#' score = MSE(),
#' estimator = SampleMean(),
#' data_distribution = Student(FALSE),
#' design = get_example_design(),
#' mu = c(0, 0.3, 0.6),
#' sigma = 1,
#' exact = FALSE
#' )
#'
Student <- function(two_armed = TRUE) new("Student", two_armed = two_armed)
n1 <- function(design, round = FALSE) if (round) round(design@n1) else design@n1
### end of remove ###

setClass(
"TwoStageDesignWithCache",
contains = "TwoStageDesign",
Expand Down
22 changes: 12 additions & 10 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Currently, it works for designs objects which were produced by the
R-package `adoptr`, which calculates optimal design parameters adaptive
two-stage designs.

An introductory vignette covering common usecases is given at [https://jan-imbi.github.io/adestr/articles/Introduction.html](https://jan-imbi.github.io/adestr/articles/Introduction.html).

The test [https://jan-imbi.github.io/adestr/articles/Introduction.html](https://jan-imbi.github.io/adestr/articles/Introduction.html).

<!-- reference implementation verlinken -->

## Installation

You can install the development version of adestr by typing
Expand All @@ -43,16 +49,7 @@ remotes::install_github("https://github.com/jan-imbi/adestr")
```
into your R console.

## Information for reviewers

The scripts to reproduce the results from the paper can be found in the
`/data/code/` directory of this repository. The results themselves are
located in the `/data/` directory.

The easiest way to inspect the results is to [clone this repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository).


## General example for usage of the package
## Small introductory example

Here is a quick example showing the capabilities of `adestr`.
First, load `adestr`:
Expand Down Expand Up @@ -103,3 +100,8 @@ analyze(
design = get_example_design()
)
```

Please refer to [https://jan-imbi.github.io/adestr/articles/Introduction.html](https://jan-imbi.github.io/adestr/articles/Introduction.html) for a more detailed introduction.



35 changes: 0 additions & 35 deletions man/Normal.Rd

This file was deleted.

34 changes: 0 additions & 34 deletions man/Student.Rd

This file was deleted.

41 changes: 0 additions & 41 deletions man/TwoStageDesign-class.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion tests/testthat/setup_designs.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# adoptr designs used for testing
designad <- get_example_design()
### Put GroupSequentialDesign( once adoptr is back on CRAN ###
designgs <- TwoStageDesign(
designgs <- GroupSequentialDesign(
n1 = 29.53980042851903320411,
c1f = 0.8563037186428685831885,
c1e = 2.211178640465977007779,
Expand Down

0 comments on commit 48c436d

Please sign in to comment.