Skip to contents

We emulate a randomized-controlled trial setting where at any given sample size, there exists the number of patients enrolled in either standard of care (SOC) or control arm, and a treatment or experimental arm. The allocation of patients will depend on the randomization ratio set by the user and is rounded to the next higher integer. Therefore the sequence of patients is determined from the start, such that the number of patients in both arms is constant across trial simulations, however the number of patients within the control and treatment arm is determined by the randomisation ratio. Interim looks are for sample sizes below that of the final sample size.

Usage

ocRctPostprobDist(
  nnE,
  pE,
  pS,
  deltaE,
  deltaF,
  relativeDelta = FALSE,
  tL,
  tU,
  parE = c(a = 1, b = 1),
  parS = c(a = 1, b = 1),
  randRatio = 1,
  sim,
  wiggle = FALSE,
  nnF = nnE
)

Arguments

nnE

(numeric):
sample size or sizes where study can be stopped for Efficacy decision. If different for Futility decision, specify in nnF.

pE

(number):
Response rate in Treatment group.

pS

(number):
Response rate in Control group.

deltaE

(number):
margin by which the response rate in the treatment group should be better than in the standard of care or control or S group in Efficacy looks only. Note that this can also be negative as well.

deltaF

(number):
margin by which the response rate in the treatment group should be better than in the standard of care or control or S group in Futility looks only. Note that this can also be negative as well.

relativeDelta

(flag):
If TRUE, then a relativeDelta is used. Represents that a minimum response rate in magnitude of delta of the S non-responding patients is included as the margin between treatment and control group. See note.

tL

(number):
posterior probability threshold for being below p0.

tU

(number):
posterior probability threshold for being above p1.

parE

(numeric):
alpha and beta parameters for the prior on the treatment population. Default set at alpha = 1, beta = 1, or uniform prior.

parS

(numeric or matrix):
parameters for beta distribution. If it is a matrix, it needs to have 2 columns, and each row corresponds to each component of a beta-mixture distribution for the S group. See details.

randRatio

(numeric):
The randomisation ratio between treatment and control. Must be greater than 0 and maximum of 1.

sim

(number):
number of simulations.

wiggle

(flag):
generate random look locations (not default). if TRUE, optional to specify dist (see @details).

nnF

(numeric):
sample size or sizes where study can be stopped for Futility decision if different from Efficacy decision.

Details

Final looks are only performed at the maximum sample size.

At each interim or final look, a futility or efficacy or both can be performed.

The rules for Stop, Go and Gray Zone (where applicable), and use of beta priors are the same as in ocPostprobDist() where the only difference here is to emulate a randomized-controlled trial setting.

The returned value is a list with the following elements:

  • oc: matrix with operating characteristics with the following details:

  • ExpectedN: expected number of patients in the trials in both treatment and SOC group

  • ExpectedNactive : the mean of the number of patients in treatment arm

  • ExpectedNcontrol: the mean of the number of patients in control arm

  • PrStopEarly: probability to stop the trial early (before reaching the maximum sample size)

  • PrEarlyEff: probability of Early Go decision

  • PrEarlyFut: probability of Early Stop decision

  • PrEfficacy: probability of Go decision

  • PrFutility: probability of Stop decision

  • PrGrayZone: probability of Evaluate or "Gray Zone" decision (between Go and Stop)

  • Decision : numeric of results with TRUE as Go, FALSE as Stop and NA as Evaluate decision.

  • SampleSize : numeric of sample sizes from nnE or nnF or both.

  • wiggled_nnE : user input for nnE with random distance applied.

  • wiggled_nnF : user input for nnF with random distance applied.

  • wiggled_dist : magnitude of random distance applied in order of input looks.

  • params : all user input arguments.

Examples

# When `relativeDelta = TRUE`:
set.seed(2000)
ocRctPostprobDist(
  nnE = c(10, 20, 30),
  pE = 0.4,
  pS = 0.3,
  deltaE = 0.15,
  deltaF = 0.05,
  relativeDelta = TRUE,
  tL = 0.2,
  tU = 0.8,
  parE = c(a = 1, b = 1),
  parS = c(a = 1, b = 1),
  randRatio = 1,
  sim = 50,
  wiggle = FALSE,
  nnF = c(10, 20, 30)
)
#> Warning: Advise to use sim >= 50000 to achieve convergence
#> $oc
#>   ExpectedN PrStopEarly PrEarlyEff PrEarlyFut PrEfficacy PrFutility PrGrayZone
#> 1      12.2        0.94        0.2       0.74       0.22       0.78          0
#>   ExpectedNactive ExpectedNcontrol
#> 1            6.14             6.06
#> 
#> $ExpectedN
#> [1] 12.2
#> 
#> $ExpectedNactive
#> [1] 6.14
#> 
#> $ExpectedNcontrol
#> [1] 6.06
#> 
#> $Decision
#>  [1]  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
#> [13] FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE
#> [25] FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE
#> [37]  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE
#> [49] FALSE FALSE
#> 
#> $SampleSize
#>  [1] 20 10 10 30 10 10 10 30 10 10 20 10 10 30 10 10 10 10 20 10 10 10 10 10 10
#> [26] 10 10 10 10 10 10 20 10 10 10 10 10 10 10 10 10 10 10 10 10 20 10 10 10 10
#> 
#> $SampleSizeActive
#>  [1] 10  5  5 15  5  6  5 15  4  3  8  5  4 15  6  7  6  6  9  4  3  5  7  5  4
#> [26]  7  6  4  4  5  7 11  8  5  6  6  4  4  4  6  6  7  3  3  3 10  7  3  5  6
#> 
#> $SampleSizeControl
#>  [1] 10  5  5 15  5  4  5 15  6  7 12  5  6 15  4  3  4  4 11  6  7  5  3  5  6
#> [26]  3  4  6  6  5  3  9  2  5  4  4  6  6  6  4  4  3  7  7  7 10  3  7  5  4
#> 
#> $union_nn
#> [1] 10 20 30
#> 
#> $wiggled_nnE
#> [1] 10 20 30
#> 
#> $wiggled_nnF
#> [1] 10 20 30
#> 
#> $wiggle_dist
#> [1] 0
#> 
#> $params
#> $params[[1]]
#> ocRctPostprobDist
#> 
#> $params$nnE
#> c(10, 20, 30)
#> 
#> $params$pE
#> [1] 0.4
#> 
#> $params$pS
#> [1] 0.3
#> 
#> $params$deltaE
#> [1] 0.15
#> 
#> $params$deltaF
#> [1] 0.05
#> 
#> $params$relativeDelta
#> [1] TRUE
#> 
#> $params$tL
#> [1] 0.2
#> 
#> $params$tU
#> [1] 0.8
#> 
#> $params$parE
#> c(a = 1, b = 1)
#> 
#> $params$parS
#> c(a = 1, b = 1)
#> 
#> $params$randRatio
#> [1] 1
#> 
#> $params$sim
#> [1] 50
#> 
#> $params$wiggle
#> [1] FALSE
#> 
#> $params$nnF
#> c(10, 20, 30)
#> 
#> 

# When `relativeDelta = FALSE`:
set.seed(2000)
ocRctPostprobDist(
  nnE = c(10, 20, 30),
  pE = 0.4,
  pS = 0.3,
  deltaE = 0.15,
  deltaF = 0.05,
  relativeDelta = FALSE,
  tL = 0.2,
  tU = 0.8,
  parE = c(a = 1, b = 1),
  parS = c(a = 1, b = 1),
  randRatio = 1,
  sim = 50,
  wiggle = FALSE,
  nnF = c(10, 20, 30)
)
#> Warning: Advise to use sim >= 50000 to achieve convergence
#> $oc
#>   ExpectedN PrStopEarly PrEarlyEff PrEarlyFut PrEfficacy PrFutility PrGrayZone
#> 1      12.8        0.92       0.22        0.7       0.24       0.74       0.02
#>   ExpectedNactive ExpectedNcontrol
#> 1            6.48             6.32
#> 
#> $ExpectedN
#> [1] 12.8
#> 
#> $ExpectedNactive
#> [1] 6.48
#> 
#> $ExpectedNcontrol
#> [1] 6.32
#> 
#> $Decision
#>  [1]  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
#> [13]    NA  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE
#> [25] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE
#> [37]  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE
#> [49] FALSE FALSE
#> 
#> $SampleSize
#>  [1] 20 10 10 30 10 10 10 30 10 10 20 10 30 30 10 10 10 10 20 10 10 10 10 10 10
#> [26] 20 10 10 10 10 10 20 10 10 10 10 10 10 10 10 10 10 10 10 10 20 10 10 10 10
#> 
#> $SampleSizeActive
#>  [1] 10  5  5 15  5  6  5 15  4  3  8  5 15 15  6  7  6  6  9  4  3  5  7  5  4
#> [26] 13  6  4  4  5  7 11  8  5  6  6  4  4  4  6  6  7  3  3  3 10  7  3  5  6
#> 
#> $SampleSizeControl
#>  [1] 10  5  5 15  5  4  5 15  6  7 12  5 15 15  4  3  4  4 11  6  7  5  3  5  6
#> [26]  7  4  6  6  5  3  9  2  5  4  4  6  6  6  4  4  3  7  7  7 10  3  7  5  4
#> 
#> $union_nn
#> [1] 10 20 30
#> 
#> $wiggled_nnE
#> [1] 10 20 30
#> 
#> $wiggled_nnF
#> [1] 10 20 30
#> 
#> $wiggle_dist
#> [1] 0
#> 
#> $params
#> $params[[1]]
#> ocRctPostprobDist
#> 
#> $params$nnE
#> c(10, 20, 30)
#> 
#> $params$pE
#> [1] 0.4
#> 
#> $params$pS
#> [1] 0.3
#> 
#> $params$deltaE
#> [1] 0.15
#> 
#> $params$deltaF
#> [1] 0.05
#> 
#> $params$relativeDelta
#> [1] FALSE
#> 
#> $params$tL
#> [1] 0.2
#> 
#> $params$tU
#> [1] 0.8
#> 
#> $params$parE
#> c(a = 1, b = 1)
#> 
#> $params$parS
#> c(a = 1, b = 1)
#> 
#> $params$randRatio
#> [1] 1
#> 
#> $params$sim
#> [1] 50
#> 
#> $params$wiggle
#> [1] FALSE
#> 
#> $params$nnF
#> c(10, 20, 30)
#> 
#> 

# Only one Futility look:
set.seed(2000)
ocRctPostprobDist(
  nnE = c(10, 20, 30),
  pE = 0.4,
  pS = 0.3,
  deltaE = 0.15,
  deltaF = 0.05,
  relativeDelta = FALSE,
  tL = 0.2,
  tU = 0.8,
  parE = c(a = 1, b = 1),
  parS = c(a = 1, b = 1),
  randRatio = 1,
  sim = 50,
  wiggle = FALSE,
  nnF = 30
)
#> Warning: Advise to use sim >= 50000 to achieve convergence
#> $oc
#>   ExpectedN PrStopEarly PrEarlyEff PrEarlyFut PrEfficacy PrFutility PrGrayZone
#> 1        26        0.24       0.24          0       0.26       0.48       0.26
#>   ExpectedNactive ExpectedNcontrol
#> 1           12.98            13.02
#> 
#> $ExpectedN
#> [1] 26
#> 
#> $ExpectedNactive
#> [1] 12.98
#> 
#> $ExpectedNcontrol
#> [1] 13.02
#> 
#> $Decision
#>  [1]  TRUE FALSE FALSE FALSE    NA  TRUE    NA FALSE FALSE    NA FALSE FALSE
#> [13]    NA  TRUE    NA FALSE    NA FALSE  TRUE FALSE  TRUE FALSE  TRUE    NA
#> [25]    NA  TRUE    NA  TRUE    NA  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE
#> [37]  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE    NA    NA FALSE  TRUE
#> [49]    NA FALSE
#> 
#> $SampleSize
#>  [1] 20 30 30 30 30 10 30 30 30 30 30 30 30 30 30 30 30 30 20 30 20 30 10 30 30
#> [26] 20 30 10 30 10 30 30 30 30 30 10 10 30 30 30 30 30 10 30 30 30 30 10 30 30
#> 
#> $SampleSizeActive
#>  [1] 10 15 15 15 15  6 15 15 15 15 15 15 15 15 15 15 15 15  9 15  9 15  7 15 15
#> [26] 13 15  4 15  5 15 15 15 15 15  6  4 15 15 15 15 15  3 15 15 15 15  3 15 15
#> 
#> $SampleSizeControl
#>  [1] 10 15 15 15 15  4 15 15 15 15 15 15 15 15 15 15 15 15 11 15 11 15  3 15 15
#> [26]  7 15  6 15  5 15 15 15 15 15  4  6 15 15 15 15 15  7 15 15 15 15  7 15 15
#> 
#> $union_nn
#> [1] 10 20 30
#> 
#> $wiggled_nnE
#> [1] 10 20 30
#> 
#> $wiggled_nnF
#> [1] 30
#> 
#> $wiggle_dist
#> [1] 0
#> 
#> $params
#> $params[[1]]
#> ocRctPostprobDist
#> 
#> $params$nnE
#> c(10, 20, 30)
#> 
#> $params$pE
#> [1] 0.4
#> 
#> $params$pS
#> [1] 0.3
#> 
#> $params$deltaE
#> [1] 0.15
#> 
#> $params$deltaF
#> [1] 0.05
#> 
#> $params$relativeDelta
#> [1] FALSE
#> 
#> $params$tL
#> [1] 0.2
#> 
#> $params$tU
#> [1] 0.8
#> 
#> $params$parE
#> c(a = 1, b = 1)
#> 
#> $params$parS
#> c(a = 1, b = 1)
#> 
#> $params$randRatio
#> [1] 1
#> 
#> $params$sim
#> [1] 50
#> 
#> $params$wiggle
#> [1] FALSE
#> 
#> $params$nnF
#> [1] 30
#> 
#> 

# When `deltaF = 0`:
set.seed(2000)
ocRctPostprobDist(
  nnE = c(10, 20, 30),
  pE = 0.4,
  pS = 0.3,
  deltaE = 0.15,
  deltaF = 0,
  relativeDelta = FALSE,
  tL = 0.2,
  tU = 0.8,
  parE = c(a = 1, b = 1),
  parS = c(a = 1, b = 1),
  randRatio = 1,
  sim = 50,
  wiggle = FALSE,
  nnF = c(10, 20, 30)
)
#> Warning: Advise to use sim >= 50000 to achieve convergence
#> $oc
#>   ExpectedN PrStopEarly PrEarlyEff PrEarlyFut PrEfficacy PrFutility PrGrayZone
#> 1      11.4        0.98        0.2       0.78       0.22       0.78          0
#>   ExpectedNactive ExpectedNcontrol
#> 1            5.74             5.66
#> 
#> $ExpectedN
#> [1] 11.4
#> 
#> $ExpectedNactive
#> [1] 5.74
#> 
#> $ExpectedNcontrol
#> [1] 5.66
#> 
#> $Decision
#>  [1]  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
#> [13] FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE
#> [25] FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE
#> [37]  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE
#> [49] FALSE FALSE
#> 
#> $SampleSize
#>  [1] 20 10 10 10 10 10 10 10 10 10 20 10 10 30 10 10 10 10 20 10 10 10 10 10 10
#> [26] 10 10 10 10 10 10 20 10 10 10 10 10 10 10 10 10 10 10 10 10 20 10 10 10 10
#> 
#> $SampleSizeActive
#>  [1] 10  5  5  5  5  6  5  5  4  3  8  5  4 15  6  7  6  6  9  4  3  5  7  5  4
#> [26]  7  6  4  4  5  7 11  8  5  6  6  4  4  4  6  6  7  3  3  3 10  7  3  5  6
#> 
#> $SampleSizeControl
#>  [1] 10  5  5  5  5  4  5  5  6  7 12  5  6 15  4  3  4  4 11  6  7  5  3  5  6
#> [26]  3  4  6  6  5  3  9  2  5  4  4  6  6  6  4  4  3  7  7  7 10  3  7  5  4
#> 
#> $union_nn
#> [1] 10 20 30
#> 
#> $wiggled_nnE
#> [1] 10 20 30
#> 
#> $wiggled_nnF
#> [1] 10 20 30
#> 
#> $wiggle_dist
#> [1] 0
#> 
#> $params
#> $params[[1]]
#> ocRctPostprobDist
#> 
#> $params$nnE
#> c(10, 20, 30)
#> 
#> $params$pE
#> [1] 0.4
#> 
#> $params$pS
#> [1] 0.3
#> 
#> $params$deltaE
#> [1] 0.15
#> 
#> $params$deltaF
#> [1] 0
#> 
#> $params$relativeDelta
#> [1] FALSE
#> 
#> $params$tL
#> [1] 0.2
#> 
#> $params$tU
#> [1] 0.8
#> 
#> $params$parE
#> c(a = 1, b = 1)
#> 
#> $params$parS
#> c(a = 1, b = 1)
#> 
#> $params$randRatio
#> [1] 1
#> 
#> $params$sim
#> [1] 50
#> 
#> $params$wiggle
#> [1] FALSE
#> 
#> $params$nnF
#> c(10, 20, 30)
#> 
#>