RATET01
Event Rate Summary for Recurrent Events
This example will focus on data from a single visit “WEEK 1 DAY 8” and a single endpoint “FKSI-FWB”. Only evaluable populations will be analyzed.
Code
lyt <- basic_table(show_colcounts = TRUE) %>%
split_cols_by("ARM", ref_group = "B: Placebo", split_fun = ref_group_position("first")) %>%
analyze_vars(
"AVAL_f",
var_labels = "Number of exacerbations per patient",
.stats = c("count_fraction"),
.formats = c("count_fraction" = "xx (xx.xx%)"),
.labels = c("Number of exacerbations per patient")
) %>%
summarize_glm_count(
vars = "AVAL",
variables = list(arm = "ARM", offset = "lgTMATRSK", covariates = NULL),
conf_level = 0.95,
distribution = "poisson",
rate_mean_method = "emmeans",
var_labels = "Unadjusted exacerbation rate (per year)",
table_names = "unadj",
.stats = c("rate"),
.labels = c(rate = "Rate")
) %>%
summarize_glm_count(
vars = "AVAL",
variables = list(arm = "ARM", offset = "lgTMATRSK", covariates = c("REGION1")),
conf_level = 0.95,
distribution = "quasipoisson",
rate_mean_method = "ppmeans",
var_labels = "Adjusted (QP) exacerbation rate (per year)",
table_names = "adj-qp",
.stats = c("rate", "rate_ci", "rate_ratio", "rate_ratio_ci", "pval"),
.labels = c(
rate = "Rate", rate_ci = "Rate CI", rate_ratio = "Rate Ratio",
rate_ratio_ci = "Rate Ratio CI", pval = "p value"
)
) %>%
summarize_glm_count(
vars = "AVAL",
variables = list(arm = "ARM", offset = "lgTMATRSK", covariates = c("REGION1")),
conf_level = 0.95,
distribution = "negbin",
rate_mean_method = "emmeans",
var_labels = "Adjusted (NB) exacerbation rate (per year)",
table_names = "adj-nb",
.stats = c("rate", "rate_ci", "rate_ratio", "rate_ratio_ci", "pval"),
.labels = c(
rate = "Rate", rate_ci = "Rate CI", rate_ratio = "Rate Ratio",
rate_ratio_ci = "Rate Ratio CI", pval = "p value"
)
)
result <- build_table(
lyt = lyt,
df = anl
)
result
B: Placebo A: Drug X C: Combination
(N=134) (N=134) (N=132)
---------------------------------------------------------------------------------------------------
Number of exacerbations per patient
0 10 (7.46%) 6 (4.48%) 11 (8.33%)
1 25 (18.66%) 21 (15.67%) 14 (10.61%)
2 38 (28.36%) 41 (30.60%) 33 (25.00%)
3 22 (16.42%) 26 (19.40%) 21 (15.91%)
4 13 (9.70%) 18 (13.43%) 30 (22.73%)
5 11 (8.21%) 10 (7.46%) 12 (9.09%)
6 10 (7.46%) 7 (5.22%) 7 (5.30%)
7 3 (2.24%) 4 (2.99%) 3 (2.27%)
8 1 (0.75%) 1 (0.75%) 1 (0.76%)
9 1 (0.75%) 0 (0.00%) 0 (0.00%)
Unadjusted exacerbation rate (per year)
Rate 7.2364 8.2148 9.8131
Adjusted (QP) exacerbation rate (per year)
Rate 2.4550 2.8514 3.4304
Rate CI (1.6194, 3.7219) (1.8974, 4.2850) (2.2946, 5.1284)
Rate Ratio 1.1615 1.3973
Rate Ratio CI (0.6462, 2.0877) (0.7789, 2.5067)
p value 0.6169 0.2619
Adjusted (NB) exacerbation rate (per year)
Rate 2.7374 2.8150 2.9789
Rate CI (2.3932, 3.1311) (2.4681, 3.2106) (2.6152, 3.3932)
Rate Ratio 1.0283 1.0882
Rate Ratio CI (0.8856, 1.1941) (0.9381, 1.2624)
p value 0.7140 0.2643
Timestamp
Session Info
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
locale:
[1] C
time zone: Etc/UTC
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.1.4 tern_0.9.4 rtables_0.6.7 magrittr_2.0.3
[5] formatters_0.5.6 scda.2022_0.1.5 scda_0.1.6
loaded via a namespace (and not attached):
[1] sandwich_3.1-0 utf8_1.2.4 generics_0.1.3 tidyr_1.3.1
[5] stringi_1.8.4 lattice_0.22-6 digest_0.6.35 evaluate_0.23
[9] grid_4.4.0 estimability_1.5 mvtnorm_1.2-4 fastmap_1.1.1
[13] jsonlite_1.8.8 Matrix_1.7-0 backports_1.4.1 brio_1.1.5
[17] survival_3.6-4 multcomp_1.4-25 purrr_1.0.2 fansi_1.0.6
[21] scales_1.3.0 TH.data_1.1-2 codetools_0.2-20 Rdpack_2.6
[25] cli_3.6.2 rlang_1.1.3 rbibutils_2.2.16 munsell_0.5.1
[29] splines_4.4.0 yaml_2.3.8 tools_4.4.0 checkmate_2.3.1
[33] coda_0.19-4.1 colorspace_2.1-0 ggplot2_3.5.1 forcats_1.0.0
[37] broom_1.0.5 vctrs_0.6.5 R6_2.5.1 zoo_1.8-12
[41] lifecycle_1.0.4 emmeans_1.10.1 htmlwidgets_1.6.4 MASS_7.3-60.2
[45] pkgconfig_2.0.3 pillar_1.9.0 gtable_0.3.5 glue_1.7.0
[49] xfun_0.43 tibble_3.2.1 tidyselect_1.2.1 knitr_1.46
[53] xtable_1.8-4 htmltools_0.5.8.1 rmarkdown_2.26 testthat_3.2.1.1
[57] compiler_4.4.0
.lock
file
Download the .lock
file and use renv::restore()
on it to recreate environment used to generate this website.
Code
parent_file_path <- knitr::current_input(dir = TRUE)
book_root_dir <- parent_file_path
while (!file.exists(file.path(book_root_dir, "_quarto.yml"))) book_root_dir <- dirname(book_root_dir)
lock_path <- file.path(
"../../assets/www/lock",
paste0(
gsub(
file.path(book_root_dir, ""),
"",
gsub(
"\\.rmarkdown$",
"",
knitr::current_input(dir = TRUE)
)
),
".lock"
)
)
withr::with_options(
list(renv.verbose = FALSE),
renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)
)