Skip to content

Commit a4b5f59

Browse files
committed
MODIFIED FOR CRAN
1 parent 501a00f commit a4b5f59

57 files changed

Lines changed: 1744 additions & 1159 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

2 KB
Binary file not shown.

.Rhistory

Lines changed: 503 additions & 503 deletions
Large diffs are not rendered by default.

DESCRIPTION

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
Package: BayesianPlatformDesignTimeTrend
2-
Title: Simulate and analyse Bayesian Platform Trial with time trend
3-
Version: 1.0.0
2+
Title: Simulate and Analyse Bayesian Platform Trial with Time Trend
3+
Version: 1.1.1
44
Author: Ziyan Wang [aut, cre]
55
Maintainer: Ziyan Wang <zw7g20@soton.ac.uk>
66
Authors@R:
77
person(given = "Ziyan",
88
family = "Wang",
99
role = c("aut", "cre"),
1010
email = "zw7g20@soton.ac.uk")
11-
Description: Simulating the multi-arm multi-stage or platform trial with Bayesian approach using the 'rstan' package, which provides the R interface for to the Stan.
12-
The randomisation approach in this package are fix ratio and Bayesian adaptive randomisation.
13-
In addition, the time trend problem of platform trial can be studied in this package.
14-
There is a demo for multi-arm multi-stage trial with two different null scenario and a demo for Bayesian trial cutoff screening.
11+
Description: Simulating the sequential multi-arm multi-stage or platform trial with Bayesian approach using the 'rstan' package, which provides the R interface for the Stan.
12+
This package supports fixed ratio and Bayesian adaptive randomization approaches for randomization.
13+
Additionally, it allows for the study of time trend problems in platform trials.
14+
There are demos available for a multi-arm multi-stage trial with two different null scenarios, as well as for Bayesian trial cutoff screening.
1515
The Bayesian adaptive randomisation approaches are described in:
1616
Trippa et al. (2012) <doi:10.1200/JCO.2011.39.8420> and
17-
Wathen et al. (2017) <doi:10.1177/1740774517692302>
18-
The randomisation algorithm is described in
19-
Zhao W <doi:10.1016/j.cct.2015.06.008>
17+
Wathen et al. (2017) <doi:10.1177/1740774517692302>.
18+
The randomisation algorithm is described in:
19+
Zhao W <doi:10.1016/j.cct.2015.06.008>.
2020
The analysis methods of time trend effect in platform trial are described in:
2121
Saville et al. (2022) <doi:10.1177/17407745221112013> and
22-
Bofill Roig et al. (2022) <doi:10.1186/s12874-022-01683-w>
22+
Bofill Roig et al. (2022) <doi:10.1186/s12874-022-01683-w>.
2323
URL: https://github.com/ZXW834/PlatFormDesignTime
2424
Encoding: UTF-8
2525
Roxygen: list(markdown = TRUE)
@@ -42,7 +42,8 @@ Imports:
4242
iterators (>= 1.0.13),
4343
reshape (>= 0.8.8),
4444
BiocManager (>= 1.30.19),
45-
rjags
45+
lhs (>= 1.1.6),
46+
laGP (>= 1.5-9)
4647
LinkingTo:
4748
BH (>= 1.66.0),
4849
Rcpp (>= 0.12.0),

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
YEAR: 2023
2-
COPYRIGHT HOLDER: PlatFormDesign authors
2+
COPYRIGHT HOLDER: BayesianPlatformDesignTimeTrend authors

NAMESPACE

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ export(ARmethod)
44
export(AdaptiveRandomisation)
55
export(Boundaryconstruction)
66
export(FWER_disconjunctivepowerfunc)
7+
export(GP.optim)
78
export(Initializetrialparameter)
89
export(Meanfunc)
9-
export(Mixeffect_analysis)
10-
export(Mixeffect_modelling)
1110
export(Nfunc)
1211
export(OutputStats.initialising)
1312
export(Randomisation.inf)
@@ -18,6 +17,7 @@ export(Timetrend.fun)
1817
export(Trial.simulation)
1918
export(alphaspending)
2019
export(demo_Cutoffscreening)
20+
export(demo_Cutoffscreening.GP)
2121
export(demo_multscenario)
2222
export(ibetabinomial.post)
2323
export(intbias)
@@ -46,17 +46,19 @@ importFrom(foreach,"%dopar%")
4646
importFrom(foreach,foreach)
4747
importFrom(graphics,lines)
4848
importFrom(iterators,icount)
49+
importFrom(laGP,distance)
4950
importFrom(matrixStats,colVars)
5051
importFrom(rstan,rstan_options)
5152
importFrom(rstan,sampling)
5253
importFrom(stats,dbeta)
5354
importFrom(stats,integrate)
5455
importFrom(stats,lm)
5556
importFrom(stats,model.matrix)
57+
importFrom(stats,optimize)
5658
importFrom(stats,pbeta)
5759
importFrom(stats,pnorm)
5860
importFrom(stats,predict)
61+
importFrom(stats,qnorm)
5962
importFrom(stats,rbinom)
60-
importFrom(stats,update)
6163
importFrom(stats,var)
6264
useDynLib(BayesianPlatformDesignTimeTrend, .registration = TRUE)

NEWS.md

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,69 @@
1-
# BayesianPlatformDesignTimeTrend 1.0.0
2-
* Added a `NEWS.md` file to track changes to the package.
1+
# Jun 11, 2023, BayesianPlatformDesignTimeTrend version 1.1.1
2+
This release fix one bug reported by the cran team.
3+
4+
- I fixed the bug in function `GP.optim` where the nextcutoff vector for sample may have only one element. This will lead to the error in function `sample` when you only want to sample one value greater than 1.
5+
- The argument 'ntrials' in each example should be large (> 100) instead 2 to make the example more like an actual simulation example. I use ntrials = 2 in the example to speed up the check process.
6+
# May 2, 2023, BayesianPlatformDesignTimeTrend version 1.1.0
7+
This release implements additional method of cutoff screening using Bayesian optimization.
8+
9+
## New feature
10+
- Add a new Demo function called `demo_Cutoffscreening_GP`. The function indicates how to use Gaussian process-based Bayesian optimisation algorithm to calibrate the critical value for stopping boundary under the null scenario to control the Type I error rate or FWER before trial simulation.
11+
12+
- Add a function `GP_optim` which returns a cutoff value for the next evaluation during the cutoff screening process. The function is used in demo `demo_Cutoffscreening_GP`.
13+
14+
## Bugs
15+
- I found that the output data matrix can not be generated when there are four arm, the 'variable.inf' = "Mixeffect" and 'reg.inf' is "main"/"main + stage_continuous"/"main * stage_discrete".
16+
It only work for 'variable.inf'="Mixeffect" and 'reg.inf = main + stage_discrete'. The reason why this happen is that the length of stats6 and stats7 variable are not generated correctly at stage 1 since the fixed effect model is used for 'variable.inf'="Mixeffect" at stage 1 to speed up the simulation.
17+
18+
## Debug
19+
- I add one ifelse command to enforce the generation of stats6 and stats7 when 'variable.inf'="Mixeffect". It does not depend on the value of 'reg.inf' now.
20+
21+
# May 1, 2023, BayesianPlatformDesignTimeTrend version 1.0.1
22+
## Major changes
23+
- I fixed a bug where the fix ratio allocation method code is not suitable for the multi-arm trial
24+
25+
- Old code: rpk[-1] = rep((armleft - 1) / (armleft - 1 + Fixratiocontrol), armleft - 1)
26+
- New code: rpk[-1] = rep(1 / (armleft - 1 + Fixratiocontrol), armleft - 1)
27+
28+
# Apr 25, 2023, BayesianPlatformDesignTimeTrend version 1.0.1
29+
## Major changes
30+
- I added a check command for max.ar which is the upper boundary for randomisation ratio for each arm. The command is added in the MainFunction.R. Details are shown below.
31+
- #-max.ar check
32+
if (1 - max.ar > 1/K){
33+
stop("Error: The lower allocation ratio should be at least 1/K. Please check the number of arm at the beginning and the max.ar")
34+
}
35+
36+
- Another change is the randomisation ratio adjustment in the Simulation_AdaptiveRandomisationmethodRatioCalc.R.
37+
38+
- I modified the randomisation ratio adjustment command for Thall's approach.
39+
40+
- ##----Original code------ (This code only protects the control arm's allocation ratio)
41+
- rpk = matrix(rep(0, armleft), ncol = armleft)
42+
- randomprob = matrix(rep(0, K), ncol = K)
43+
- colnames(rpk) = c(1, treatmentindex + 1)
44+
- colnames(randomprob) = seq(1, K)
45+
- rpk[1] = alloc.prob.best[1]
46+
- rpk[-1] = alloc.prob.best[-1][treatmentindex]
47+
- rpk = rpk / sum(rpk)
48+
- lower = ifelse(rpk[1] < (1 - max.ar), 1 - max.ar, rpk[1])
49+
- rpk[1] = lower
50+
- upper = ifelse(rpk[1] > max.ar, max.ar, rpk[1])
51+
- rpk[1] = upper
52+
- rpk[-1] = (1 - rpk[1]) * rpk[-1] / sum(rpk[-1])
53+
- randomprob[as.numeric(colnames(rpk))] = randomprob[as.numeric(colnames(rpk))] + rpk
54+
55+
- ##----New code------ (This code protects all arms' allocation ratio. Also, this code work together with max.ar check code)
56+
- rpk = matrix(rep(0,armleft),ncol = armleft)
57+
- randomprob = matrix(rep(0,K),ncol = K)
58+
- colnames(rpk) = c(1,treatmentindex+1)
59+
- colnames(randomprob) = seq(1,K)
60+
- rpk[1] = alloc.prob.best[1]
61+
- rpk[-1] = alloc.prob.best[-1][treatmentindex]
62+
- rpk = rpk/sum(rpk)
63+
- lower = ifelse(rpk<(1-max.ar),1-max.ar,rpk)
64+
- rpk = lower
65+
- upper = ifelse(rpk>max.ar,max.ar,rpk)
66+
- rpk = upper
67+
- rpk[!(rpk==(1-max.ar))]=(1-sum(rpk[rpk==1-max.ar]))*(rpk[!(rpk==1-max.ar)]/sum(rpk[!(rpk==1-max.ar)]))
68+
- randomprob[as.numeric(colnames(rpk))] = randomprob[as.numeric(colnames(rpk))]+rpk
69+

R/Demo_CutoffScreening.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ demo_Cutoffscreening = function(ntrials = 1000,
3131
response.probs = c(0.4, 0.4),
3232
ns = c(30, 60, 90, 120, 150),
3333
max.ar = 0.75,
34-
rand.type = "Urn",
34+
rand.algo = "Urn",
3535
max.deviation = 3,
3636
model.inf = list(
3737
model = "tlr",
@@ -67,6 +67,7 @@ demo_Cutoffscreening = function(ntrials = 1000,
6767
),
6868
cl = 2) {
6969
old <- options()# code line i
70+
on.exit(options(old))
7071
#Set start grid of screening
7172
startgrid <-
7273
data.frame(tpIE = rep(NA, length(grid.inf$start)), cutoff = grid.inf$start)
@@ -94,7 +95,7 @@ demo_Cutoffscreening = function(ntrials = 1000,
9495
response.probs = input.info$response.probs,
9596
ns = input.info$ns,
9697
max.ar = input.info$max.ar,
97-
rand.type = input.info$rand.type,
98+
rand.algo = input.info$rand.algo,
9899
max.deviation = input.info$max.deviation,
99100
model.inf = input.info$model.inf,
100101
Stopbound.inf = Stopbound.inf,
@@ -138,7 +139,7 @@ demo_Cutoffscreening = function(ntrials = 1000,
138139
response.probs = input.info$response.probs,
139140
ns = input.info$ns,
140141
max.ar = input.info$max.ar,
141-
rand.type = input.info$rand.type,
142+
rand.algo = input.info$rand.algo,
142143
max.deviation = input.info$max.deviation,
143144
model.inf = input.info$model.inf,
144145
Stopbound.inf = Stopbound.inf,
@@ -178,7 +179,6 @@ demo_Cutoffscreening = function(ntrials = 1000,
178179
predict(quadratic.model,
179180
list(cutoff = cutoffgrid, cutoff2 = cutoffgrid ^ 2))
180181
doParallel::stopImplicitCluster()
181-
on.exit(options(old))
182182
return(
183183
list(
184184
detailsforgrid = dataloginformd,

0 commit comments

Comments
 (0)