-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
85 lines (58 loc) · 3.08 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
<!-- badges: start -->
[![R-CMD-check](https://github.com/imbi-heidelberg/blindrecalc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/imbi-heidelberg/blindrecalc/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/imbi-heidelberg/blindrecalc/branch/master/graph/badge.svg)](https://app.codecov.io/gh/imbi-heidelberg/blindrecalc?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/blindrecalc)](https://cran.r-project.org/package=blindrecalc)
<!-- badges: end -->
# blindrecalc
blindrecalc facilitates the planning of a clinical trial with an internal pilot study and blinded sample size recalculation.
## Installation
Install the current CRAN version of blindrecalc with:
``` r
install.packages("blindrecalc")
```
Or install the development version from GitHub with:
``` r
# install.packages("devtools")
devtools::install_github("imbi-heidelberg/blindrecalc")
```
## Usage
blindrecalc currently supports continuous and binary endpoints for superiority and non-inferiority test problems. Continuous endpoints are analyzed using Student's t-test, binary endpoints are analyzed using the Chi-squared test for superiority trials and the Farrington-Manning test for non-inferiority trials. Each design can be defined using a setup-function: `setupStudent`, `setupChiSquare` and `setupFarringtonManning`. For example, to setup a superiority trial with a continuous endpoint:
```{r}
library(blindrecalc)
design <- setupStudent(alpha = 0.025, beta = 0.2, r = 1, delta = 5)
```
`alpha` and `beta` refer to the type 1 and type 2 error rate, `r` is the sample size allocation ratio and `delta`is the effect size between the null and the alternative hypothesis. For a non-inferiority trial with a shifted t-test, additionally the argument `delta_NI` must be specified.
To calculate the sample size for a fixed design, use `n_fix`:
```{r}
n_fix(design, nuisance = c(5, 10, 15))
```
`nuisance` refers to the nuisance parameter of the design, which in the case of the t-test is the common variance of the outcome variable.
To calculate the type 1 error rate of the design using blinded sample size recalculation, use `toer`:
```{r}
toer(design, n1 = c(30, 60, 90), nuisance = 10, recalculation = TRUE)
```
`n1` refers to the sample size of the internal pilot study `recalculation = TRUE` specifices that the type 1 error rate for a design with blinded sample size recalculation should be computed.
To compute the power of the design, use `pow`:
```{r}
pow(design, n1 = c(30, 60, 90), nuisance = 10, recalculation = TRUE)
```
To calculate the distribution of the total sample sizes use `n_dist`:
```{r}
n_dist(design, n1 = c(30, 60, 90), nuisance = 10)
```
## Reference
A paper describing blindrecalc can be found [here](https://journal.r-project.org/articles/RJ-2022-001/).