Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update rate01 test #174

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Suggests:
VignetteBuilder:
knitr
Remotes:
insightsengineering/tern@main,
pharmaverse/pharmaverseadam@main
biocViews:
Config/Needs/website: insightsengineering/nesttemplate
Expand Down
70 changes: 42 additions & 28 deletions tests/testthat/_snaps/table_ratet01.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,46 @@
Code
res
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
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) with offset
Rate 7.2364 8.2148 9.8131
Unadjusted exacerbation rate (per year)
Rate 2.7761 2.8433 2.9848
Adjusted (QP) exacerbation rate (per year) with offset
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 (QP) exacerbation rate (per year)
Rate 2.7380 2.8161 2.9771
Rate CI (2.3920, 3.1339) (2.4676, 3.2137) (2.6125, 3.3926)
Rate Ratio 1.0285 1.0873
Rate Ratio CI (0.8849, 1.1954) (0.9366, 1.2624)
p-value 0.7140 0.2714
Adjusted (NB) exacerbation rate (per year) with offset
Rate 18.4450 28.0582 23.9304
Rate CI (13.9015, 24.4736) (21.3288, 36.9108) (18.1382, 31.5722)
Rate Ratio 1.5212 1.2974
Rate Ratio CI (1.1166, 2.0724) (0.9505, 1.7708)
p-value 0.0078 0.1009
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

39 changes: 39 additions & 0 deletions tests/testthat/test-table_ratet01.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ testthat::test_that("RATET01 is produced correctly", {
conf_level = 0.95,
distribution = "poisson",
rate_mean_method = "emmeans",
var_labels = "Unadjusted exacerbation rate (per year) with offset",
table_names = "unadj-offest",
.stats = c("rate"),
.labels = c(rate = "Rate")
) %>%
summarize_glm_count(
vars = "AVAL",
variables = list(arm = "ARM", 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"),
Expand All @@ -34,6 +45,20 @@ testthat::test_that("RATET01 is produced correctly", {
conf_level = 0.95,
distribution = "quasipoisson",
rate_mean_method = "ppmeans",
var_labels = "Adjusted (QP) exacerbation rate (per year) with offset",
table_names = "adj-qp-offest",
.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", covariates = c("REGION1")),
conf_level = 0.95,
distribution = "quasipoisson",
rate_mean_method = "emmeans",
var_labels = "Adjusted (QP) exacerbation rate (per year)",
table_names = "adj-qp",
.stats = c("rate", "rate_ci", "rate_ratio", "rate_ratio_ci", "pval"),
Expand All @@ -48,6 +73,20 @@ testthat::test_that("RATET01 is produced correctly", {
conf_level = 0.95,
distribution = "negbin",
rate_mean_method = "emmeans",
var_labels = "Adjusted (NB) exacerbation rate (per year) with offset",
table_names = "adj-nb-offest",
.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", 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"),
Expand Down
Loading