Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update branch cran #42

Merged
merged 68 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
3b2dc9f
Merge pull request #29 from imbi-heidelberg/cran
max-pilz May 7, 2020
c5578a6
Merge pull request #30 from imbi-heidelberg/cran
lbau7 May 11, 2020
6998767
improve documentation
max-pilz Sep 17, 2020
b000f9b
fit to documentation guidelines
max-pilz Sep 18, 2020
70657cc
unify summary doc
max-pilz Sep 18, 2020
020a424
Merge pull request #32 from imbi-heidelberg/general
lbau7 Sep 18, 2020
6015dc2
inline comments
max-pilz Jun 25, 2021
b10540d
add tests
max-pilz Jun 25, 2021
127e1e0
update version number
max-pilz Jun 28, 2021
3adf288
extend documentation
max-pilz Jun 29, 2021
30ca00f
add in-line documentation
lbau7 Jun 30, 2021
237a7fe
add in-line documentation
lbau7 Jun 30, 2021
976746d
add in-line documentation
lbau7 Jun 30, 2021
5b25be3
add tests
lbau7 Jun 30, 2021
d41a02f
Merge pull request #33 from imbi-heidelberg/tests-docs
max-pilz Jun 30, 2021
49fdd2b
use GitHub actions instead of travis
lbau7 Jun 30, 2021
f83e0e7
new roxygen version
lbau7 Jul 1, 2021
983e6d7
expand documentation
lbau7 Jul 1, 2021
68fd3ae
make student documentation more consistent
max-pilz Jul 1, 2021
330569c
merge master into review
max-pilz Jul 1, 2021
8027db4
...
max-pilz Jul 1, 2021
d7826a5
...
max-pilz Jul 1, 2021
4b7b274
Merge pull request #34 from imbi-heidelberg/review
max-pilz Jul 1, 2021
f1d9c01
enhance README
lbau7 Jul 2, 2021
8a4edf2
review
lbau7 Jul 2, 2021
3d83de0
enhance README
lbau7 Jul 2, 2021
76488e7
Merge pull request #35 from imbi-heidelberg/review
max-pilz Jul 2, 2021
f107f57
Update DESCRIPTION
max-pilz Jul 5, 2021
4ec7e7e
Update DESCRIPTION
max-pilz Jul 5, 2021
bc8a434
fix formating in pdf documentation
lbau7 Jul 6, 2021
60b9702
Merge pull request #36 from imbi-heidelberg/review
max-pilz Jul 6, 2021
ec98f16
fix non-ascii character in documentation
lbau7 Jul 6, 2021
692163e
fix non-ascii character in documentation
lbau7 Jul 6, 2021
519b6fd
Merge branch 'master' into review
lbau7 Jul 6, 2021
c90e136
Merge pull request #37 from imbi-heidelberg/review
max-pilz Jul 6, 2021
0772afc
few updates
max-pilz Aug 22, 2022
289f70e
add R Journal reference
max-pilz Sep 9, 2022
cebbb7c
update documentation
max-pilz Sep 9, 2022
52e0cde
next step to solve html issue
max-pilz Nov 3, 2022
ea6ade2
try to fix Student documentation
max-pilz Nov 3, 2022
2a656e9
next student trial
max-pilz Nov 3, 2022
8b7a41b
ChiSquare trial
max-pilz Nov 3, 2022
8763f24
usw
max-pilz Nov 3, 2022
93f903b
...
max-pilz Nov 11, 2022
79d18fd
remove code/link structure from FarringtonManning
max-pilz Nov 11, 2022
85c871d
next trial
max-pilz Nov 11, 2022
447e0b3
...
max-pilz Nov 11, 2022
f78d26f
...
max-pilz Nov 11, 2022
5bfb0e4
...
max-pilz Nov 11, 2022
2c2dd9f
...
max-pilz Nov 11, 2022
a687ac3
remove all <p></p> environments
max-pilz Nov 11, 2022
0610359
typo
max-pilz Nov 14, 2022
b2125b5
test if eqn and deqn are accepted in html test
max-pilz Nov 14, 2022
91586a2
remove all the ifelse-html constructs
max-pilz Nov 14, 2022
ba1218f
switch to version 1.0.0
max-pilz Nov 14, 2022
22c90b1
Merge pull request #38 from imbi-heidelberg/fix-documentation
lbau7 Nov 16, 2022
09f4263
udpate description
max-pilz Nov 17, 2022
235ef33
add reference to readme
max-pilz Nov 17, 2022
b6df80d
Merge pull request #39 from imbi-heidelberg/fix-documentation
max-pilz Nov 22, 2022
eb993f6
fix doctype issue
lbau7 Sep 29, 2023
8215364
update version number
lbau7 Sep 29, 2023
b19cc5e
update roxygen version
lbau7 Sep 29, 2023
22eba77
fix github actions
lbau7 Sep 29, 2023
0c5053d
fix badges
lbau7 Sep 29, 2023
51afca9
Merge pull request #40 from imbi-heidelberg/fix
lbau7 Sep 29, 2023
0978add
fix institute name
lbau7 Sep 29, 2023
60b9390
fix citation
lbau7 Sep 29, 2023
f274901
Merge pull request #41 from imbi-heidelberg/fix
lbau7 Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
^README\.Rmd$
^LICENSE\.md$
^Thumbs.db$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
49 changes: 49 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
50 changes: 50 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

17 changes: 10 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
Package: blindrecalc
Type: Package
Title: Blinded Sample Size Recalculation
Version: 0.1.2
Version: 1.0.1
Authors@R:
c(person(given = "Lukas",
family = "Baumann",
role = c("aut"),
email = "[email protected]"),
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0001-7931-7470")),
person(given = "Maximilian",
family = "Pilz",
role = c("aut", "cre"),
email = "[email protected]"),
person(given = "Institute of Medical Biometry and Informatics - University of Heidelberg",
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-9685-1613")),
person(given = "Institute of Medical Biometry - University of Heidelberg",
role = c("cph")))
Description: Computation of key characteristics and plots for blinded sample size recalculation.
Continuous as well as binary endpoints are supported in superiority and non-inferiority trials.
See Baumann, Pilz, Kieser (2022) <doi:10.32614/RJ-2022-001> for a detailed description.
The implemented methods include the approaches by
Lu, K. (2019) <doi:10.1002/pst.1737>,
Kieser, M. and Friede, T. (2000) <doi:10.1002/(SICI)1097-0258(20000415)19:7%3C901::AID-SIM405%3E3.0.CO;2-L>,
Expand All @@ -41,6 +44,6 @@ Collate:
FarringtonManning.R
FarringtonManning_helper.R
RcppExports.R
RoxygenNote: 7.1.0
RoxygenNote: 7.2.3
LinkingTo:
Rcpp
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2019
YEAR: 2022
COPYRIGHT HOLDER: Institute of Medical Biometry and Informatics - University of Heidelberg
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# blindrecalc 1.0.0

* fix documentation to pass CRAN check

* add reference to R Journal publication
43 changes: 30 additions & 13 deletions R/ChiSquare.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#' Type I Error Rate
#'
#' Computes the type I error rate of designs with blinded sample size recalculation
#' or of fixed designs for one or several values of the nuisance parameter.
#' Computes the type I error rate of designs with blinded sample size
#' recalculation or of fixed designs for one or several values of the
#' nuisance parameter.
#'
#' @template methods_chisquare
#' @template recalculation
#' @template allocation_chisquare
#' @template dotdotdot
#'
#' @return One type I error rate value for every nuisance parameter and every value of n1.
#' @return One type I error rate value for every nuisance parameter and
#' every value of n1.
#'
#' @details The method is only vectorized in either \code{nuisance}
#' or \code{n1}.
Expand All @@ -23,6 +25,7 @@ setMethod("toer", signature("ChiSquare"),
function(design, n1, nuisance, recalculation,
allocation = c("exact", "approximate", "kf_approx"), ...) {
allocation <- match.arg(allocation)
# Check if input is valid
if (allocation == "exact") {
if (sum(n1 %% (design@r + 1) != 0) > 0) {
stop("No integer sample sizes.")
Expand All @@ -37,11 +40,12 @@ setMethod("toer", signature("ChiSquare"),
if (sum(design@n_max < n1) > 0) {
stop("n_max is smaller than n1.")
}

# Check whether n1 or nuisance is a vector
if ((length(n1) > 1) & (length(nuisance) > 1)) {
stop("only one of n1 and nuisance can have length > 1")
} else if (length(n1) > 1) {
if (recalculation) {
# Create matrix with total sample sizes
nmat <- lapply(n1, function(x) get_nmat_chisq(design, x, allocation, ...))
mapply(chisq_recalc_reject, n1 = n1, nmat = nmat,
MoreArgs = list(design = design, nuisance = nuisance, type = "size"))
Expand All @@ -50,13 +54,15 @@ setMethod("toer", signature("ChiSquare"),
}
} else if (length(nuisance) > 1) {
if (recalculation) {
# Create matrix with total sample sizes
nmat <- get_nmat_chisq(design, n1, allocation, ...)
sapply(nuisance, function(x) chisq_recalc_reject(design, n1, x, "size", nmat))
} else {
sapply(nuisance, function(x) chisq_fix_reject(design, n1, x, "size"))
}
} else {
if (recalculation) {
# Create matrix with total sample sizes
nmat <- get_nmat_chisq(design, n1, allocation, ...)
chisq_recalc_reject(design, n1, nuisance, "size", nmat)
} else {
Expand Down Expand Up @@ -92,6 +98,7 @@ setMethod("pow", signature("ChiSquare"),
function(design, n1, nuisance, recalculation,
allocation = c("exact", "approximate", "kf_approx"), ...) {
allocation <- match.arg(allocation)
# Check if input is valid
if (allocation == "exact") {
if (n1 %% (design@r + 1) != 0) {
stop("No integer sample sizes for first stage.")
Expand All @@ -107,10 +114,12 @@ setMethod("pow", signature("ChiSquare"),
stop("n_max is smaller than n1.")
}

# Check whether n1 or nuisance is a vector
if ((length(n1) > 1) & (length(nuisance) > 1)) {
stop("Only one of n1 and nuisance can have length > 1")
} else if (length(n1) > 1) {
if (recalculation) {
# Create matrix with total sample sizes
nmat <- lapply(n1, function(x) get_nmat_chisq(design, x, allocation, ...))
mapply(chisq_recalc_reject, n1 = n1, nmat = nmat,
MoreArgs = list(design = design, nuisance = nuisance, type = "power"))
Expand All @@ -119,13 +128,15 @@ setMethod("pow", signature("ChiSquare"),
}
} else if (length(nuisance) > 1) {
if (recalculation) {
# Create matrix with total sample sizes
nmat <- get_nmat_chisq(design, n1, allocation, ...)
sapply(nuisance, function(x) chisq_recalc_reject(design, n1, x, "power", nmat))
} else {
sapply(nuisance, function(x) chisq_fix_reject(design, n1, x, "power"))
}
} else {
if (recalculation) {
# Create matrix with total sample sizes
nmat <- get_nmat_chisq(design, n1, allocation, ...)
chisq_recalc_reject(design, n1, nuisance, "power", nmat)
} else {
Expand All @@ -143,15 +154,13 @@ setMethod("pow", signature("ChiSquare"),
#' nuisance parameter or of n1.
#'
#' @template methods_chisquare
#' @param summary Logical. If \code{TRUE} (default) a summary of the sample
#' size distribution is printed. If \code{FALSE} all sample sizes are
#' printed.
#' @template summary
#' @template plot
#' @template allocation_chisquare
#' @template dotdotdot
#'
#' @details Only sample sizes that occur with a probability of at least 0.01% are
#' considered.
#' @details Only sample sizes that occur with a probability of at least 0.01%
#' are considered.
#'
#' @return Summary and/or plot of the sample size distribution for
#' every nuisance parameter and every value of n1.
Expand All @@ -169,6 +178,7 @@ setMethod("n_dist", signature("ChiSquare"),
function(design, n1, nuisance, summary = TRUE, plot = FALSE,
allocation = c("exact", "approximate"), ...) {
allocation <- match.arg(allocation)
# Check if input is valid
if (allocation == "exact") {
if (sum(n1 %% (design@r + 1) != 0) > 0) {
stop("No integer sample sizes for first stage.")
Expand All @@ -181,9 +191,11 @@ setMethod("n_dist", signature("ChiSquare"),
stop("Nuisance has to be within [0, 1].")
}

# Check whether n1 or nuisance is a vector
if ((length(n1) > 1) & (length(nuisance) > 1)) {
stop("Only one of n1 and nuisance can have length > 1.")
} else if (length(n1) == 1) {
# Calculate possible total sample sizes and probabilities
out <- lapply(nuisance, function(x) n_distrib_chisq(design, n1, x, allocation, ...))
out <- Map(cbind, out, nuisance = nuisance)
out <- do.call("rbind", out)
Expand Down Expand Up @@ -247,6 +259,7 @@ setMethod("adjusted_alpha", signature("ChiSquare"),
function(design, n1, nuisance, nuis_ass, precision = 0.001, gamma = 0,
recalculation, allocation = c("exact", "approximate"), ...) {
allocation <- match.arg(allocation)
# Check if input is valid
if (allocation == "exact") {
if (n1 %% (design@r + 1) != 0) {
stop("No integer sample sizes for first stage.")
Expand All @@ -261,6 +274,7 @@ setMethod("adjusted_alpha", signature("ChiSquare"),

alpha_nom <- design@alpha - gamma
if (recalculation) {
# iteratively reduce the significance level until it is sufficiently small
repeat {
nmat <- get_nmat_chisq(design, n1, allocation, ...)
alpha_max <- max(sapply(nuisance,
Expand All @@ -269,6 +283,7 @@ setMethod("adjusted_alpha", signature("ChiSquare"),
design@alpha <- design@alpha - precision
}
} else {
# iteratively reduce the significance level until it is sufficiently small
repeat {
alpha_max <- max(sapply(nuisance,
function(x) chisq_fix_reject(design, n1, x, "size")))
Expand All @@ -293,10 +308,10 @@ setMethod("adjusted_alpha", signature("ChiSquare"),
#' @param design Object of class \code{ChiSquare} created by \code{setupChiSquare}.
#' @param nuisance Value of the nuisance parameter. For the
#' Chi-Squared test this is the overall response rate.
#' @param variance A character string indicating whether the "\code{heterogenous}" (default)
#' or the "\code{homogeneous}" variance formula should be used.
#' @param rounded Whether the calculated sample size should be rounded up such that
#' the allocation ratio is preserved.
#' @param variance A character string indicating whether the "\code{heterogenous}"
#' (default) or the "\code{homogeneous}" variance formula should be used.
#' @param rounded Whether the calculated sample size should be rounded up such
#' that the allocation ratio is preserved.
#' @template dotdotdot
#'
#' @return One value of the fixed sample size for every nuisance parameter
Expand All @@ -315,9 +330,11 @@ setMethod("n_fix", signature("ChiSquare"),
function(design, nuisance, variance = c("heterogeneous", "homogeneous"),
rounded = TRUE, ...) {
variance <- match.arg(variance)
# Check if input is valid
if (sum(nuisance < 0) + sum(nuisance > 1) > 0) {
stop("Nuisance has to be within [0, 1].")
}
# Use recursion if nuisance is a vector
if (length(nuisance) > 1) {
sapply(nuisance, function(x) n_fix(design = design, nuisance = x,
variance = variance, rounded = rounded, ...))
Expand Down
4 changes: 4 additions & 0 deletions R/ChiSquare_helper.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Helper function that creates a matrix with the total sample sizes
# for all possible outcomes of the internal pilot study
get_nmat_chisq <- function(design, n1, allocation, ...) {
n_c1 <- ceiling(n1 / (design@r + 1))
n_e1 <- ceiling(n1 * design@r / (design@r + 1))
Expand All @@ -21,6 +23,8 @@ get_nmat_chisq <- function(design, n1, allocation, ...) {
return(as.matrix(out.mat))
}

# Helper function that calculates the probability for all possible
# total sample sizes based on n1 and nuisance
n_distrib_chisq <- function(design, n1, nuisance, allocation, ...) {
p_e <- nuisance + design@delta / (1 + design@r)
p_c <- p_e - design@delta
Expand Down
Loading