`library(SMARTbayesR)`

This R package provides functions for power analysis and the construction of the set of best embedded dynamic treatment regimes (EDTR) using Bayesian multiple comparison with the best (MCB) methodology. This entails the construction of simultaneous one-sided upper credible intervals for the difference between each EDTR’s summary statistic and the best EDTRs. It is designed for binary outcomes in sequential, multiple assignment, randomized trials.

We extend frequentist methods to the Bayesian setting. In particular, one may determine what sample size to enroll in order to achieve a specified power, where power is the probability of excluding inferior embedded dynamic treatment regimes from the set of best.

The set of best consists of EDTRs which are not significantly inferior to the optimal or best embedded dynamic treatment regime (Artman et al. 2020).

The best EDTR is included in the set of best with probability at least \(1-\alpha\).

In this vignette, we outline how the functions may be used together to achieve these goals.

First, run \(\texttt{SimDesign1}\) to simulate a design-1 SMART.

Then, apply \(\texttt{PosteriorTrtSeqProb}\) to sample from the posterior of the probabilities of response at each stage.

To obtain draws from the probabilities of response for each of the embedded dynamic treatment regimes (EDTRs), run \(\texttt{PosteriorEDTRProbs}\).

In order to construct the set of best (or equivalently, upper credible interval limits), run \(\texttt{MCBUpperLimits}\).

```
set.seed(23856)
<- SimDesign1(sample_size = 250,
dat response_prob = c(0.2,0.3,0.4,0.5,0.6,0.7),
stage_one_trt_one_response_prob = 0.7,
stage_one_trt_two_response_prob = 0.4)
```

```
set.seed(39864)
<- PosteriorTrtSeqProb(niter = 10000,
posterior_trt_seq_draws
dat,design = "design-1")
```

Convert draws from each treatment sequence to draws from each embedded DTR.

`<- PosteriorEDTRProbs(posterior_trt_seq_draws) posterior_EDTR_draws `

```
MCBUpperLimits(thetadraws=posterior_EDTR_draws,
alpha=0.05,
design="design-1",
type="log-OR")
#> [1] -0.8337268 -0.9920360 0.4241352 0.0000000
```

Note that EDTRs 1 and 2 are statistically significantly inferior to EDTR 4 whereas EDTR 3 is not.

To see what the log-odds ratios are, run \(\texttt{LogOR}\). Lastly, to compute the power to exclude inferior embedded dynamic treatment regimes (EDTRs) from the set of best (or equivalently, for their upper credible interval to exclude 0), run \(\texttt{PowerBayesian}\).

Compute log-OR of a success.

```
LogOR(response_prob = c(0.3,0.3,0.3,0.8,0.6,0.7),
stage_one_trt_one_response_prob = 0.6,
stage_one_trt_two_response_prob = 0.4,
design = "design-1")
#> EDTR 1 EDTR 2 EDTR 3 EDTR 4
#> [1,] -1.893266 -1.893266 -0.2921968 0
```

Compute power to exclude embedded dynamic treatment regimes 1 and 2. The choice to exclude these embedded dynamic treatment regimes may be based off the values of the log-OR between each EDTR and the best.

```
set.seed(2364)
<- PowerBayesian("design-1",
power1 sample_size = 100,
response_prob = c(0.2,0.3,0.4,0.5,0.6,0.7),
stage_one_trt_one_response_prob = 0.6,
stage_one_trt_two_response_prob = 0.4,
type="log-OR",
threshold=1)
```

```
power1#> [1] 0.8182
```

To see what the log-relative-risk are, run \(\texttt{LogRR}\). Lastly, to compute the power to exclude inferior embedded dynamic treatment regimes (EDTRs) from the set of best (or equivalently, for their upper credible interval to exclude 0), run \(\texttt{PowerBayesian}\).

Compute log-RR of a success.

```
LogRR(response_prob = c(0.3,0.3,0.3,0.8,0.6,0.7),
stage_one_trt_one_response_prob = 0.6,
stage_one_trt_two_response_prob = 0.4,
design = "design-1")
#> EDTR 1 EDTR 2 EDTR 3 EDTR 4
#> [1,] -0.9028677 -0.9028677 -0.08455739 0
```

Compute power to exclude embedded dynamic treatment regimes 1 and 2. The choice to exclude these embedded dynamic treatment regimes may be based off the values of the log-RR between each EDTR and the best.

```
set.seed(23641)
<- PowerBayesian("design-1",
power2 sample_size = 100,
response_prob = c(0.2,0.3,0.4,0.5,0.6,0.7),
stage_one_trt_one_response_prob = 0.6,
stage_one_trt_two_response_prob = 0.4,
type="log-RR",
threshold=0.8)
```

```
power2#> [1] 0.9256
```

To see what the risk difference are, run \(\texttt{RD}\). Lastly, to compute the power to exclude inferior embedded dynamic treatment regimes (EDTRs) from the set of best (or equivalently, for their upper credible interval to exclude 0), run \(\texttt{PowerBayesian}\).

Compute RD of a success.

```
RD(response_prob = c(0.3,0.3,0.3,0.8,0.6,0.7),
stage_one_trt_one_response_prob = 0.6,
stage_one_trt_two_response_prob = 0.4,
design = "design-1")
#> EDTR 1 EDTR 2 EDTR 3 EDTR 4
#> [1,] -0.44 -0.44 -0.06 0
```

Compute power to exclude embedded dynamic treatment regimes 1 and 2. The choice to exclude these embedded dynamic treatment regimes may be based off the values of the log-RR between each EDTR and the best.

```
set.seed(236412)
<- PowerBayesian("design-1",
power3 sample_size = 100,
response_prob = c(0.2,0.3,0.4,0.5,0.6,0.7),
stage_one_trt_one_response_prob = 0.6,
stage_one_trt_two_response_prob = 0.4,
type="RD",
threshold=0.3)
```

```
power3#> [1] 0.8206
```

#General SMART To see what the log-odds ratios are, run \(\texttt{LogOR}\). Lastly, to compute the power to exclude inferior embedded dynamic treatment regimes (EDTRs) from the set of best (or equivalently, for their upper credible interval to exclude 0), run \(\texttt{PowerBayesian}\).

Compute log-OR of a success.

```
LogOR(response_prob = c(0.2,0.3,0.4,0.5,0.6,0.7,0.7,0.6),
stage_one_trt_one_response_prob = 0.6,
stage_one_trt_two_response_prob = 0.4,
design = "general")
#> EDTR 1 EDTR 2 EDTR 3 EDTR 4 EDTR 5 EDTR 6 EDTR 7
#> [1,] -1.791759 -1.60107 -1.510592 -1.336846 -0.1840036 -0.4418328 0
#> EDTR 8
#> [1,] -0.2719337
```

Compute power to exclude embedded dynamic treatment regimes 1, 2, 3, 4. The choice to exclude these embedded dynamic treatment regimes may be based off the values of the log-OR between each EDTR and the best.

```
set.seed(23644)
<- PowerBayesian("general",
power4 sample_size = 250,
response_prob = c(0.2,0.3,0.4,0.5,0.6,0.7,0.7,0.6),
stage_one_trt_one_response_prob = 0.6,
stage_one_trt_two_response_prob = 0.4,
type="log-OR",
threshold=1)
```

```
power4#> [1] 0.9286
```

To see what the log-odds ratios are, run \(\texttt{LogOR}\). Lastly, to compute the power to exclude inferior embedded dynamic treatment regimes (EDTRs) from the set of best (or equivalently, for their upper credible interval to exclude 0), run \(\texttt{PowerBayesian}\).

Compute log-OR of a success.

```
LogOR(response_prob = c(0.2,0.3,0.4,0.5,0.6,0.7,0.7,0.6,0.9),
stage_one_trt_one_response_prob = 0.6,
stage_one_trt_two_response_prob = 0.4,
stage_one_trt_three_response_prob = 0.7,
design = "design-3")
#> EDTR 1 EDTR 2 EDTR 3 EDTR 4 EDTR 5 EDTR 6
#> [1,] -2.305359 -2.097141 -0.9115175 -0.6631313 -0.4444945 0
```

Compute power to exclude embedded dynamic treatment regimes 1, 2, and 3. The choice to exclude these embedded dynamic treatment regimes may be based off the values of the log-OR between each EDTR and the best.

```
set.seed(236445)
<- PowerBayesian("design-3",
power5 sample_size = 250,
response_prob = c(0.2,0.3,0.4,0.5,0.6,0.7,0.7,0.6,0.9),
stage_one_trt_one_response_prob = 0.6,
stage_one_trt_two_response_prob = 0.4,
stage_one_trt_three_response_prob = 0.7,
type="log-OR",
threshold=0.8)
```

```
power5#> [1] 0.4299
```

Artman, W. J., Ertefaie, A., Lynch, K. G., & McKay, J. R. (2020). Bayesian Set of Best Dynamic Treatment Regimes and Sample Size Determination for SMARTs with Binary Outcomes. arXiv preprint arXiv:2008.02341.