Skip to contents

Computes the optimal Go threshold \(\gamma_{\mathrm{go}}\) and NoGo threshold \(\gamma_{\mathrm{nogo}}\) for two binary endpoints by searching over a two-dimensional grid of candidate value pairs. The two thresholds are calibrated independently under separate scenarios:

  • \(\gamma_{\mathrm{go}}\) is the smallest value in gamma_go_grid such that the worst-case marginal Go probability over all \(\gamma_{\mathrm{nogo}}\) in gamma_nogo_grid is strictly less than target_go under the Go-calibration scenario (pi_t1_go, pi_t2_go, rho_t_go, pi_c1_go, pi_c2_go, rho_c_go); typically the Null scenario.

  • \(\gamma_{\mathrm{nogo}}\) is the smallest value in gamma_nogo_grid such that the worst-case marginal NoGo probability over all \(\gamma_{\mathrm{go}}\) in gamma_go_grid is strictly less than target_nogo under the NoGo-calibration scenario (pi_t1_nogo, pi_t2_nogo, rho_t_nogo, pi_c1_nogo, pi_c2_nogo, rho_c_nogo); typically the Alternative scenario.

Usage

getgamma2bin(
  prob = "posterior",
  design = "controlled",
  GoRegions,
  NoGoRegions,
  pi_t1_go,
  pi_t2_go,
  rho_t_go,
  pi_c1_go = NULL,
  pi_c2_go = NULL,
  rho_c_go = NULL,
  pi_t1_nogo,
  pi_t2_nogo,
  rho_t_nogo,
  pi_c1_nogo = NULL,
  pi_c2_nogo = NULL,
  rho_c_nogo = NULL,
  target_go,
  target_nogo,
  n_t,
  n_c,
  a_t_00,
  a_t_01,
  a_t_10,
  a_t_11,
  a_c_00,
  a_c_01,
  a_c_10,
  a_c_11,
  theta_TV1 = NULL,
  theta_MAV1 = NULL,
  theta_TV2 = NULL,
  theta_MAV2 = NULL,
  theta_NULL1 = NULL,
  theta_NULL2 = NULL,
  m_t = NULL,
  m_c = NULL,
  z00 = NULL,
  z01 = NULL,
  z10 = NULL,
  z11 = NULL,
  xe_t_00 = NULL,
  xe_t_01 = NULL,
  xe_t_10 = NULL,
  xe_t_11 = NULL,
  xe_c_00 = NULL,
  xe_c_01 = NULL,
  xe_c_10 = NULL,
  xe_c_11 = NULL,
  alpha0e_t = NULL,
  alpha0e_c = NULL,
  nMC = 1000L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)

Arguments

prob

A character string specifying the probability type. Must be 'posterior' or 'predictive'.

design

A character string specifying the trial design. Must be 'controlled', 'uncontrolled', or 'external'.

GoRegions

An integer vector of region indices (subset of 1:9 for prob = 'posterior' or 1:4 for prob = 'predictive') that constitute the Go region.

NoGoRegions

An integer vector of region indices that constitute the NoGo region. Must be disjoint from GoRegions.

pi_t1_go

A numeric scalar in (0, 1) giving the true treatment response probability for Endpoint 1 under the Go-calibration scenario (typically Null).

pi_t2_go

A numeric scalar in (0, 1) giving the true treatment response probability for Endpoint 2 under the Go-calibration scenario.

rho_t_go

A numeric scalar giving the within-group correlation in the treatment group under the Go-calibration scenario.

pi_c1_go

A numeric scalar in (0, 1) giving the true control response probability for Endpoint 1 under the Go-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

pi_c2_go

A numeric scalar in (0, 1) giving the true control response probability for Endpoint 2 under the Go-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

rho_c_go

A numeric scalar giving the within-group correlation in the control group under the Go-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

pi_t1_nogo

A numeric scalar in (0, 1) giving the true treatment response probability for Endpoint 1 under the NoGo-calibration scenario (typically Alternative).

pi_t2_nogo

A numeric scalar in (0, 1) giving the true treatment response probability for Endpoint 2 under the NoGo-calibration scenario.

rho_t_nogo

A numeric scalar giving the within-group correlation in the treatment group under the NoGo-calibration scenario.

pi_c1_nogo

A numeric scalar in (0, 1) giving the true control response probability for Endpoint 1 under the NoGo-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

pi_c2_nogo

A numeric scalar in (0, 1) giving the true control response probability for Endpoint 2 under the NoGo-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

rho_c_nogo

A numeric scalar giving the within-group correlation in the control group under the NoGo-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

target_go

A numeric scalar in (0, 1) giving the upper bound on the worst-case marginal Go probability under the Go-calibration scenario. The optimal \(\gamma_{\mathrm{go}}\) is the smallest grid value satisfying the constraint.

target_nogo

A numeric scalar in (0, 1) giving the upper bound on the worst-case marginal NoGo probability under the NoGo-calibration scenario. The optimal \(\gamma_{\mathrm{nogo}}\) is the smallest grid value satisfying the constraint.

n_t

A positive integer giving the number of patients in the treatment group in the PoC trial.

n_c

A positive integer giving the number of patients in the control group in the PoC trial.

a_t_00

A positive numeric scalar giving the Dirichlet prior parameter for the (0,0) response pattern in the treatment group.

a_t_01

A positive numeric scalar; see a_t_00.

a_t_10

A positive numeric scalar; see a_t_00.

a_t_11

A positive numeric scalar; see a_t_00.

a_c_00

A positive numeric scalar giving the Dirichlet prior parameter for the (0,0) response pattern in the control group.

a_c_01

A positive numeric scalar; see a_c_00.

a_c_10

A positive numeric scalar; see a_c_00.

a_c_11

A positive numeric scalar; see a_c_00.

theta_TV1

A numeric scalar giving the TV threshold for Endpoint 1. Required when prob = 'posterior'; otherwise set to NULL.

theta_MAV1

A numeric scalar giving the MAV threshold for Endpoint 1. Required when prob = 'posterior'; otherwise set to NULL.

theta_TV2

A numeric scalar giving the TV threshold for Endpoint 2. Required when prob = 'posterior'; otherwise set to NULL.

theta_MAV2

A numeric scalar giving the MAV threshold for Endpoint 2. Required when prob = 'posterior'; otherwise set to NULL.

theta_NULL1

A numeric scalar giving the null hypothesis threshold for Endpoint 1. Required when prob = 'predictive'; otherwise set to NULL.

theta_NULL2

A numeric scalar giving the null hypothesis threshold for Endpoint 2. Required when prob = 'predictive'; otherwise set to NULL.

m_t

A positive integer giving the future sample size for the treatment group. Required when prob = 'predictive'; set to NULL otherwise.

m_c

A positive integer giving the future sample size for the control group. Required when prob = 'predictive'; set to NULL otherwise.

z00

A non-negative integer giving the hypothetical control count for pattern (0,0). Required when design = 'uncontrolled'; otherwise set to NULL.

z01

A non-negative integer; see z00.

z10

A non-negative integer; see z00.

z11

A non-negative integer; see z00.

xe_t_00

A non-negative integer giving the external treatment group count for pattern (0,0). Required when design = 'external' and external treatment data are used; otherwise NULL.

xe_t_01

A non-negative integer; see xe_t_00.

xe_t_10

A non-negative integer; see xe_t_00.

xe_t_11

A non-negative integer; see xe_t_00.

xe_c_00

A non-negative integer giving the external control group count for pattern (0,0). Required when design = 'external' and external control data are used; otherwise NULL.

xe_c_01

A non-negative integer; see xe_c_00.

xe_c_10

A non-negative integer; see xe_c_00.

xe_c_11

A non-negative integer; see xe_c_00.

alpha0e_t

A numeric scalar in (0, 1] giving the power prior weight for external treatment group data. Required when external treatment data are used; otherwise NULL.

alpha0e_c

A numeric scalar in (0, 1] giving the power prior weight for external control group data. Required when external control data are used; otherwise NULL.

nMC

A positive integer giving the number of Dirichlet draws used to evaluate region probabilities for each count combination in Stage 1. Default is 1000L.

gamma_go_grid

A numeric vector of candidate Go threshold values in (0, 1) to search over. Defaults to seq(0.01, 0.99, by = 0.01).

gamma_nogo_grid

A numeric vector of candidate NoGo threshold values in (0, 1) to search over. Defaults to seq(0.01, 0.99, by = 0.01).

Value

A list of class getgamma2bin with the following elements:

gamma_go

Optimal Go threshold: the smallest value in gamma_go_grid for which the marginal \(\Pr(\mathrm{Go}) < \code{target\_go}\) under the Go-calibration scenario. NA if no such value exists.

gamma_nogo

Optimal NoGo threshold: the smallest value in gamma_nogo_grid for which the marginal \(\Pr(\mathrm{NoGo}) < \code{target\_nogo}\) under the NoGo-calibration scenario. NA if no such value exists.

PrGo_opt

Marginal \(\Pr(\mathrm{Go})\) at gamma_go under the Go-calibration scenario. NA if gamma_go is NA.

PrNoGo_opt

Marginal \(\Pr(\mathrm{NoGo})\) at gamma_nogo under the NoGo-calibration scenario. NA if gamma_nogo is NA.

target_go

The value of target_go supplied by the user.

target_nogo

The value of target_nogo supplied by the user.

grid_results

A data frame with columns gamma_grid, PrGo_grid (marginal Go probability under the Go-calibration scenario), and PrNoGo_grid (marginal NoGo probability under the NoGo-calibration scenario).

Details

The function uses the same two-stage precompute-then-sweep strategy as pbayesdecisionprob2bin.

Stage 1 (precomputation): pbayespostpred2bin is called for every possible multinomial outcome combination \((x_t, x_c)\) enumerated by allmultinom. The resulting region probability vector is summed over GoRegions and NoGoRegions to obtain \(\hat{g}_{Go,ij}\) and \(\hat{g}_{NoGo,ij}\). These are independent of the calibration scenario; only the multinomial weights differ.

Stage 2 (gamma sweep): For each pair \((\gamma_{\mathrm{go}}, \gamma_{\mathrm{nogo}})\) in the two-dimensional grid, operating characteristics are computed separately under each calibration scenario using the respective multinomial weights: $$\Pr(\mathrm{Go}) = \sum_{i,j} w_{ij}^{(\mathrm{go})} \mathbf{1}\!\left[\hat{g}_{Go,ij} \ge \gamma_{\mathrm{go}},\; \hat{g}_{NoGo,ij} < \gamma_{\mathrm{nogo}}\right]$$ $$\Pr(\mathrm{NoGo}) = \sum_{i,j} w_{ij}^{(\mathrm{nogo})} \mathbf{1}\!\left[\hat{g}_{NoGo,ij} \ge \gamma_{\mathrm{nogo}},\; \hat{g}_{Go,ij} < \gamma_{\mathrm{go}}\right]$$

Stage 3 (optimal threshold selection): For each candidate \(\gamma_{\mathrm{go}}\), the worst-case \(\Pr(\mathrm{Go})\) over all \(\gamma_{\mathrm{nogo}}\) in gamma_nogo_grid is computed; the optimal \(\gamma_{\mathrm{go}}\) is the smallest grid value for which this worst-case probability is less than target_go. Analogously, the optimal \(\gamma_{\mathrm{nogo}}\) is the smallest grid value for which the worst-case \(\Pr(\mathrm{NoGo})\) is less than target_nogo.

Examples

# Example 1: Controlled design, posterior probability
# gamma_go  : smallest gamma_go   s.t. max_{gamma_nogo} Pr(Go)   < 0.05 under Null
# gamma_nogo: smallest gamma_nogo s.t. max_{gamma_go}   Pr(NoGo) < 0.20 under Alt
# \donttest{
getgamma2bin(
  prob = 'posterior', design = 'controlled',
  GoRegions = 1L, NoGoRegions = 9L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = 0.15, pi_c2_go = 0.20, rho_c_go = 0.0,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = 0.15, pi_c2_nogo = 0.20, rho_c_nogo = 0.0,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = 0.15, theta_MAV1 = 0.10,
  theta_TV2   = 0.15, theta_MAV2 = 0.10,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  m_t = NULL, m_c = NULL,
  z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL,
  xe_t_00 = NULL, xe_t_01 = NULL, xe_t_10 = NULL, xe_t_11 = NULL,
  xe_c_00 = NULL, xe_c_01 = NULL, xe_c_10 = NULL, xe_c_11 = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)
#> $gamma_go
#> [1] 0.33
#> 
#> $gamma_nogo
#> [1] 0.31
#> 
#> $PrGo_opt
#> [1] 0.04881058
#> 
#> $PrNoGo_opt
#> [1] 0.1989759
#> 
#> $target_go
#> [1] 0.05
#> 
#> $target_nogo
#> [1] 0.2
#> 
#> $grid_results
#>    gamma_grid    PrGo_grid  PrNoGo_grid
#> 1        0.01 7.954652e-01 0.9076094016
#> 2        0.02 6.219577e-01 0.8216606338
#> 3        0.03 5.038653e-01 0.7537329388
#> 4        0.04 4.428904e-01 0.6824349823
#> 5        0.05 3.548199e-01 0.6540289681
#> 6        0.06 2.748603e-01 0.5672398968
#> 7        0.07 2.748603e-01 0.5672398968
#> 8        0.08 2.612604e-01 0.5296949464
#> 9        0.09 2.406585e-01 0.4960626303
#> 10       0.10 2.197303e-01 0.4753416443
#> 11       0.11 2.134679e-01 0.4511663319
#> 12       0.12 2.057089e-01 0.4390473431
#> 13       0.13 1.909921e-01 0.4224855216
#> 14       0.14 1.870645e-01 0.4086345799
#> 15       0.15 1.534393e-01 0.3650815086
#> 16       0.16 1.534393e-01 0.3650815086
#> 17       0.17 1.436005e-01 0.3533986212
#> 18       0.18 1.236183e-01 0.3153715619
#> 19       0.19 1.236183e-01 0.3153715619
#> 20       0.20 1.041959e-01 0.2940643040
#> 21       0.21 9.450037e-02 0.2727375534
#> 22       0.22 9.450037e-02 0.2727375534
#> 23       0.23 9.118507e-02 0.2641090262
#> 24       0.24 8.223704e-02 0.2460644920
#> 25       0.25 8.223704e-02 0.2460644920
#> 26       0.26 7.324800e-02 0.2388258610
#> 27       0.27 7.166373e-02 0.2318399716
#> 28       0.28 6.762415e-02 0.2225213086
#> 29       0.29 6.382009e-02 0.2109906522
#> 30       0.30 6.382009e-02 0.2109906522
#> 31       0.31 6.180689e-02 0.1989759203
#> 32       0.32 5.244006e-02 0.1852506914
#> 33       0.33 4.881058e-02 0.1795245956
#> 34       0.34 4.599055e-02 0.1706462283
#> 35       0.35 4.111934e-02 0.1483113311
#> 36       0.36 3.742751e-02 0.1432385405
#> 37       0.37 3.742751e-02 0.1432385405
#> 38       0.38 3.190546e-02 0.1360543668
#> 39       0.39 3.150340e-02 0.1300807145
#> 40       0.40 3.098482e-02 0.1238128667
#> 41       0.41 2.649500e-02 0.1157670280
#> 42       0.42 2.299867e-02 0.1112819983
#> 43       0.43 2.299867e-02 0.1112819983
#> 44       0.44 2.243108e-02 0.1029042874
#> 45       0.45 2.169296e-02 0.0915602898
#> 46       0.46 1.937837e-02 0.0871494245
#> 47       0.47 1.576021e-02 0.0780850428
#> 48       0.48 1.490842e-02 0.0743580317
#> 49       0.49 1.490842e-02 0.0743580317
#> 50       0.50 1.481575e-02 0.0699493719
#> 51       0.51 1.270689e-02 0.0674144577
#> 52       0.52 1.260624e-02 0.0643277841
#> 53       0.53 1.222108e-02 0.0614673129
#> 54       0.54 1.209327e-02 0.0599772299
#> 55       0.55 1.114765e-02 0.0588754629
#> 56       0.56 1.080676e-02 0.0583300889
#> 57       0.57 1.074479e-02 0.0543750074
#> 58       0.58 9.872575e-03 0.0522103409
#> 59       0.59 9.872575e-03 0.0522103409
#> 60       0.60 9.486246e-03 0.0491780871
#> 61       0.61 9.063257e-03 0.0465190192
#> 62       0.62 6.726751e-03 0.0393321601
#> 63       0.63 6.649731e-03 0.0361140903
#> 64       0.64 4.601979e-03 0.0343896701
#> 65       0.65 4.057688e-03 0.0328334696
#> 66       0.66 3.636068e-03 0.0290914110
#> 67       0.67 3.037808e-03 0.0272670776
#> 68       0.68 2.638302e-03 0.0246520549
#> 69       0.69 2.180574e-03 0.0214249754
#> 70       0.70 2.173047e-03 0.0187223689
#> 71       0.71 2.111176e-03 0.0183285893
#> 72       0.72 2.111176e-03 0.0183285893
#> 73       0.73 2.037318e-03 0.0172133824
#> 74       0.74 1.178799e-03 0.0149694452
#> 75       0.75 1.133578e-03 0.0144264329
#> 76       0.76 9.830169e-04 0.0130640302
#> 77       0.77 9.211805e-04 0.0119869609
#> 78       0.78 8.729897e-04 0.0111498478
#> 79       0.79 8.696250e-04 0.0098654145
#> 80       0.80 7.479437e-04 0.0093031631
#> 81       0.81 7.221845e-04 0.0079471159
#> 82       0.82 4.255952e-04 0.0066405643
#> 83       0.83 2.895582e-04 0.0056411040
#> 84       0.84 1.695243e-04 0.0050021829
#> 85       0.85 1.695243e-04 0.0050021829
#> 86       0.86 1.569124e-04 0.0038907680
#> 87       0.87 1.482270e-04 0.0033987807
#> 88       0.88 1.398892e-04 0.0031614087
#> 89       0.89 1.087453e-04 0.0026721717
#> 90       0.90 1.049929e-04 0.0024668154
#> 91       0.91 7.926244e-05 0.0019172697
#> 92       0.92 3.521455e-05 0.0013450644
#> 93       0.93 3.054274e-05 0.0011294849
#> 94       0.94 1.829396e-05 0.0005869932
#> 95       0.95 1.786995e-05 0.0004330819
#> 96       0.96 1.448157e-05 0.0002609640
#> 97       0.97 1.448157e-05 0.0002609640
#> 98       0.98 1.837227e-06 0.0001189892
#> 99       0.99 8.362059e-07 0.0000619464
#> 
#> attr(,"class")
#> [1] "getgamma2bin"
# }

# Example 2: Uncontrolled design, posterior probability
# \donttest{
getgamma2bin(
  prob = 'posterior', design = 'uncontrolled',
  GoRegions = 1L, NoGoRegions = 9L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = NULL, pi_c2_go = NULL, rho_c_go = NULL,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = NULL, pi_c2_nogo = NULL, rho_c_nogo = NULL,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = 0.15, theta_MAV1 = 0.10,
  theta_TV2   = 0.15, theta_MAV2 = 0.10,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  m_t = NULL, m_c = NULL,
  z00 = 3L, z01 = 2L, z10 = 3L, z11 = 2L,
  xe_t_00 = NULL, xe_t_01 = NULL, xe_t_10 = NULL, xe_t_11 = NULL,
  xe_c_00 = NULL, xe_c_01 = NULL, xe_c_10 = NULL, xe_c_11 = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)
#> $gamma_go
#> [1] 0.04
#> 
#> $gamma_nogo
#> [1] 0.77
#> 
#> $PrGo_opt
#> [1] 0.03985146
#> 
#> $PrNoGo_opt
#> [1] 0.1530204
#> 
#> $target_go
#> [1] 0.05
#> 
#> $target_nogo
#> [1] 0.2
#> 
#> $grid_results
#>    gamma_grid    PrGo_grid PrNoGo_grid
#> 1        0.01 2.360906e-01 0.999005176
#> 2        0.02 8.537207e-02 0.997969935
#> 3        0.03 5.341285e-02 0.995538106
#> 4        0.04 3.985146e-02 0.992193458
#> 5        0.05 2.030333e-02 0.987356172
#> 6        0.06 1.476160e-02 0.983409085
#> 7        0.07 1.476160e-02 0.983409085
#> 8        0.08 7.596110e-03 0.980224109
#> 9        0.09 5.074576e-03 0.977499472
#> 10       0.10 2.649928e-03 0.974309154
#> 11       0.11 1.988443e-03 0.948879263
#> 12       0.12 1.119360e-03 0.947942697
#> 13       0.13 6.989096e-04 0.932527558
#> 14       0.14 6.984393e-04 0.930138826
#> 15       0.15 5.296546e-04 0.921794917
#> 16       0.16 5.296546e-04 0.921794917
#> 17       0.17 2.580353e-04 0.908725900
#> 18       0.18 2.580353e-04 0.894369469
#> 19       0.19 2.580353e-04 0.894369469
#> 20       0.20 2.580353e-04 0.886963373
#> 21       0.21 7.765490e-05 0.881281258
#> 22       0.22 7.765490e-05 0.881281258
#> 23       0.23 7.765490e-05 0.865912514
#> 24       0.24 7.765490e-05 0.853182749
#> 25       0.25 7.765490e-05 0.853182749
#> 26       0.26 5.165530e-05 0.852948607
#> 27       0.27 3.553118e-05 0.841945265
#> 28       0.28 3.553118e-05 0.836147475
#> 29       0.29 3.533523e-05 0.831085913
#> 30       0.30 3.533523e-05 0.831085913
#> 31       0.31 3.533523e-05 0.798075886
#> 32       0.32 3.533523e-05 0.780212885
#> 33       0.33 1.645821e-05 0.775864543
#> 34       0.34 1.631893e-05 0.758055027
#> 35       0.35 1.631893e-05 0.712287796
#> 36       0.36 1.005936e-05 0.712287796
#> 37       0.37 1.005936e-05 0.712287796
#> 38       0.38 5.340107e-06 0.712287796
#> 39       0.39 5.340107e-06 0.702800221
#> 40       0.40 5.340107e-06 0.693912906
#> 41       0.41 4.180706e-06 0.618256789
#> 42       0.42 4.180706e-06 0.618256789
#> 43       0.43 4.180706e-06 0.618256789
#> 44       0.44 4.180706e-06 0.618256789
#> 45       0.45 1.821078e-06 0.597822010
#> 46       0.46 9.882688e-07 0.553043616
#> 47       0.47 9.882688e-07 0.553043616
#> 48       0.48 9.882688e-07 0.538812252
#> 49       0.49 9.882688e-07 0.538812252
#> 50       0.50 9.882688e-07 0.528044928
#> 51       0.51 9.882688e-07 0.503287408
#> 52       0.52 9.882688e-07 0.503287408
#> 53       0.53 8.702875e-07 0.501065579
#> 54       0.54 8.702875e-07 0.490298255
#> 55       0.55 8.702875e-07 0.490298255
#> 56       0.56 6.195771e-07 0.424278201
#> 57       0.57 3.246237e-07 0.374763161
#> 58       0.58 3.246237e-07 0.374763161
#> 59       0.59 3.246237e-07 0.374763161
#> 60       0.60 3.246237e-07 0.370725414
#> 61       0.61 3.246237e-07 0.324067011
#> 62       0.62 3.246237e-07 0.274075864
#> 63       0.63 2.413427e-07 0.266000372
#> 64       0.64 2.413427e-07 0.266000372
#> 65       0.65 2.413427e-07 0.266000372
#> 66       0.66 2.413427e-07 0.246003913
#> 67       0.67 3.314034e-08 0.246003913
#> 68       0.68 3.314034e-08 0.246003913
#> 69       0.69 3.314034e-08 0.231006569
#> 70       0.70 3.314034e-08 0.231006569
#> 71       0.71 3.314034e-08 0.231006569
#> 72       0.72 3.314034e-08 0.231006569
#> 73       0.73 3.314034e-08 0.231006569
#> 74       0.74 3.314034e-08 0.231006569
#> 75       0.75 3.314034e-08 0.231006569
#> 76       0.76 3.314034e-08 0.231006569
#> 77       0.77 2.967030e-08 0.153020380
#> 78       0.78 2.967030e-08 0.153020380
#> 79       0.79 7.982550e-09 0.134380824
#> 80       0.80 6.342300e-10 0.121572597
#> 81       0.81 6.342300e-10 0.121572597
#> 82       0.82 6.342300e-10 0.107779121
#> 83       0.83 6.342300e-10 0.107779121
#> 84       0.84 2.187000e-11 0.107779121
#> 85       0.85 2.187000e-11 0.107779121
#> 86       0.86 2.187000e-11 0.107779121
#> 87       0.87 2.187000e-11 0.107779121
#> 88       0.88 2.187000e-11 0.079926911
#> 89       0.89 2.187000e-11 0.079926911
#> 90       0.90 2.187000e-11 0.037087559
#> 91       0.91 2.187000e-11 0.037087559
#> 92       0.92 2.187000e-11 0.037087559
#> 93       0.93 2.187000e-11 0.037087559
#> 94       0.94 2.187000e-11 0.033639190
#> 95       0.95 2.187000e-11 0.012948977
#> 96       0.96 2.187000e-11 0.012948977
#> 97       0.97 2.187000e-11 0.012948977
#> 98       0.98 2.187000e-11 0.006544863
#> 99       0.99 0.000000e+00 0.001372310
#> 
#> attr(,"class")
#> [1] "getgamma2bin"
# }

# Example 3: External design, posterior probability
# \donttest{
getgamma2bin(
  prob = 'posterior', design = 'external',
  GoRegions = 1L, NoGoRegions = 9L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = 0.15, pi_c2_go = 0.20, rho_c_go = 0.0,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = 0.15, pi_c2_nogo = 0.20, rho_c_nogo = 0.0,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = 0.15, theta_MAV1 = 0.10,
  theta_TV2   = 0.15, theta_MAV2 = 0.10,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  m_t = NULL, m_c = NULL,
  z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL,
  xe_t_00 = NULL, xe_t_01 = NULL, xe_t_10 = NULL, xe_t_11 = NULL,
  xe_c_00 = 3L, xe_c_01 = 2L, xe_c_10 = 3L, xe_c_11 = 2L,
  alpha0e_t = NULL, alpha0e_c = 0.5,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)
#> $gamma_go
#> [1] 0.13
#> 
#> $gamma_nogo
#> [1] 0.48
#> 
#> $PrGo_opt
#> [1] 0.04324874
#> 
#> $PrNoGo_opt
#> [1] 0.1951535
#> 
#> $target_go
#> [1] 0.05
#> 
#> $target_nogo
#> [1] 0.2
#> 
#> $grid_results
#>    gamma_grid    PrGo_grid  PrNoGo_grid
#> 1        0.01 4.951001e-01 0.9724918617
#> 2        0.02 3.116979e-01 0.9455899595
#> 3        0.03 2.443279e-01 0.9252742205
#> 4        0.04 1.963479e-01 0.9008501883
#> 5        0.05 1.462569e-01 0.8786244333
#> 6        0.06 1.097866e-01 0.8264505887
#> 7        0.07 1.097866e-01 0.8264505887
#> 8        0.08 9.897378e-02 0.8083068444
#> 9        0.09 8.499661e-02 0.7947310196
#> 10       0.10 7.920292e-02 0.7649219450
#> 11       0.11 6.796985e-02 0.7426909894
#> 12       0.12 5.257477e-02 0.7242890019
#> 13       0.13 4.324874e-02 0.7047368395
#> 14       0.14 4.079363e-02 0.6921974703
#> 15       0.15 3.262187e-02 0.6327218991
#> 16       0.16 3.262187e-02 0.6327218991
#> 17       0.17 2.828468e-02 0.6184010956
#> 18       0.18 2.363096e-02 0.5803251493
#> 19       0.19 2.363096e-02 0.5803251493
#> 20       0.20 2.006980e-02 0.5657672258
#> 21       0.21 1.491666e-02 0.5269840989
#> 22       0.22 1.491666e-02 0.5269840989
#> 23       0.23 1.426930e-02 0.5102066608
#> 24       0.24 1.046571e-02 0.4827416927
#> 25       0.25 1.046571e-02 0.4827416927
#> 26       0.26 9.919009e-03 0.4659092125
#> 27       0.27 8.046368e-03 0.4537617984
#> 28       0.28 7.413101e-03 0.4334780198
#> 29       0.29 6.802545e-03 0.4018021690
#> 30       0.30 6.802545e-03 0.4018021690
#> 31       0.31 6.521756e-03 0.3898097115
#> 32       0.32 6.073910e-03 0.3748202662
#> 33       0.33 5.039330e-03 0.3652650187
#> 34       0.34 4.596183e-03 0.3574216368
#> 35       0.35 3.691812e-03 0.3344130560
#> 36       0.36 2.931371e-03 0.3263088504
#> 37       0.37 2.931371e-03 0.3263088504
#> 38       0.38 2.886885e-03 0.3137724315
#> 39       0.39 2.506523e-03 0.2992228280
#> 40       0.40 2.386474e-03 0.2838910320
#> 41       0.41 1.807754e-03 0.2665366346
#> 42       0.42 1.350043e-03 0.2563593316
#> 43       0.43 1.350043e-03 0.2563593316
#> 44       0.44 1.074185e-03 0.2435716216
#> 45       0.45 1.001765e-03 0.2316736773
#> 46       0.46 9.884577e-04 0.2151040914
#> 47       0.47 9.142112e-04 0.2019851787
#> 48       0.48 7.481832e-04 0.1951534931
#> 49       0.49 7.481832e-04 0.1951534931
#> 50       0.50 6.599170e-04 0.1928516421
#> 51       0.51 5.168863e-04 0.1830750182
#> 52       0.52 4.799139e-04 0.1803510089
#> 53       0.53 4.504407e-04 0.1659263615
#> 54       0.54 4.098998e-04 0.1588252248
#> 55       0.55 3.808166e-04 0.1558773408
#> 56       0.56 3.469071e-04 0.1476681885
#> 57       0.57 2.437967e-04 0.1356136489
#> 58       0.58 2.409133e-04 0.1334055133
#> 59       0.59 2.409133e-04 0.1334055133
#> 60       0.60 2.251424e-04 0.1271137383
#> 61       0.61 2.055742e-04 0.1128916663
#> 62       0.62 1.898606e-04 0.1070971944
#> 63       0.63 1.760575e-04 0.1023718680
#> 64       0.64 1.075865e-04 0.0958445638
#> 65       0.65 9.726792e-05 0.0920787241
#> 66       0.66 9.569993e-05 0.0842075692
#> 67       0.67 8.713419e-05 0.0777219594
#> 68       0.68 8.615661e-05 0.0750987339
#> 69       0.69 7.931109e-05 0.0701266638
#> 70       0.70 6.805616e-05 0.0656943273
#> 71       0.71 6.515731e-05 0.0608253406
#> 72       0.72 6.515731e-05 0.0608253406
#> 73       0.73 5.090134e-05 0.0554841972
#> 74       0.74 3.569443e-05 0.0525902031
#> 75       0.75 2.439426e-05 0.0468407231
#> 76       0.76 2.220424e-05 0.0392821432
#> 77       0.77 1.106530e-05 0.0374855213
#> 78       0.78 1.065260e-05 0.0341636875
#> 79       0.79 9.522423e-06 0.0316452501
#> 80       0.80 9.248391e-06 0.0301633321
#> 81       0.81 6.213362e-06 0.0254898508
#> 82       0.82 3.456849e-06 0.0213732912
#> 83       0.83 3.188458e-06 0.0188025730
#> 84       0.84 2.822047e-06 0.0170757920
#> 85       0.85 2.822047e-06 0.0170757920
#> 86       0.86 2.423144e-06 0.0140254410
#> 87       0.87 2.388355e-06 0.0132682065
#> 88       0.88 2.199758e-06 0.0108915190
#> 89       0.89 2.122337e-06 0.0091102526
#> 90       0.90 1.774688e-06 0.0078453927
#> 91       0.91 1.751080e-06 0.0063748660
#> 92       0.92 1.545205e-06 0.0053135773
#> 93       0.93 1.436975e-06 0.0044878808
#> 94       0.94 6.379328e-08 0.0024589850
#> 95       0.95 1.639072e-08 0.0015546968
#> 96       0.96 7.152402e-09 0.0012518743
#> 97       0.97 7.152402e-09 0.0012518743
#> 98       0.98 4.896475e-10 0.0009930829
#> 99       0.99 3.514889e-10 0.0006543539
#> 
#> attr(,"class")
#> [1] "getgamma2bin"
# }

# Example 4: Controlled design, predictive probability
# \donttest{
getgamma2bin(
  prob = 'predictive', design = 'controlled',
  GoRegions = 1L, NoGoRegions = 4L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = 0.15, pi_c2_go = 0.20, rho_c_go = 0.0,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = 0.15, pi_c2_nogo = 0.20, rho_c_nogo = 0.0,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = NULL, theta_MAV1 = NULL,
  theta_TV2   = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 0.10, theta_NULL2 = 0.10,
  m_t = 5L, m_c = 5L,
  z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL,
  xe_t_00 = NULL, xe_t_01 = NULL, xe_t_10 = NULL, xe_t_11 = NULL,
  xe_c_00 = NULL, xe_c_01 = NULL, xe_c_10 = NULL, xe_c_11 = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)
#> $gamma_go
#> [1] 0.39
#> 
#> $gamma_nogo
#> [1] 0.31
#> 
#> $PrGo_opt
#> [1] 0.04652919
#> 
#> $PrNoGo_opt
#> [1] 0.1900399
#> 
#> $target_go
#> [1] 0.05
#> 
#> $target_nogo
#> [1] 0.2
#> 
#> $grid_results
#>    gamma_grid    PrGo_grid  PrNoGo_grid
#> 1        0.01 9.750221e-01 9.821884e-01
#> 2        0.02 9.560457e-01 9.531104e-01
#> 3        0.03 9.178123e-01 9.284211e-01
#> 4        0.04 8.256217e-01 8.952698e-01
#> 5        0.05 7.865954e-01 8.675649e-01
#> 6        0.06 6.677635e-01 7.832358e-01
#> 7        0.07 6.677635e-01 7.832358e-01
#> 8        0.08 5.895814e-01 7.573131e-01
#> 9        0.09 5.625619e-01 7.187535e-01
#> 10       0.10 5.249304e-01 6.881344e-01
#> 11       0.11 4.758384e-01 6.493585e-01
#> 12       0.12 4.461752e-01 6.286040e-01
#> 13       0.13 4.069889e-01 5.902782e-01
#> 14       0.14 3.772822e-01 5.559979e-01
#> 15       0.15 3.379374e-01 4.949400e-01
#> 16       0.16 3.379374e-01 4.949400e-01
#> 17       0.17 3.072946e-01 4.712202e-01
#> 18       0.18 2.666951e-01 4.146777e-01
#> 19       0.19 2.666951e-01 4.146777e-01
#> 20       0.20 2.443417e-01 3.909106e-01
#> 21       0.21 2.125556e-01 3.562416e-01
#> 22       0.22 2.125556e-01 3.562416e-01
#> 23       0.23 1.954188e-01 3.307704e-01
#> 24       0.24 1.634662e-01 2.945441e-01
#> 25       0.25 1.634662e-01 2.945441e-01
#> 26       0.26 1.571988e-01 2.758060e-01
#> 27       0.27 1.398199e-01 2.546110e-01
#> 28       0.28 1.354864e-01 2.393323e-01
#> 29       0.29 1.207820e-01 2.124344e-01
#> 30       0.30 1.207820e-01 2.124344e-01
#> 31       0.31 1.019841e-01 1.900399e-01
#> 32       0.32 9.713049e-02 1.762344e-01
#> 33       0.33 8.555234e-02 1.613700e-01
#> 34       0.34 7.877063e-02 1.529513e-01
#> 35       0.35 6.976346e-02 1.333328e-01
#> 36       0.36 5.945680e-02 1.298143e-01
#> 37       0.37 5.945680e-02 1.298143e-01
#> 38       0.38 5.280726e-02 1.184796e-01
#> 39       0.39 4.652919e-02 1.103831e-01
#> 40       0.40 4.581529e-02 1.036333e-01
#> 41       0.41 3.821522e-02 8.623582e-02
#> 42       0.42 3.719169e-02 8.173403e-02
#> 43       0.43 3.719169e-02 8.173403e-02
#> 44       0.44 3.482630e-02 7.393386e-02
#> 45       0.45 3.289736e-02 6.699245e-02
#> 46       0.46 3.252666e-02 6.102545e-02
#> 47       0.47 2.636470e-02 5.678311e-02
#> 48       0.48 2.213166e-02 5.360107e-02
#> 49       0.49 2.213166e-02 5.360107e-02
#> 50       0.50 2.017763e-02 4.868277e-02
#> 51       0.51 1.728773e-02 4.375798e-02
#> 52       0.52 1.453412e-02 4.004738e-02
#> 53       0.53 1.048154e-02 3.802291e-02
#> 54       0.54 1.030742e-02 3.571268e-02
#> 55       0.55 9.493679e-03 3.326677e-02
#> 56       0.56 8.566147e-03 3.029447e-02
#> 57       0.57 6.301682e-03 2.621649e-02
#> 58       0.58 5.417523e-03 2.414322e-02
#> 59       0.59 5.417523e-03 2.414322e-02
#> 60       0.60 5.281986e-03 1.930606e-02
#> 61       0.61 3.962380e-03 1.751573e-02
#> 62       0.62 3.369319e-03 1.563887e-02
#> 63       0.63 2.713051e-03 1.440151e-02
#> 64       0.64 2.600807e-03 1.251723e-02
#> 65       0.65 1.365756e-03 1.136088e-02
#> 66       0.66 1.289188e-03 1.049695e-02
#> 67       0.67 1.011641e-03 9.029128e-03
#> 68       0.68 9.773410e-04 7.938702e-03
#> 69       0.69 8.777253e-04 5.794064e-03
#> 70       0.70 6.911078e-04 5.323342e-03
#> 71       0.71 4.305289e-04 5.085402e-03
#> 72       0.72 4.305289e-04 5.085402e-03
#> 73       0.73 3.541520e-04 4.108705e-03
#> 74       0.74 3.324469e-04 3.783933e-03
#> 75       0.75 2.673747e-04 3.428785e-03
#> 76       0.76 2.620069e-04 2.693566e-03
#> 77       0.77 2.427568e-04 2.296264e-03
#> 78       0.78 1.846475e-04 2.043808e-03
#> 79       0.79 1.807894e-04 1.745477e-03
#> 80       0.80 1.274326e-04 1.630126e-03
#> 81       0.81 1.092960e-04 1.330968e-03
#> 82       0.82 7.672251e-05 9.505534e-04
#> 83       0.83 6.523246e-05 5.765465e-04
#> 84       0.84 6.191225e-05 4.749659e-04
#> 85       0.85 6.191225e-05 4.749659e-04
#> 86       0.86 1.567049e-05 3.815961e-04
#> 87       0.87 1.381877e-05 3.094471e-04
#> 88       0.88 1.355148e-05 1.881015e-04
#> 89       0.89 1.153830e-05 9.742999e-05
#> 90       0.90 1.066501e-05 7.778447e-05
#> 91       0.91 2.124690e-06 5.591501e-05
#> 92       0.92 1.802019e-06 3.175768e-05
#> 93       0.93 1.151754e-06 1.616152e-05
#> 94       0.94 3.417970e-07 4.164678e-06
#> 95       0.95 8.630579e-09 1.388372e-06
#> 96       0.96 1.053585e-09 1.085243e-06
#> 97       0.97 1.053585e-09 1.085243e-06
#> 98       0.98 1.051088e-09 1.540722e-07
#> 99       0.99 3.805672e-10 6.681513e-08
#> 
#> attr(,"class")
#> [1] "getgamma2bin"
# }

# Example 5: Uncontrolled design, predictive probability
# \donttest{
getgamma2bin(
  prob = 'predictive', design = 'uncontrolled',
  GoRegions = 1L, NoGoRegions = 4L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = NULL, pi_c2_go = NULL, rho_c_go = NULL,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = NULL, pi_c2_nogo = NULL, rho_c_nogo = NULL,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = NULL, theta_MAV1 = NULL,
  theta_TV2   = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 0.10, theta_NULL2 = 0.10,
  m_t = 5L, m_c = 5L,
  z00 = 3L, z01 = 2L, z10 = 3L, z11 = 2L,
  xe_t_00 = NULL, xe_t_01 = NULL, xe_t_10 = NULL, xe_t_11 = NULL,
  xe_c_00 = NULL, xe_c_01 = NULL, xe_c_10 = NULL, xe_c_11 = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)
#> $gamma_go
#> [1] 0.09
#> 
#> $gamma_nogo
#> [1] 0.61
#> 
#> $PrGo_opt
#> [1] 0.04971972
#> 
#> $PrNoGo_opt
#> [1] 0.160196
#> 
#> $target_go
#> [1] 0.05
#> 
#> $target_nogo
#> [1] 0.2
#> 
#> $grid_results
#>    gamma_grid    PrGo_grid PrNoGo_grid
#> 1        0.01 8.151178e-01 0.999998946
#> 2        0.02 5.295714e-01 0.999762626
#> 3        0.03 4.523943e-01 0.998193777
#> 4        0.04 3.163886e-01 0.995003459
#> 5        0.05 1.773653e-01 0.994859570
#> 6        0.06 1.242958e-01 0.993468601
#> 7        0.07 1.242958e-01 0.993468601
#> 8        0.08 7.640987e-02 0.993029721
#> 9        0.09 4.971972e-02 0.988734741
#> 10       0.10 3.598005e-02 0.986361712
#> 11       0.11 3.250947e-02 0.984181347
#> 12       0.12 2.078376e-02 0.976580759
#> 13       0.13 1.561006e-02 0.971317820
#> 14       0.14 1.478674e-02 0.970863713
#> 15       0.15 7.026761e-03 0.959438516
#> 16       0.16 7.026761e-03 0.959438516
#> 17       0.17 6.363004e-03 0.955654020
#> 18       0.18 4.629536e-03 0.952471430
#> 19       0.19 4.629536e-03 0.952471430
#> 20       0.20 2.204888e-03 0.912951301
#> 21       0.21 1.360361e-03 0.892736353
#> 22       0.22 1.360361e-03 0.892736353
#> 23       0.23 9.230108e-04 0.854859463
#> 24       0.24 6.291061e-04 0.831216710
#> 25       0.25 6.291061e-04 0.831216710
#> 26       0.26 6.291061e-04 0.817297413
#> 27       0.27 6.283168e-04 0.817297413
#> 28       0.28 6.023172e-04 0.802320931
#> 29       0.29 1.060964e-04 0.760106185
#> 30       0.30 1.060964e-04 0.760106185
#> 31       0.31 1.060964e-04 0.760106185
#> 32       0.32 1.038678e-04 0.709486616
#> 33       0.33 1.038678e-04 0.687951968
#> 34       0.34 5.386842e-05 0.683166491
#> 35       0.35 3.054975e-05 0.622026447
#> 36       0.36 2.819012e-05 0.616101570
#> 37       0.37 2.819012e-05 0.616101570
#> 38       0.38 2.805084e-05 0.550081516
#> 39       0.39 2.785488e-05 0.538009690
#> 40       0.40 1.173076e-05 0.538009690
#> 41       0.41 7.011510e-06 0.518013231
#> 42       0.42 7.011510e-06 0.497578452
#> 43       0.43 7.011510e-06 0.497578452
#> 44       0.44 5.340107e-06 0.497578452
#> 45       0.45 5.340107e-06 0.450661608
#> 46       0.46 4.229694e-06 0.450661608
#> 47       0.47 4.021492e-06 0.402502511
#> 48       0.48 1.543883e-06 0.400280682
#> 49       0.49 1.543883e-06 0.400280682
#> 50       0.50 1.543883e-06 0.400280682
#> 51       0.51 1.012967e-06 0.400280682
#> 52       0.52 9.639786e-07 0.337298639
#> 53       0.53 9.639786e-07 0.337298639
#> 54       0.54 9.639786e-07 0.273586242
#> 55       0.55 1.311690e-07 0.273586242
#> 56       0.56 4.788801e-08 0.273586242
#> 57       0.57 4.788801e-08 0.228898099
#> 58       0.58 4.788801e-08 0.228898099
#> 59       0.59 4.788801e-08 0.228898099
#> 60       0.60 4.788801e-08 0.228898099
#> 61       0.61 4.788801e-08 0.160195980
#> 62       0.62 4.788801e-08 0.127820762
#> 63       0.63 4.053969e-08 0.127820762
#> 64       0.64 4.053969e-08 0.127820762
#> 65       0.65 4.053969e-08 0.127820762
#> 66       0.66 4.053969e-08 0.127820762
#> 67       0.67 3.706965e-08 0.069392334
#> 68       0.68 2.232198e-08 0.069392334
#> 69       0.69 1.501740e-09 0.058251450
#> 70       0.70 8.893800e-10 0.058251450
#> 71       0.71 8.893800e-10 0.058251450
#> 72       0.72 8.893800e-10 0.058251450
#> 73       0.73 2.187000e-11 0.058251450
#> 74       0.74 2.187000e-11 0.058251450
#> 75       0.75 2.187000e-11 0.045443222
#> 76       0.76 2.187000e-11 0.045443222
#> 77       0.77 2.187000e-11 0.024753009
#> 78       0.78 2.187000e-11 0.016397346
#> 79       0.79 2.187000e-11 0.016397346
#> 80       0.80 2.187000e-11 0.009993232
#> 81       0.81 2.187000e-11 0.009993232
#> 82       0.82 2.187000e-11 0.006544863
#> 83       0.83 0.000000e+00 0.001372310
#> 84       0.84 0.000000e+00 0.001372310
#> 85       0.85 0.000000e+00 0.001372310
#> 86       0.86 0.000000e+00 0.001372310
#> 87       0.87 0.000000e+00 0.001372310
#> 88       0.88 0.000000e+00 0.001372310
#> 89       0.89 0.000000e+00 0.001372310
#> 90       0.90 0.000000e+00 0.001372310
#> 91       0.91 0.000000e+00 0.001372310
#> 92       0.92 0.000000e+00 0.001372310
#> 93       0.93 0.000000e+00 0.001372310
#> 94       0.94 0.000000e+00 0.000000000
#> 95       0.95 0.000000e+00 0.000000000
#> 96       0.96 0.000000e+00 0.000000000
#> 97       0.97 0.000000e+00 0.000000000
#> 98       0.98 0.000000e+00 0.000000000
#> 99       0.99 0.000000e+00 0.000000000
#> 
#> attr(,"class")
#> [1] "getgamma2bin"
# }

# Example 6: External design, predictive probability
# \donttest{
getgamma2bin(
  prob = 'predictive', design = 'external',
  GoRegions = 1L, NoGoRegions = 4L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = 0.15, pi_c2_go = 0.20, rho_c_go = 0.0,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = 0.15, pi_c2_nogo = 0.20, rho_c_nogo = 0.0,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = NULL, theta_MAV1 = NULL,
  theta_TV2   = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 0.10, theta_NULL2 = 0.10,
  m_t = 5L, m_c = 5L,
  z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL,
  xe_t_00 = 3L, xe_t_01 = 2L, xe_t_10 = 3L, xe_t_11 = 2L,
  xe_c_00 = NULL, xe_c_01 = NULL, xe_c_10 = NULL, xe_c_11 = NULL,
  alpha0e_t = 0.5, alpha0e_c = NULL,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)
#> $gamma_go
#> [1] 0.5
#> 
#> $gamma_nogo
#> [1] 0.24
#> 
#> $PrGo_opt
#> [1] 0.04940784
#> 
#> $PrNoGo_opt
#> [1] 0.1750539
#> 
#> $target_go
#> [1] 0.05
#> 
#> $target_nogo
#> [1] 0.2
#> 
#> $grid_results
#>    gamma_grid    PrGo_grid  PrNoGo_grid
#> 1        0.01 9.994349e-01 9.920354e-01
#> 2        0.02 9.964521e-01 9.713186e-01
#> 3        0.03 9.928036e-01 9.464356e-01
#> 4        0.04 9.886331e-01 9.034024e-01
#> 5        0.05 9.817743e-01 8.593528e-01
#> 6        0.06 9.512176e-01 7.512254e-01
#> 7        0.07 9.512176e-01 7.512254e-01
#> 8        0.08 9.266539e-01 7.257879e-01
#> 9        0.09 9.009688e-01 6.749665e-01
#> 10       0.10 8.895978e-01 6.242615e-01
#> 11       0.11 8.723639e-01 5.766174e-01
#> 12       0.12 8.512200e-01 5.366685e-01
#> 13       0.13 8.346112e-01 5.007527e-01
#> 14       0.14 8.180101e-01 4.666235e-01
#> 15       0.15 7.662686e-01 4.015641e-01
#> 16       0.16 7.662686e-01 4.015641e-01
#> 17       0.17 7.524781e-01 3.638887e-01
#> 18       0.18 7.024638e-01 3.039011e-01
#> 19       0.19 7.024638e-01 3.039011e-01
#> 20       0.20 6.590072e-01 2.767728e-01
#> 21       0.21 5.913884e-01 2.294137e-01
#> 22       0.22 5.913884e-01 2.294137e-01
#> 23       0.23 5.343147e-01 2.114896e-01
#> 24       0.24 4.766412e-01 1.750539e-01
#> 25       0.25 4.766412e-01 1.750539e-01
#> 26       0.26 4.536376e-01 1.565300e-01
#> 27       0.27 4.287813e-01 1.407700e-01
#> 28       0.28 4.192047e-01 1.246640e-01
#> 29       0.29 3.562449e-01 1.030596e-01
#> 30       0.30 3.562449e-01 1.030596e-01
#> 31       0.31 3.304460e-01 9.418694e-02
#> 32       0.32 3.119337e-01 8.084137e-02
#> 33       0.33 2.873753e-01 7.357231e-02
#> 34       0.34 2.493040e-01 6.230969e-02
#> 35       0.35 2.256572e-01 4.930966e-02
#> 36       0.36 2.039489e-01 4.438832e-02
#> 37       0.37 2.039489e-01 4.438832e-02
#> 38       0.38 1.938691e-01 3.855650e-02
#> 39       0.39 1.760407e-01 3.463117e-02
#> 40       0.40 1.470093e-01 3.078975e-02
#> 41       0.41 1.069093e-01 2.536763e-02
#> 42       0.42 1.012641e-01 2.257785e-02
#> 43       0.43 1.012641e-01 2.257785e-02
#> 44       0.44 9.347793e-02 1.900238e-02
#> 45       0.45 8.276777e-02 1.626835e-02
#> 46       0.46 7.789344e-02 1.484156e-02
#> 47       0.47 7.290147e-02 1.184308e-02
#> 48       0.48 6.509581e-02 1.016197e-02
#> 49       0.49 6.509581e-02 1.016197e-02
#> 50       0.50 4.940784e-02 8.420224e-03
#> 51       0.51 4.872419e-02 6.907657e-03
#> 52       0.52 3.709404e-02 5.842116e-03
#> 53       0.53 3.271448e-02 4.233733e-03
#> 54       0.54 2.905321e-02 3.691869e-03
#> 55       0.55 2.672177e-02 3.173353e-03
#> 56       0.56 2.424709e-02 2.794924e-03
#> 57       0.57 1.928262e-02 2.126583e-03
#> 58       0.58 1.886772e-02 1.859341e-03
#> 59       0.59 1.886772e-02 1.859341e-03
#> 60       0.60 1.875611e-02 1.462878e-03
#> 61       0.61 1.644774e-02 1.312541e-03
#> 62       0.62 1.620749e-02 1.194313e-03
#> 63       0.63 1.482458e-02 9.621153e-04
#> 64       0.64 1.257891e-02 8.306942e-04
#> 65       0.65 7.813557e-03 6.547937e-04
#> 66       0.66 5.429133e-03 5.692695e-04
#> 67       0.67 5.165630e-03 4.415062e-04
#> 68       0.68 3.840255e-03 3.316454e-04
#> 69       0.69 1.897765e-03 2.015186e-04
#> 70       0.70 1.309016e-03 1.545178e-04
#> 71       0.71 1.067691e-03 1.055070e-04
#> 72       0.72 1.067691e-03 1.055070e-04
#> 73       0.73 7.505195e-04 7.457204e-05
#> 74       0.74 6.616280e-04 6.089287e-05
#> 75       0.75 5.661194e-04 4.579137e-05
#> 76       0.76 2.874544e-04 3.806392e-05
#> 77       0.77 2.336267e-04 3.047739e-05
#> 78       0.78 1.514313e-04 2.073584e-05
#> 79       0.79 1.390695e-04 1.305223e-05
#> 80       0.80 6.605397e-05 1.105473e-05
#> 81       0.81 6.450185e-05 9.267511e-06
#> 82       0.82 4.124954e-05 3.716999e-06
#> 83       0.83 4.055159e-05 2.314058e-06
#> 84       0.84 3.954597e-05 1.977748e-06
#> 85       0.85 3.954597e-05 1.977748e-06
#> 86       0.86 2.326379e-05 1.396659e-06
#> 87       0.87 2.309503e-05 5.994163e-07
#> 88       0.88 2.042319e-06 4.886352e-07
#> 89       0.89 7.683096e-08 3.482391e-07
#> 90       0.90 7.532573e-08 1.486180e-07
#> 91       0.91 5.968255e-08 9.570758e-08
#> 92       0.92 1.027781e-10 4.762625e-08
#> 93       0.93 1.027781e-10 3.660138e-08
#> 94       0.94 1.009618e-10 7.582470e-09
#> 95       0.95 4.263921e-11 3.808649e-09
#> 96       0.96 0.000000e+00 2.953392e-09
#> 97       0.97 0.000000e+00 2.953392e-09
#> 98       0.98 0.000000e+00 4.057484e-10
#> 99       0.99 0.000000e+00 2.883704e-11
#> 
#> attr(,"class")
#> [1] "getgamma2bin"
# }