forwsim {unknown} | R Documentation

## Forward Simulation to evaluate sequential boundaries in 1 group binomial design.

### Description

Estimates the expected utility of using boundaries on the posterior (mean,standard deviation) space as a stopping criteria in a sequential experiment with 1 group binomial data. The utility can incorporate the fixed cost of performing a study, sampling cost and a pay-off if a future confirmatory study gives significant results. See Details section for more information about the utility.

Also, empirical type I & II error rates, sample size and other quantities are saved. Each boundary being identified by `(b0,b1,b2)`, the utility is estimated for a grid containing combinations of `(b0,b1,b2)` values.

### Usage

    forwsim(dta.N = 2, th.u = 1, th.v = 1, th.au = 3, th.bu = 1, th.av = 3, th.bv = 1, dsg.uth = 0, dsg.hyper = FALSE, dsg.pool = FALSE,
    dsg.logsd = TRUE, dsg.kini = 1, dsg.c0 = 0, dsg.c1 = 1, dsg.c2 = 10000, dsg.p0 = 0.5, dsg.a = 0.05, dsg.b = 0.1, dsg.s0 = 0.05, dsg.s1 = 0.1,
    mc.nsim = 100, mc.nt = 100, mc.pk = c(0.7, 0.2, 0.05, 0.05), b0grid = c(0.5, 0.9, 20), b1grid = c(0.7, 1.7, 20), b2grid = c(0, 0.8, 20),
    uhat.bsave = rep(1, 3), dir)

### Arguments

`dta.N` | Batch size. Posterior moments are obtained after every `dta.N` patients have been recruited into each treatment arm.
`th.u` | Prior for success probability `theta ~ Beta(th.u,th.v)`.
`th.v` | Prior for success probability `theta ~ Beta(th.u,th.v)`.
`th.au` | Hyperprior `th.u ~ Gamma(th.au,th.bu)` (mean is `th.au/th.bu`). Ignored if `dsg.hyper` and `dsg.pool` set to `FALSE`.
`th.bu` | Hyperprior `th.u ~ Gamma(th.au,th.bu)` (mean is `th.au/th.bu`). Ignored if `dsg.hyper` and `dsg.pool` set to `FALSE`.
`th.av` | Hyperprior `th.v ~ Gamma(th.av,th.bv)` (mean is `th.av/th.bv`). Ignored if `dsg.hyper` and `dsg.pool` set to `FALSE`.
`th.bv` | Hyperprior `th.v ~ Gamma(th.av,th.bv)` (mean is `th.av/th.bv`). Ignored if `dsg.hyper` and `dsg.pool` set to `FALSE`.
`dsg.uth` | Indicates what utility function to use. 0: use posterior mean in utility evaluation; 1: use true theta; 2: drop terms related to a future study from utility. See Details section.
`dsg.hyper` | If set to `TRUE` hyper-parameters `th.u,th.v` are fixed in the simulation. If set to `FALSE` `u,v` are simulated from hyper-priors.
`dsg.pool` | If set to `TRUE` at the time of analysis pooling is performed (via empirical Bayes). If set to `FALSE` hyper-prior is ignored at the time of analysis.
`dsg.logsd` | If set to `TRUE` the decision boundaries are linear in log(SD). If set to `FALSE` boundaries are linear in SD
`dsg.kini` | Initial number of treatments.
`dsg.c0` | Coefficient for utility function representing the fixed cost of performing a phase III study. See Details section.
`dsg.c1` | Coefficient for utility function representing the sampling cost of 1 patient. See Details section.
`dsg.c2` | Coefficient for utility function representing the pay-off for significant phase III result. See Details section.
`dsg.p0` | Value of theta under H0 for phase III (e.g. success probability for standard of care)
`dsg.a` | Type I error to be used when designing future studies (used for sample size calculation).
`dsg.b` | Type II error to be used when designing future studies (used for sample size calculation).
`dsg.s0` | Value of the posterior standard deviation (in log scale) at which the upper and lower boundaries cross, i.e. any treatment with posterior SD < `dsg.c0` is terminated.
`dsg.s1` | `b1` and `b2` are the values of the upper and lower boundaries when posterior SD is equal to `dsg-s1`.
`mc.nsim` | Number of forward simulations.
`mc.nt` | Time horizon in forward simulation expressed in number of batches.
`mc.pk` | Vector indicating probabilities of 0,1,2 and 3 new treatments arising at any point in time.
`b0grid` | Grid on `b0`, specified as initial term, final term and number of points in the grid.
`b1grid` | Grid on `b0`, specified as initial term, final term and number of points in the grid.
`b2grid` | Grid on `b0`, specified as initial term, final term and number of points in the grid.
`uhat.bsave` | Index for `b0grid,b1grid,b2grid`. For the corresponding `(b0,b1,b2)` value extra information will be saved (trajectories, posterior moments etc.)
`dir` | Directory where output files will be written to.

### Details

Three different forms for the utility function are available to the user by specifying the parameter `dsg.uth`.

`dsg.uth==0: utility = - c1*(nb. pat. in screening study) + (c2*P(significant result in future study|data)*(E(theta|data)-dsg.p0) - c0)*I(future study is performed)`

`dsg.uth==1: utility = - c1*(nb. pat. in screening study) + (c2*P(significant result in future study|data)*(theta-dsg.p0) - c0)*I(future study is performed)`

`dsg.uth==2: utility = - c1*(nb. pat. in screening study)`

The simulation starts with `dsg.kini` treatments, with new treatments arising over time with probabilities specified by `dsg.pk`. For each treatment a success probability is generated from a Beta prior with parameters `(th.u,th.v)`, which in turn are drawn from Gamma hyper-priors if `dsg.hyper` is set to `TRUE` and they're fixed if `dsg.hyper` is set to `FALSE`. Then data is observed for each treatment in batches of `dta.N` until the time horizon of `mc.nt` batches is reached.

Each time `dta.N` new observations are available, posterior moments for each treatment are compared with the boundaries. A treatment is stopped whenever either the upper or lower boundary is crossed, and at that time a terminal decision is taken: to recommend the treament for further study or to discard it. If `dsg.uth` is set to 1 or 2 a treatment recommended whenever the expected benefits of conducting a further study are higher than the expected costs. If `dsg.uth` is set to 3 a treatment is recommended if its posterior moments trajectory crossed the upper boundary and discarded if it crossed the lower boundary.

### Value

No results are returned directly; instead they are saved in file into the directory specified by `dir`. Use function `read.forwsim` to read in the results.

`init.dsg` | Design specification. The values of all the arguments passed to the function are saved to this file.
`b0.sim` | Sequence of values of `b0` that were used to construct the grid.
`b1.sim` | Sequence of values of `b1` that were used to construct the grid.
`b2.sim` | Sequence of values of `b2` that were used to construct the grid.
`dt.sim` | Mean number of patients tested with each treatment.
`errorI.sim` | Estimated type I error rates.
`errorII.sim` | Estimated type II error rates.
`mc.dsg` | Number of treatments in each simulation.
`mse.sim` | Estimated Mean Squared Error. When a treatment is stopped the squared difference between the posterior mean and the true parameter value is computed, and the mean over all treatments and simulations is saved in this file.
`n3.sim` | Mean sample size of future confirmatory study amongst treatments that were recommended for further study.
`nreco.sim` | Mean number of recommended treatments.
`ntoreco.sim` | Mean number of patients / number of recommended treatments. Since number of recommended treatments can be zero, this quantity can be `Inf`. To avoid this problem increase the time horizon `mc.nt`
`pB.sim` | Mean posterior probability that future trial gives significant result.
`term.sim` | Terminal decisions and posterior moments for sample trajectories indicated in `uhat.save`.
`th.dsg` | Values of the success probability `theta` used in each of the simulations.
`traj.dsg` | Some sample posterior moment trajectories saved for the boundary indicated in `uhat.save`.
`U.sim` | Estimated expected utility.

### Author(s)

David Rossell, Peter Mueller.

### References

Rossell D, Mueller P, Rosner G. Screening Designs for Drug Development.

### See Also

read.forwsim

### Examples

    dir <- 'c:/projects/forwsim'                                            #set directory where results will be saved

    # run forward simulation
    forwsim(dta.N=2,th.u=1,th.v=1,th.au=3,th.bu=1,th.av=3,th.bv=1,dsg.uth=0,dsg.hyper=TRUE,dsg.pool=TRUE,dsg.logsd=FALSE,dsg.kini=1,
    dsg.c0=0,dsg.c1=1,dsg.c2=10000,dsg.p0=0.5,dsg.a=.05,dsg.b=.1,dsg.s0=.05,dsg.s1=.1,mc.nsim=1,mc.nt=100,mc.pk=c(.7,.2,.05,.05),
    b0grid=c(.5,.9,20),b1grid=c(.7,1.7,20),b2grid=c(0,.8,20),uhat.bsave=c(8,5,14),dir)

    sim1 <- read.forwsim(dir)                                               #read forward simulation results

    opt1 <- optbound(sim1,errImax=1,errIImax=1,util='u',smooth=FALSE)       #unconstrained optimization

[Package Index]