Skip to content

Commit 63a74b8

Browse files
authored
Merge pull request #3 from RCONIS/dev/friedrich_pahlke
Update documentation to use bold for randomforge and add flexible PBR
2 parents 3a18e84 + cbe9e60 commit 63a74b8

3 files changed

Lines changed: 165 additions & 2 deletions

File tree

R/pkgname.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#' The package aims to support a broad range of classical,
3434
#' covariate-adaptive, and response-adaptive techniques while
3535
#' enabling reproducibility, auditability, and methodological clarity.
36-
#' Built as part of the open *randomforge* initiative ("Innovating the
36+
#' Built as part of the open **randomforge** initiative ("Innovating the
3737
#' Future of Randomization"), the package encourages community
3838
#' collaboration, modular extensions, and contributions from academia,
3939
#' industry, and clinical researchers.

vignettes/randomforge_contribution.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,6 @@ We want to make contributing as easy and friendly as possible.
215215

216216
## Thank you
217217

218-
We appreciate your interest in contributing to the *randomforge* project.
218+
We appreciate your interest in contributing to the **randomforge** project.
219219
Your ideas and contributions help shape a more open, transparent, and
220220
community-driven future for clinical trial randomization in R.
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
---
2+
title: "Randomization with Flexible Block Sizes with randomforge"
3+
author: "Friedrich Pahlke"
4+
date: "`r Sys.Date()`"
5+
output: rmarkdown::html_vignette
6+
vignette: >
7+
%\VignetteIndexEntry{Randomization with Flexible Block Sizes with randomforge}
8+
%\VignetteEngine{knitr::rmarkdown}
9+
%\VignetteEncoding{UTF-8}
10+
---
11+
12+
```{r setup, include = FALSE}
13+
knitr::opts_chunk$set(
14+
collapse = TRUE,
15+
comment = "#>"
16+
)
17+
```
18+
19+
## Introduction
20+
21+
This vignette provides a practical example for **randomforge**.
22+
It demonstrates:
23+
24+
- How to define treatment arms
25+
- How to configure project-level randomization
26+
- How do you implement permuted block randomization (PBR) with a fixed starting
27+
block size and continuation with variable block sizes
28+
- How to perform quality control of random values
29+
- How to extract and inspect the generated randomization list
30+
31+
```{r, include = FALSE}
32+
knitr::opts_chunk$set(echo = TRUE)
33+
options(scipen = 999)
34+
```
35+
36+
## Loading the randomforge Package
37+
38+
```{r}
39+
library(randomforge)
40+
```
41+
42+
## Trial Setup
43+
44+
### Treatment Arms
45+
46+
```{r}
47+
treatmentArmIds = c("Treatment", "Control")
48+
```
49+
50+
### Maximum Number of Subjects per Center
51+
52+
```{r}
53+
maxNumberOfSubjects <- 40
54+
```
55+
56+
### Seed
57+
58+
The seeds in this example will be generated via
59+
[random.org](https://www.random.org/)
60+
61+
```{r}
62+
#| eval: FALSE
63+
seed <- createSeed()
64+
seed
65+
```
66+
67+
```{r}
68+
#| echo: FALSE
69+
seed <- 1379678
70+
seed
71+
```
72+
73+
## Creating Project and Configuration
74+
75+
```{r}
76+
randomDataBase <- getRandomDataBase()
77+
78+
randomProject <- getRandomProject(name = "Flexible PBR Example Trial")
79+
randomDataBase$persist(randomProject)
80+
81+
randomConfiguration <- getRandomConfiguration(
82+
randomProject = randomProject,
83+
treatmentArmIds = treatmentArmIds,
84+
seed = seed
85+
)
86+
randomDataBase$persist(randomConfiguration)
87+
88+
ravService <- getRandomAllocationValueService()
89+
```
90+
91+
## Initial Randomization Using Fixed Block Size
92+
93+
### Define Initial Block Length
94+
95+
```{r, message = FALSE}
96+
initialBlockLength <- 8
97+
randomMethod <- getRandomMethodPBR(
98+
blockSizes = getBlockSizes(treatmentArmIds, initialBlockLength)
99+
)
100+
for (i in 1:initialBlockLength) {
101+
suppressMessages(getNextRandomResult(
102+
randomDataBase, randomProject, randomMethod, ravService
103+
))
104+
}
105+
```
106+
107+
## Variable Block Sizes for Remaining Subjects
108+
109+
### Define Candidate Block Sizes
110+
111+
```{r}
112+
blockSizes <- getBlockSizes(treatmentArmIds, c(4, 6))
113+
blockSizeRandomizer <- getRandomBlockSizeRandomizer(
114+
blockSizes = blockSizes,
115+
seed = 2758500)
116+
blockSizeRandomizer$initRandomValues(numberOfBlockSizes = length(blockSizes))
117+
```
118+
119+
### Randomize Remaining Subjects
120+
121+
```{r, message = FALSE}
122+
randomMethod <- getRandomMethodPBR(
123+
blockSizes = blockSizes,
124+
fixedBlockDesignEnabled = FALSE,
125+
blockSizeRandomizer = blockSizeRandomizer
126+
)
127+
128+
for (i in 1:(maxNumberOfSubjects - initialBlockLength)) {
129+
suppressMessages(getNextRandomResult(
130+
randomDataBase, randomProject, randomMethod, ravService
131+
))
132+
}
133+
```
134+
135+
## Quality Control
136+
137+
### Distribution of Used Random Values
138+
139+
```{r}
140+
plot(ravService)
141+
```
142+
143+
No significant deviation from a uniform distribution is detected (p > 0.05).
144+
145+
### Distribution of All Generated Random Values
146+
147+
```{r}
148+
plot(ravService, usedValuesOnly = FALSE)
149+
```
150+
151+
## Output: Randomization List
152+
153+
```{r}
154+
randomList <- as.data.frame(randomDataBase)
155+
knitr::kable(randomList)
156+
```
157+
158+
## System Information
159+
160+
- System: `r R.version.string`
161+
- randomforge version: `r packageVersion("randomforge")`
162+
- Platform: `r R.version$platform`
163+
- Working directory: `r getwd()`

0 commit comments

Comments
 (0)