diff --git a/.Rbuildignore b/.Rbuildignore index 81aba21..57ca929 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,3 +12,4 @@ manifest.json ^libs$ ^\.github$ ^cran-comments\.md$ +^CRAN-SUBMISSION$ diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml new file mode 100644 index 0000000..74ec7b0 --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,95 @@ +# R-hub's generic GitHub Actions workflow file. It's canonical location is at +# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml +# You can update this file to a newer version using the rhub2 package: +# +# rhub::rhub_setup() +# +# It is unlikely that you need to modify this file manually. + +name: R-hub +run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" + +on: + workflow_dispatch: + inputs: + config: + description: 'A comma separated list of R-hub platforms to use.' + type: string + default: 'linux,windows,macos' + name: + description: 'Run name. You can leave this empty now.' + type: string + id: + description: 'Unique ID. You can leave this empty now.' + type: string + +jobs: + + setup: + runs-on: ubuntu-latest + outputs: + containers: ${{ steps.rhub-setup.outputs.containers }} + platforms: ${{ steps.rhub-setup.outputs.platforms }} + + steps: + # NO NEED TO CHECKOUT HERE + - uses: r-hub/actions/setup@v1 + with: + config: ${{ github.event.inputs.config }} + id: rhub-setup + + linux-containers: + needs: setup + if: ${{ needs.setup.outputs.containers != '[]' }} + runs-on: ubuntu-latest + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.containers) }} + container: + image: ${{ matrix.config.container }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/run-check@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + + other-platforms: + needs: setup + if: ${{ needs.setup.outputs.platforms != '[]' }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.platforms) }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/setup-r@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/run-check@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} diff --git a/DESCRIPTION b/DESCRIPTION index 9c29906..b31152f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,7 +11,7 @@ Authors@R: family = "Baillie", email = "mark.baillie@novartis.com", role = c("aut"), - comment = c(ORCID = "000-0002-5618-0667") + comment = c(ORCID = "0000-0002-5618-0667") ), person(given = "Craig", family = "Wang", diff --git a/NAMESPACE b/NAMESPACE index 391b9ef..41614af 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,7 @@ # Generated by roxygen2: do not edit by hand +S3method(sanitize_model,default) +S3method(sanitize_model,glm) export(apply_contrast) export(average_predictions) export(estimate_varcov) diff --git a/R/sanitize.R b/R/sanitize.R index 613b121..9ff654d 100644 --- a/R/sanitize.R +++ b/R/sanitize.R @@ -14,6 +14,7 @@ #' \link[stats]{glm} with binomial family canonical link is supported. #' @param ... arguments passed to or from other methods. #' @return if model is non-compliant will throw warnings or errors. +#' @keywords internal sanitize_model <- function(model, ...) { UseMethod("sanitize_model") } @@ -21,13 +22,16 @@ sanitize_model <- function(model, ...) { #' (internal) Sanitize a glm model #' @param model a \link[stats]{glm} with binomial family canonical link. #' @param trt the name of the treatment variable on the right-hand side of the formula in a \link[stats]{glm}. +#' @param ... ignored. #' @return if model is non-compliant will throw warnings or errors. #' @importFrom stats model.frame model.matrix terms +#' @keywords internal +#' @export #' @examples \dontrun{ #' fit1 <- glm(aval ~ trtp + bl_cov, family = "binomial", data = trial01) #' sanitize_model(fit1, "trtp") #' } -sanitize_model.glm <- function(model, trt) { +sanitize_model.glm <- function(model, trt, ...) { # sanitize variable sanitize_variable(model, trt) @@ -84,7 +88,8 @@ sanitize_model.glm <- function(model, trt) { return(model) } -sanitize_model.default <- function(model, trt) { +#' @export +sanitize_model.default <- function(model, trt, ...) { if (!inherits(model, "glm")) { msg <- c(sprintf('Model of class "%s" is not supported.', class(model)[1])) stop(msg, call. = FALSE) @@ -95,6 +100,7 @@ sanitize_model.default <- function(model, trt) { #' @param model an \link[stats]{glm} model object. #' @param trt the name of the treatment variable on the right-hand side of the glm formula. #' @return if model and variable are non-compliant, will throw warnings or error. +#' @keywords internal sanitize_variable <- function(model, trt) { data <- .get_data(model) diff --git a/README.md b/README.md index f4d0404..4bc9ef1 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) -[![CRAN status](https://www.r-pkg.org/badges/version/beeca)](https://CRAN.R-project.org/package=beeca) +[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) +![CRAN status](https://www.r-pkg.org/badges/version/beeca) [![R-CMD-check](https://github.com/openpharma/beeca/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/openpharma/beeca/actions/workflows/R-CMD-check.yaml) @@ -23,7 +23,7 @@ Motivated by the recent [FDA guidance (2023)](https://www.fda.gov/regulatory-inf ## Scope -The package is designed to estimate marginal (unconditional) estimands in a binary endpoint setting with covariate adjustment. It is suited for 2-arm clinical trials with or without covariate adaptive (stratified permuted block or biased coin) randomization where the summary measure of the marginal estimand is one of (risk difference, odds ratio, risk ratio, log odds ratio, log risk ratio). For practical considerations on the implications of covariate adjustment in superiority vs non-inferiority trials, please see [Nicholas et al. (2015)](https://doi.org/10.1002%2Fsim.6447) and [Morris et al. (2022)](https://doi.org/10.1186/s13063-022-06097-z). +The package is designed to estimate marginal (unconditional) estimands in a binary endpoint setting with covariate adjustment. It is suited for 2-arm clinical trials with or without covariate adaptive (stratified permuted block or biased coin) randomization where the summary measure of the marginal estimand is one of (risk difference, odds ratio, risk ratio, log odds ratio, log risk ratio). For practical considerations on the implications of covariate adjustment in superiority vs non-inferiority trials, please see [Nicholas et al. (2015)](https://doi.org/10.1002/sim.6447) and [Morris et al. (2022)](https://doi.org/10.1186/s13063-022-06097-z). ## Example @@ -69,7 +69,7 @@ Further development of covariate adjustment software is by the [Software Subteam * FDA. 2023. "Adjusting for Covariates in Randomized Clinical Trials for Drugs and Biological Products. Final Guidance for Industry." -* Ge, Miaomiao, L Kathryn Durham, R Daniel Meyer, Wangang Xie, and Neal Thomas. 2011. "Covariate-Adjusted Difference in Proportions from Clinical Trials Using Logistic Regression and Weighted Risk Differences." *Drug Information Journal: DIJ/Drug Information Association* 45: 481--93. +* Ge, Miaomiao, L Kathryn Durham, R Daniel Meyer, Wangang Xie, and Neal Thomas. 2011. "Covariate-Adjusted Difference in Proportions from Clinical Trials Using Logistic Regression and Weighted Risk Differences." *Drug Information Journal: DIJ/Drug Information Association* 45: 481--93. * Magirr, Dominic, Mark Baillie, Craig Wang, and Alexander Przybylski. 2024. “Estimating the Variance of Covariate-Adjusted Estimators of Average Treatment Effects in Clinical Trials with Binary Endpoints.” OSF. May 16. . diff --git a/man/beeca-package.Rd b/man/beeca-package.Rd index 676d7da..f049c52 100644 --- a/man/beeca-package.Rd +++ b/man/beeca-package.Rd @@ -20,7 +20,7 @@ Useful links: Authors: \itemize{ - \item Mark Baillie \email{mark.baillie@novartis.com} (\href{https://orcid.org/000-0002-5618-0667}{ORCID}) + \item Mark Baillie \email{mark.baillie@novartis.com} (\href{https://orcid.org/0000-0002-5618-0667}{ORCID}) \item Craig Wang \email{craig.wang@novartis.com} (\href{https://orcid.org/0000-0003-1804-2463}{ORCID}) \item Dominic Magirr \email{dominic.magirr@novartis.com} } diff --git a/man/sanitize_model.Rd b/man/sanitize_model.Rd index 7545720..ce9791d 100644 --- a/man/sanitize_model.Rd +++ b/man/sanitize_model.Rd @@ -24,3 +24,4 @@ and mode convergence. Currently it supports models with a binomial family and canonical logit link. } +\keyword{internal} diff --git a/man/sanitize_model.glm.Rd b/man/sanitize_model.glm.Rd index cf3b7c6..9494433 100644 --- a/man/sanitize_model.glm.Rd +++ b/man/sanitize_model.glm.Rd @@ -4,12 +4,14 @@ \alias{sanitize_model.glm} \title{(internal) Sanitize a glm model} \usage{ -\method{sanitize_model}{glm}(model, trt) +\method{sanitize_model}{glm}(model, trt, ...) } \arguments{ \item{model}{a \link[stats]{glm} with binomial family canonical link.} \item{trt}{the name of the treatment variable on the right-hand side of the formula in a \link[stats]{glm}.} + +\item{...}{ignored.} } \value{ if model is non-compliant will throw warnings or errors. @@ -23,3 +25,4 @@ fit1 <- glm(aval ~ trtp + bl_cov, family = "binomial", data = trial01) sanitize_model(fit1, "trtp") } } +\keyword{internal} diff --git a/man/sanitize_variable.Rd b/man/sanitize_variable.Rd index 37cc7be..b7111da 100644 --- a/man/sanitize_variable.Rd +++ b/man/sanitize_variable.Rd @@ -17,3 +17,4 @@ if model and variable are non-compliant, will throw warnings or error. \description{ (internal) Sanitize function to check model and data } +\keyword{internal} diff --git a/vignettes/estimand_and_implementations.Rmd b/vignettes/estimand_and_implementations.Rmd index b36a024..65674eb 100644 --- a/vignettes/estimand_and_implementations.Rmd +++ b/vignettes/estimand_and_implementations.Rmd @@ -245,12 +245,12 @@ if (requireNamespace("RobinCar", versionCheck = list(name = "RobinCar", op = "== * Arel-Bundock V (2023). _marginaleffects: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests_. R package version 0.14.0, - . + . * Bannick M, Ye T, Yi Y, Bian F (2024). _RobinCar: Robust Estimation and Inference in Covariate-Adaptive Randomization_. R package version 0.2.0, . -* European Medicines Agency. 2020. "ICH E9 (R1) addendum on estimands and sensitivity analysis in clinical trials to the guideline on statistical principles for clinical trials." +* European Medicines Agency. 2020. "ICH E9 (R1) addendum on estimands and sensitivity analysis in clinical trials to the guideline on statistical principles for clinical trials." * FDA. 2023. "Adjusting for Covariates in Randomized Clinical Trials for Drugs and Biological Products. Final Guidance for Industry."