The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

How to simulate binary data

library(NCC)

datasim_bin()

The function datasim_bin() enables data simulation of a platform trial with binary endpoint and an arbitrary number of treatment arms entering at different time points.

Assumptions

Notation

Paper Software
\(N\) n_total
\(K\) num_arms
\(d\) d
\(n\) n_arm
\(\eta_0\) p0
\(\lambda\) lambda
\(N_p\) N_peak

Usage

Input

The user specifies the number of treatment arms in the trial, the sample size per treatment arm (assumed equal) and the timing of adding arms in terms of patients recruited to the trial so far.

Output

Per default (using full=FALSE), the function outputs a dataframe with simulated trial data needed for the analysis. If the parameter full is set to TRUE, the output is a list containing an extended version of the dataframe (also including lambdas and underlying responses) and all input parameters.

Examples

# Dataset with trial data only (default) 

head(datasim_bin(num_arms = 3, n_arm = 100, d = c(0, 100, 250),
                 p0 = 0.7, OR = rep(1.8, 3), 
                 lambda = rep(0.15, 4), trend="stepwise"))
  j response treatment period
1 1        0         0      1
2 2        1         1      1
3 3        1         1      1
4 4        1         0      1
5 5        1         0      1
6 6        0         1      1
# Full dataset

head(datasim_bin(num_arms = 3, n_arm = 100, d = c(0, 100, 250),
                 p0 = 0.7, OR = rep(1.8, 3), 
                 lambda = rep(0.15, 4), trend="stepwise", full = T)$Data)
  j response treatment period         p lambda0 lambda1 lambda2 lambda3
1 1        0         0      1 0.7000000    0.15    0.15    0.15    0.15
2 2        0         1      1 0.8076923    0.15    0.15    0.15    0.15
3 3        1         1      1 0.8076923    0.15    0.15    0.15    0.15
4 4        1         0      1 0.7000000    0.15    0.15    0.15    0.15
5 5        1         0      1 0.7000000    0.15    0.15    0.15    0.15
6 6        1         1      1 0.8076923    0.15    0.15    0.15    0.15

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.