trial: Run a simulated trial

Description Usage Arguments Details Value Author(s) Examples

View source: R/trial.R

Description

Runs the all analyses for a coadministration trial

Usage

1
2
3
4
5
6
7
trial <- function(
    scenario = 0,
    looks = c(200, 300, 400, 500), n_per_yr = 2000, delta_ni = 0.2, 
    beta = NULL, sd_id = 0.5, p_miss = 0.0,
    Ncoad = 2, Nbrand = 2, Ncohort = 2, 
    a0 = 1, b0 = 1, eta0 = 0.01, keep_post_sampls = FALSE
    )

Arguments

scenario

an id for designating the current scenario

looks

sample size to run interim and final analyses

n_per_yr

enrollment per year

delta_ni

non-inferiority margin on probability scale

beta

simulation parameters, see pr_adverse_evt

sd_id

subject level variation

p_miss

probability of missingness

Ncoad

number of treatments - presently fixed to 2

Nbrand

number of brands - presently fixed to 2

Ncohort

number of cohorts - presently fixed to 2

a0

hyperparameter for beta prior

b0

hyperparameter for beta prior

eta0

hyperparameter for exponential prior

keep_post_sampls

returns posterior samples (or not)

Details

After setting up some preliminary data structures, this function simulates the data for this trial then proceeds through the interim analyses. At each interim, the data accrued to date is used to model the adverse events for the coadministered covid and flu and the coadministered covid and placebo for each brand and cohort (where cohort denotes being enrolled at either dose 1 of the covid vaccine or dose 2 of the covid vaccine).

After all the interim analyses have been completed, a final analysis is run on all the data after followup is completed then the trial dataset, analysis summaries and config are returned to the user.

Best used in parallel per the example.

Value

List of data and parameters used in the trial and trial analysis results

d

Simulated dataset used for trial

lpar

Simulation parameters

lr

Summaries of analysis results

lpost

Posterior samples (if requested) otherwise NULL

Author(s)

Mark

Examples

 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
## Not run: 
library(data.table)
library(coadministr)
# Same incr in Pr AE in CVD+FLU regardless of whether cvd dose 1 and dose 2
# cvd+flu combination increases pr AE by 0.1 for AZ
# cvd+flu combination increases pr AE by 0.15 for PF
b <- pr_adverse_evt(pae_pbo = 0.02, pae_flu = 0.05, 
                    pae_coad_az = 0.1, pae_coad_pf = 0.15,
                    pae_az1 = 0.5, pae_az2 = 0.4,
                    pae_pf1 = 0.3, pae_pf2 = 0.5)
d <- get_data(J = 1000,
              beta = b,
              sd_id = 0.5,
              n_per_yr = 1000,
              p_miss = 0.1)
results <- coadministr::trial(
   scenario = 1,
   looks = seq(500, 1000, by = 100),
   n_per_yr = 2000,
   delta_ni = 0.2, 
   beta = b,
   sd_id = 0.5,
   p_miss = 0.1,
   Ncoad = 2,
   Nbrand = 2,
   Ncohort = 2,
   a0 = 1,
   b0 = 1,
   eta0 = 0.01,
   keep_post_sampls = TRUE
 )
 # Note that results$lpost[[1]]$pflu[, , 1] contains draws for AZ coad CVD+FLU 
 # at covid dose 1 and dose 2 in cols 1 and 2 respectively.
 # ditto for results$lpost[[1]]$pflu[, , 2] but for PF
 # ditto for results$lpost[[1]]$ppbo[, , 1] but for AZ CVD+PBO
 # ditto for results$lpost[[1]]$ppbo[, , 2] but for PF CVD+PBO
 str(results$lpost[[1]])
 post_to_data_table(results$lpost[[1]])

## End(Not run)
## Not run: 
library(parallel)
library(data.table)
ncores <- 10
results <- parallel::mclapply(X=1:10, mc.cores = ncores, FUN=function(x) {
 # should use tryCatch block
 b <- pr_adverse_evt(pae_pbo = 0.02, pae_flu = 0.05, pae_coad = 0.1)
 coadministr::trial(
   scenario = 1,
   looks = seq(500, 1000, by = 100),
   n_per_yr = 2000,
   delta_ni = 0.2, 
   beta = b,
   sd_id = 0.5,
   p_miss = 0.1,
   Ncoad = 2,
   Nbrand = 2,
   Ncohort = 2,
   a0 = 1,
   b0 = 1,
   eta0 = 0.01
 )
})

## End(Not run)

maj-biostat/coadministr documentation built on Dec. 21, 2021, 1:44 p.m.