R/binomialfreq.R
binomialfreq.Rd
Simulation for binomial counts for block design for response-adaptive randomization with time as a confounding
binomialfreq( p_control, p_treatment, N_total, block_number = 4, drift = 0, simulation = 10000, conf_int = 0.95, alternative = "greater", correct = FALSE, early_stop = FALSE, size_equal_randomization = 20, min_patient_earlystop = 20, max_prob = 0.8 )
p_control | scalar. Proportion of events under the control arm. |
---|---|
p_treatment | scalar. Proportion of events under the treatment arm. |
N_total | scalar. Total sample size. |
block_number | scalar. Number of blocks or time levels. The default is set to 4.
If |
drift | scalar. The increase or decrease in proportion of event over time. In this case, the proportion of failure changes in each block by the number of patient accured over the total sample size. The full drift effect is seen in the final block. |
simulation | scalar. Number of simulation to be ran. The default is set to 10000. |
conf_int | scalar. Confidence level of the interval. |
alternative | character. A string specifying the alternative hypothesis, must be one of "less" or "greater" (default). |
correct | logical. A logical indicating whether to apply continuity correction when computing the test statistic: one half is subtracted from all |O - E| differences; however, the correction will not be bigger than the differences themselves. |
early_stop | logical. A logical indicating whether the trials are stopped early for success or futility. |
size_equal_randomization | scalar. The number of run in patients because adaptive randomization is applied. |
min_patient_earlystop | scalar. Minimum number of patients before early stopping rule is applied. |
max_prob | scalar. The maximum probability for assigning to treatment/control group is 0.8. |
a list with details on the simulation.
power
scalar. The power of the trial, ie. the proportion of success over the number of simulation ran.
N_enrolled
vector. The number of patients enrolled in the trial (sum of control and experimental group for each simulation. )
N_control
vector. The number of patients enrolled in the control group for each simulation.
N_control
vector. The number of patients enrolled in the experimental group for each simulation.
randomization_ratio
matrix. The randomization ratio allocated for each block.
binomialfreq(p_control = 0.7, p_treatment = 0.65, N_total = 200, block_number = 2, simulation = 3)#> $power #> [1] 0 #> #> $prop_diff_estimate #> [1] 0.063212643 -0.008362227 0.024190242 #> #> $N_enrolled #> [1] 200 200 200 #> #> $N_control #> [1] 101 105 112 #> #> $N_treatment #> [1] 99 95 88 #> #> $early_stop #> [1] 0 0 0 #> #> $p_value #> [1] 0.3524833 0.9003808 0.7161280 #> #> $prob_treatment #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60] [,61] [,62] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72] [,73] [,74] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,75] [,76] [,77] [,78] [,79] [,80] [,81] [,82] [,83] [,84] [,85] [,86] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,87] [,88] [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96] [,97] [,98] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,99] [,100] [,101] [,102] [,103] [,104] [,105] [,106] #> [1,] 0.5 0.5 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.5 0.5 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.5 0.5 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,107] [,108] [,109] [,110] [,111] [,112] [,113] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,114] [,115] [,116] [,117] [,118] [,119] [,120] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,121] [,122] [,123] [,124] [,125] [,126] [,127] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,128] [,129] [,130] [,131] [,132] [,133] [,134] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,135] [,136] [,137] [,138] [,139] [,140] [,141] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,142] [,143] [,144] [,145] [,146] [,147] [,148] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,149] [,150] [,151] [,152] [,153] [,154] [,155] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,156] [,157] [,158] [,159] [,160] [,161] [,162] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,163] [,164] [,165] [,166] [,167] [,168] [,169] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,170] [,171] [,172] [,173] [,174] [,175] [,176] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,177] [,178] [,179] [,180] [,181] [,182] [,183] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,184] [,185] [,186] [,187] [,188] [,189] [,190] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,191] [,192] [,193] [,194] [,195] [,196] [,197] #> [1,] 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 0.4818182 #> [,198] [,199] [,200] #> [1,] 0.5538462 0.5538462 0.5538462 #> [2,] 0.4771084 0.4771084 0.4771084 #> [3,] 0.4818182 0.4818182 0.4818182 #>binomialfreq(p_control = 0.5, p_treatment = 0.40, N_total = 200, block_number = 2, simulation = 3, drift = -0.15)#> $power #> [1] 0 #> #> $prop_diff_estimate #> [1] -0.0978723404 0.0004027386 -0.1326387497 #> #> $N_enrolled #> [1] 200 200 200 #> #> $N_control #> [1] 109 102 103 #> #> $N_treatment #> [1] 91 98 97 #> #> $early_stop #> [1] 0 0 0 #> #> $p_value #> [1] 0.16733530 0.99513843 0.05515059 #> #> $prob_treatment #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60] [,61] [,62] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72] [,73] [,74] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,75] [,76] [,77] [,78] [,79] [,80] [,81] [,82] [,83] [,84] [,85] [,86] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,87] [,88] [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96] [,97] [,98] #> [1,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [2,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [3,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 #> [,99] [,100] [,101] [,102] [,103] [,104] [,105] [,106] #> [1,] 0.5 0.5 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.5 0.5 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5 0.5 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,107] [,108] [,109] [,110] [,111] [,112] [,113] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,114] [,115] [,116] [,117] [,118] [,119] [,120] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,121] [,122] [,123] [,124] [,125] [,126] [,127] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,128] [,129] [,130] [,131] [,132] [,133] [,134] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,135] [,136] [,137] [,138] [,139] [,140] [,141] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,142] [,143] [,144] [,145] [,146] [,147] [,148] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,149] [,150] [,151] [,152] [,153] [,154] [,155] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,156] [,157] [,158] [,159] [,160] [,161] [,162] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,163] [,164] [,165] [,166] [,167] [,168] [,169] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,170] [,171] [,172] [,173] [,174] [,175] [,176] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,177] [,178] [,179] [,180] [,181] [,182] [,183] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,184] [,185] [,186] [,187] [,188] [,189] [,190] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,191] [,192] [,193] [,194] [,195] [,196] [,197] #> [1,] 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 0.5288462 #> [,198] [,199] [,200] #> [1,] 0.4846527 0.4846527 0.4846527 #> [2,] 0.4827586 0.4827586 0.4827586 #> [3,] 0.5288462 0.5288462 0.5288462 #>