|
4 | 4 | #' @param response.probs A vector of true response probability for each arm. Default response.probs = c(0.4, 0.4). |
5 | 5 | #' @param ns A vector of accumulated number of patient at each stage. Default is ns = c(30, 60, 90, 120, 150). |
6 | 6 | #' @param max.ar The upper boundary for randomisation ratio for each arm. Default is 0.75 for a two arm trial. |
7 | | -#' @param rand.type The method of applying patient allocation with a given randomisation probability vector. Default is "Urn". |
| 7 | +#' @param rand.algo The method of applying patient allocation with a given randomisation probability vector. Default is "Urn". |
8 | 8 | #' @param max.deviation The tuning parameter for Urn randomisation method. Default is 3. |
9 | 9 | #' @param Stopbound.inf The list of stop boundary information for more see \code{\link{Stopboundinf}} |
10 | 10 | #' @param Random.inf The list of Adaptive randomisation information for more see \code{\link{Randomisation.inf}} |
|
19 | 19 | #' simulatetrial(response.probs = c(0.4, 0.4), |
20 | 20 | #' ns = c(30, 60, 90, 120, 150), |
21 | 21 | #' max.ar = 0.75, |
22 | | -#' rand.type = "Urn", |
| 22 | +#' rand.algo = "Urn", |
23 | 23 | #' max.deviation = 3, |
24 | 24 | #' model.inf = list( |
25 | 25 | #' model = "tlr", |
@@ -60,7 +60,7 @@ simulatetrial <- function(ii, |
60 | 60 | response.probs = c(0.4, 0.4), |
61 | 61 | ns = c(30, 60, 90, 120, 150), |
62 | 62 | max.ar = 0.75, |
63 | | - rand.type = "Urn", |
| 63 | + rand.algo = "Urn", |
64 | 64 | max.deviation = 3, |
65 | 65 | model.inf = list( |
66 | 66 | model = "tlr", |
@@ -139,10 +139,10 @@ simulatetrial <- function(ii, |
139 | 139 |
|
140 | 140 | # Patient randomisation based on given randomization ratio |
141 | 141 | # Parameter checking |
142 | | - if (rand.type %in% c("Coin", "Urn")) { |
| 142 | + if (rand.algo %in% c("Coin", "Urn")) { |
143 | 143 | random.output = AdaptiveRandomisation( |
144 | 144 | Fixratio, |
145 | | - rand.type, |
| 145 | + rand.algo, |
146 | 146 | K, |
147 | 147 | n.new, |
148 | 148 | randomprob, |
@@ -491,66 +491,6 @@ simulatetrial <- function(ii, |
491 | 491 | treatmentindex = treatmentindex[is.na(match(treatmentindex, treatmentdrop))] |
492 | 492 | } |
493 | 493 | } |
494 | | - else if (model.inf$tlr.inf$variable.inf == "Mixeffect.jag") { |
495 | | - jagmodel<-" model { |
496 | | - for(i in 1:armleft){ |
497 | | - for(j in 1:stage){ |
498 | | - Y[i,j] ~ dbin(p[i,j],N[i,j]) |
499 | | - logit(p[i,j]) = beta0 + alpha[stage-(j-1)] + beta1[i] |
500 | | - } |
501 | | - } |
502 | | - alpha[1] = 0 |
503 | | - alpha[2] ~ dnorm(0, tau2) |
504 | | - for(k in 3:stage ) { |
505 | | - alpha[k] ~ dnorm(2*alpha[k-1] - alpha[k-2],tau2) |
506 | | - } |
507 | | - beta1[1] <- 0 |
508 | | - for(i in 2:armleft){ |
509 | | - beta1[i] ~ dnorm(0,0.31) |
510 | | - } |
511 | | - tau2 ~ dgamma(0.1, 0.01) |
512 | | - beta0 ~ dnorm(0, 0.31) |
513 | | - }" |
514 | | - postsamp.list = Mixeffect_modelling(ytemp=ytemp, treatmentindex=treatmentindex, group=group, ntemp=ntemp, armleft=armleft, jagmodel=jagmodel) |
515 | | - analysis = Mixeffect_analysis(postsamp.list=postsamp.list, group=group, treatmentindex=treatmentindex, ns = ns, K = K) |
516 | | - stats1 = analysis$stats1 |
517 | | - statsbeta0 = analysis$statsbeta0 |
518 | | - stats4 = analysis$stats4 |
519 | | - stats5 = analysis$stats5 |
520 | | - stats6 = analysis$stats6 |
521 | | - stats7 = analysis$stats7 |
522 | | - sampoutcome = analysis$sampoutcome |
523 | | - sampefftotal = analysis$sampefftotal |
524 | | - post.prob.btcontrol = analysis$post.prob.btcontrol |
525 | | - #-Calculating posterior probability of each arm (including control) to be the best arm- |
526 | | - # post.prob.best: The posterior probability of each arm (including control) to be the best arm |
527 | | - # This is required for Thall's randomisation approach |
528 | | - for (q in 1:armleft) { |
529 | | - post.prob.best.mat[group, zlevel[q]] = (sum(max.col(sampefftotal) == q)) / |
530 | | - 2500 |
531 | | - } |
532 | | - post.prob.best = post.prob.best.mat[group,] |
533 | | - #Normalizing in case any value equals zero |
534 | | - post.prob.best = post.prob.best + 1e-7 |
535 | | - post.prob.best = post.prob.best / sum(post.prob.best) |
536 | | - #----Justify if type I error was made for each arm---- |
537 | | - # post.prob.btcontrol>cutoffeff[group]: Efficacy boundary is hit at this stage |
538 | | - # post.prob.btcontrol<cutoffful[group]: Fultility boundary is hit at this stage |
539 | | - Justify = post.prob.btcontrol > cutoffeff[group] | |
540 | | - post.prob.btcontrol < cutoffful[group] |
541 | | - #Identify which active arm should be dropped at current stage |
542 | | - treatmentdrop = treatmentindex[post.prob.btcontrol > cutoffeff[group] | |
543 | | - post.prob.btcontrol < cutoffful[group]] |
544 | | - stats3 = rep(NA, K - 1) |
545 | | - names(stats3) = seq(1, K - 1) |
546 | | - stats3[treatmentindex] = Justify |
547 | | - if (sum(Justify) > 0) { |
548 | | - armleft = armleft - sum(Justify) |
549 | | - #Debugged for K arm by Ziyan Wang on 12:00 26/07/2022 for three arm. Used to be treatmentindex = treatmentindex[-treatmentdrop] |
550 | | - #Debugged for K arm by Ziyan Wang on 18:58 26/07/2022 for more than 3 arm. Used to be treatmentindex = treatmentindex[!(treatmentindex==treatmentdrop)] |
551 | | - treatmentindex = treatmentindex[is.na(match(treatmentindex, treatmentdrop))] |
552 | | - } |
553 | | - } |
554 | 494 |
|
555 | 495 | #-Adjust the posterior randomisation ratio- |
556 | 496 | randomprob = ARmethod( |
|
0 commit comments