NA
```
## Using tidy `crmPack` data
Tidy `crmPack` data can be easily reported using `knitr` or similar packages in the obvious way.
### Cohort size
The cohort size for this trial is determined by the dose to be used in the current cohort according to the rules described in the table below:
``` r
CohortSizeRange(
intervals = c(0, 50, 300),
cohort_size = c(1, 3, 5)
) %>%
tidy() %>%
kable(
col.names = c("Min", "Max", "Cohort size"),
caption = "Rules for selecting the cohort size"
) %>%
add_header_above(c("Dose" = 2, " " = 1))
```
Rules for selecting the cohort size
Dose |
|
| Min |
Max |
Cohort size |
| 0 |
50 |
1 |
| 50 |
300 |
3 |
| 300 |
Inf |
5 |
Or presentations not directly supported by `crmPack` can be easily produced. Here, we create plots of the dose-specific PDFs for prior probabilities of toxicity after the first DLT is observed in a fictional trial.
``` r
options <- McmcOptions(
burnin = 5000,
step = 1,
samples = 40000
)
data <- Data(
doseGrid = c(1, 3, 5, 10, 15, 20, 25, 40, 50, 80, 100),
x = c(1, 3, 5, 10, 15, 15, 15),
y = c(0, 0, 0, 0, 0, 1, 0),
ID = 1L:7L,
cohort = as.integer(c(1:4, 5, 5, 5))
)
model <- LogisticLogNormal(
mean = c(-1, 0),
cov =
matrix(c(3, -0.1, -0.1, 4),
nrow = 2
),
ref_dose = 56
)
samples <- mcmc(data, model, options)
tidySamples <- samples %>% tidy()
# The magrittr pipe is necessary here
tidySamples$data %>%
expand(
nesting(!!!.[1:10]),
Dose = data@doseGrid[2:11]
) %>%
mutate(Prob = probFunction(model, alpha0 = alpha0, alpha1 = alpha1)(Dose)) %>%
ggplot() +
geom_density(aes(x = Prob, colour = as.factor(Dose)), adjust = 1.5) +
labs(
title = "Posterior dose-specific PDFs for p(Tox)",
caption = "Dose 1 omitted as p(Tox) is essentially 0",
x = "p(Tox)"
) +
scale_colour_discrete("Dose") +
theme_light() +
theme(
axis.ticks.y = element_blank(),
axis.text.y = element_blank(),
axis.title.y = element_blank()
)
```
# Environment
``` r
sessionInfo()
#> R version 4.6.1 (2026-06-24)
#> Platform: aarch64-apple-darwin23
#> Running under: macOS Golden Gate 27.0.1
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
#>
#> locale:
#> [1] C.UTF-8/C.UTF-8/C.UTF-8/C/C.UTF-8/C.UTF-8
#>
#> time zone: Europe/Zurich
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] magrittr_2.0.5 kableExtra_1.4.0 tibble_3.3.1 ggmcmc_1.5.1.2
#> [5] tidyr_1.3.2 dplyr_1.2.1 data.tree_1.2.0 knitr_1.52
#> [9] decider_0.0.0.9012 crmPack_2.3.0 testthat_3.3.2 ggplot2_4.0.3
#> [13] webshot2_0.1.2
#>
#> loaded via a namespace (and not attached):
#> [1] RColorBrewer_1.1-3 tensorA_0.36.2.1 sys_3.4.3
#> [4] rstudioapi_0.19.0 jsonlite_2.0.0 farver_2.1.2
#> [7] rmarkdown_2.32 fs_2.1.0 ragg_1.5.2
#> [10] vctrs_0.7.3 rhub_2.0.1 memoise_2.0.1
#> [13] askpass_1.2.1 webshot_0.5.5 htmltools_0.5.9
#> [16] usethis_3.2.2 distributional_0.8.1 lambda.r_1.2.4
#> [19] curl_8.0.0 rjags_4-17 GenSA_1.1.15
#> [22] parallelly_1.48.0 StanHeaders_2.32.10 htmlwidgets_1.6.4
#> [25] desc_1.4.3 futile.options_1.0.1 cachem_1.1.0
#> [28] lifecycle_1.0.5 iterators_1.0.14 pkgconfig_2.0.3
#> [31] Matrix_1.7-6 R6_2.6.1 fastmap_1.2.0
#> [34] rbibutils_2.4.1 digest_0.6.39 GGally_2.4.0
#> [37] rprojroot_2.1.1 pkgload_1.5.3 textshaping_1.0.5
#> [40] labeling_0.4.3 abind_1.4-8 httr_1.4.9
#> [43] compiler_4.6.1 rngtools_1.5.2 withr_3.0.3
#> [46] doParallel_1.0.17 S7_0.2.2 backports_1.5.1
#> [49] inline_0.3.21 ggstats_0.13.0 QuickJSR_1.11.0
#> [52] pkgbuild_1.4.8 R.utils_2.13.0 MASS_7.3-66
#> [55] openssl_2.4.2 rappdirs_0.3.4 sessioninfo_1.2.4
#> [58] loo_2.10.1 tools_4.6.1 chromote_0.5.1
#> [61] otel_0.2.0 zip_3.0.2 R.oo_1.27.1
#> [64] glue_1.8.1 DiagrammeR_1.0.12 R.cache_0.17.0
#> [67] promises_1.5.0 grid_4.6.1 checkmate_2.3.4
#> [70] generics_0.1.4 gtable_0.3.6 R.methodsS3_1.8.2
#> [73] flock_0.7 websocket_1.4.4 utf8_1.2.6
#> [76] xml2_1.6.0 foreach_1.5.2 pillar_1.11.1
#> [79] stringr_1.6.0 posterior_1.7.0 later_1.4.8
#> [82] splines_4.6.1 lattice_0.23-1 survival_3.8-12
#> [85] tidyselect_1.2.1 httpgd_2.1.4 gitcreds_0.1.2
#> [88] gridExtra_2.3.1 V8_8.2.0 svglite_2.2.2
#> [91] stats4_4.6.1 futile.logger_1.4.9 xfun_0.61
#> [94] devtools_2.5.2 credentials_2.0.3 brio_1.1.5
#> [97] matrixStats_1.5.0 rstan_2.32.7 visNetwork_2.1.4
#> [100] stringi_1.8.9 rematch_2.0.0 unigd_0.2.0
#> [103] yaml_2.3.12 evaluate_1.0.5 codetools_0.2-20
#> [106] sess_3.0.1 cli_3.6.6 RcppParallel_6.2.0
#> [109] systemfonts_1.3.2 Rdpack_2.6.6 processx_3.9.0
#> [112] styler_1.11.0 Rcpp_1.1.2 gert_2.3.1
#> [115] coda_0.19-4.1 parallel_4.6.1 ellipsis_0.3.3
#> [118] whoami_1.3.0 doRNG_1.8.6.3 viridisLite_0.4.3
#> [121] mvtnorm_1.4-2 scales_1.4.0 openxlsx_4.2.8.1
#> [124] purrr_1.2.2 rlang_1.3.0 formatR_1.14
```