Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jan-imbi/adestr
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-imbi committed Sep 25, 2023
2 parents b507e26 + ec94420 commit 80076ae
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 35 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Title: Adaptive Design Estimation in R
Version: 0.5.0
Authors@R: c(person("Jan", "Meis", role = c("aut", "cre"), email="meis@imbi.uni-heidelberg.de", comment = c(ORCID = "0000-0001-5407-7220")))
Description:
This package implements methods to evaluate the performance characteristics of
Methods to evaluate the performance characteristics of
various point and interval estimators for optimal adaptive two-stage designs.
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>)).
Expand All @@ -29,6 +29,7 @@ Imports:
latex2exp,
forcats,
future.apply,
pracma,
progressr,
Rdpack
Suggests:
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ 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
2 changes: 1 addition & 1 deletion R/evaluate_estimator.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ setMethod("c", signature("EstimatorScoreResultList"), definition =
#' estimator = StagewiseCombinationFunctionOrderingCI(),
#' data_distribution = Normal(FALSE),
#' design = get_example_design(),
#' mu = c(0, 0.3, 0.6),
#' mu = c(0, 0.3),
#' sigma = 1,
#' exact = FALSE
#' )
Expand Down
41 changes: 14 additions & 27 deletions R/twostagedesign_with_cache.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Remove some of this once adoptr is back on CRAN ###

#' Two-stage designs
#' 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.
Expand All @@ -24,6 +24,7 @@
#' Maximilian Pilz is available at \url{https://github.com/kkmann/adoptr}.
#'
#' @exportClass TwoStageDesign
#' @importFrom pracma gaussLegendre
setClass("TwoStageDesign", representation(
n1 = "numeric",
c1f = "numeric",
Expand All @@ -34,34 +35,20 @@ setClass("TwoStageDesign", representation(
weights = "numeric",
tunable = "logical"
))
TwoStageDesign <- function(n1, c1f, c1e, n2_pivots, c2_pivots, order = NULL) {
# The original version of this is available from
# https://github.com/kkmann/adoptr/blob/master/R/TwoStageDesign.R
if (is.null(order)) {
order <- length(c2_pivots)
} else if (length(n2_pivots) != order) {
n2_pivots <- rep(n2_pivots[1], order)
c2_pivots <- rep(c2_pivots[1], order)
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")
}
order <- as.integer(order)
if (order < 2) stop("At least two nodes are necessary for integration!")
j <- 1:(order - 1)
mu0 <- 2
b <- j / (4 * j^2 - 1)^0.5
A <- rep(0, order * order)
A[(order + 1) * (j - 1) + 2] <- b
A[(order + 1) * j] <- b
dim(A) <- c(order, order)
sd <- eigen(A, symmetric = TRUE)
w <- rev(as.vector(sd$vectors[1, ]))
w <- mu0 * w^2
x <- rev(sd$values)
rule <- data.frame(nodes = x, weights = w)
tunable <- logical(8) # initialize to all false
tunable[1:5] <- TRUE
names(tunable) <- c("n1", "c1f", "c1e", "n2_pivots", "c2_pivots", "x1_norm_pivots", "weights", "tunable")
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 = rule$nodes, weights = rule$weights,
c2_pivots = c2_pivots, x1_norm_pivots = glr$x, weights = glr$w,
tunable = tunable)
}
setClass("DataDistribution", representation(
Expand Down
2 changes: 0 additions & 2 deletions inst/REFERENCES.bib
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ @article{brannath2006estimation
pages = {3366-3381},
keywords = {adaptive design, flexible confidence interval, invariance principle, maximum likelihood estimate, mean unbiased estimate, median unbiased estimate},
doi = {10.1002/sim.2258},
url = {https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.2258},
eprint = {https://onlinelibrary.wiley.com/doi/pdf/10.1002/sim.2258},
year = {2006}
}
@book{wassmer2016group,
Expand Down
2 changes: 1 addition & 1 deletion man/EstimatorScore-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/TwoStageDesign-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/evaluate_estimator-methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/evaluate_estimator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 80076ae

Please sign in to comment.