Skip to content

Commit

Permalink
reinstate ratet01 (#223)
Browse files Browse the repository at this point in the history
closes #221

---------

Co-authored-by: Emily de la Rua <[email protected]>
  • Loading branch information
ayogasekaram and edelarua authored Feb 27, 2024
1 parent 8f19657 commit aea2699
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 3 deletions.
58 changes: 57 additions & 1 deletion book/tables/efficacy/ratet01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ subtitle: Event Rate Summary for Recurrent Events

------------------------------------------------------------------------

{{< include ../../test-utils/envir_hook.qmd >}}

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.

Expand All @@ -29,9 +31,63 @@ anl <- df_explicit_na(anl)
## Customized Table

```{r variant1, test = list(result_v1 = "result")}
# Under development
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%)"),
.label = 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
```

{{< include ../../test-utils/save_results.qmd >}}

## `teal` App

```{r teal, opts.label=c('skip_if_testing', 'app')}
Expand Down
4 changes: 2 additions & 2 deletions package/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ Suggests:
stringr,
svglite (>= 2.1.2),
teal (>= 0.14.0),
teal.modules.clinical (>= 0.8.16),
teal.modules.clinical (>= 0.9.0),
teal.modules.general (>= 0.2.16),
teal.transform (>= 0.5.0),
tern (>= 0.9.3),
tern (>= 0.9.3.9019),
tern.mmrm (>= 0.3.0),
tern.rbmi,
testthat (>= 3.0.0),
Expand Down
34 changes: 34 additions & 0 deletions package/tests/testthat/_snaps/ratet01/markdown-snaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# result_v1

Code
print(data_snap[[i]])
Output
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

0 comments on commit aea2699

Please sign in to comment.