MyNixOS website logo
Description

Simulation-Based Assessment of Covariate Adjustment in Randomized Trials.

Monte Carlo simulation framework for different randomized clinical trial designs with a special emphasis on estimators based on covariate adjustment. The package implements regression-based covariate adjustment (Rosenblum & van der Laan (2010) <doi:10.2202/1557-4679.1138>) and a one-step estimator (Van Lancker et al (2024) <doi:10.48550/arXiv.2404.11150>) for trials with continuous, binary and count outcomes. The estimation of the minimum sample-size required to reach a specified statistical power for a given estimator uses bisection to find an initial rough estimate, followed by stochastic approximation (Robbins-Monro (1951) <doi:10.1214/aoms/1177729586>) to improve the estimate, and finally, a grid search to refine the estimate in the neighborhood of the current best solution.

complete-checks vignettes slowtests

carts package carts website

The carts R package is a simulation tool for exploring various estimators within a clinical trial context under differing assumptions. The package provides a user-friendly interface for defining a clinical trial object with different choices for its design, patient and endpoint distributions, and treatment effect estimators. Once a clinical trial object is specified, the package provides the functionality for estimating the power with Monte Carlo simulations.

Example

Here we emulate a simple parallel trial design with both observed and unobserved covariates. The treatment effect is estimated using an estimator based on the efficient influence function (EIF) where we adjust for the observed covariate x.

The necessary sample-size to achieve 90% power for a one-sided superiority test is estimated using a variation of a bisection and a Robbins-Monro stochastic approximation algorithm with parallelized computations

library("carts")

## Loading required package: lava

library("data.table")
future::plan(future::multicore)
## progressr::handlers(global = TRUE)
## progressr::handlers(progressr::handler_cli)

## Covariates at baseline
x0 <- function(n, pa = 0.5, gamma.var = 0.7, ...) {
  data.table(
    a = rbinom(n, 1, pa), ## Treatment
    x = rnorm(n), ## Obs.
    z = log(rgamma(n, shape = 1 / gamma.var, rate = 1 / gamma.var)) ## Unobs.
  )
}
## Outcome model
outcome <- function(data, b = c(log(2.5), log(0.38)), ...) {
  X <- model.matrix(~ 1 + a, data)
  rate <- exp(X %*% b + with(data, x + z))
  data.table(y = rpois(length(rate), rate))
}

qmodel  <- targeted::learner_glm(y ~ a * x, family = poisson)
m <- Trial$new(
  covariates = x0,
  outcome = outcome,
  estimators = list(adj = est_adj(qmodel))
  )

## Sample-size estimation via Stochastic Approximation
e <- m$estimate_samplesize(R = 1000)
print(e)

## ── Estimated sample-size to reach 90% power ── 
## 
## n = 98 (actual estimated power≈91.18%)

Installation

The package can be installed on all unix systems from the command line via make install. Already installed R packages that are dependencies of carts will not be upgrade with make install. Instead, use the make upgrade rule to upgrade all dependencies, followed by the installation of the package.

Project organization

We use the dev branch for development and the main branch for stable releases. All releases follow semantic versioning, are tagged and notable changes are reported in the NEWS.md file.

I Have a Question / I Want to Report a Bug

If you want to ask questions, require help or clarification, or report a bug, we recommend to either contact a maintainer directly or the following:

  • Open an Issue.
  • Provide as much context as you can about what you’re running into.
  • Provide project and platform versions, depending on what seems relevant.

We will then take care of the issue as soon as possible.

Maintainers

Benedikt Sommer ([email protected])
Klaus Kähler Holst ([email protected])

Metadata

Version

0.1.0

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows