Skip to content

Commit

Permalink
Update DESCRIPTION (#1321)
Browse files Browse the repository at this point in the history
use survival 3.6-4

# Pull Request

<!--- Replace `#nnn` with your issue link for reference. -->

Fixes #nnn

Signed-off-by: Joe Zhu <[email protected]>
  • Loading branch information
shajoezhu authored Oct 8, 2024
1 parent 45e2a4b commit f5616ea
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 32 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Imports:
rlang (>= 1.1.0),
scales (>= 1.2.0),
stats,
survival (>= 3.7-0),
survival (>= 3.6-4),
tibble (>= 2.0.0),
tidyr (>= 0.8.3),
utils
Expand Down
90 changes: 59 additions & 31 deletions tests/testthat/test-odds_ratio.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ testthat::test_that("or_clogit estimates right OR and CI", {
stringsAsFactors = TRUE
)

result <- or_clogit(data, conf_level = 0.95)
# https://github.com/therneau/survival/issues/240
withr::with_options(
opts_partial_match_old,
result <- or_clogit(data, conf_level = 0.95)
)

# from SAS
res <- testthat::expect_silent(result)
Expand Down Expand Up @@ -62,13 +66,17 @@ testthat::test_that("s_odds_ratio estimates right OR and CI (stratified analysis
strata = factor(sample(c("C", "D"), 100, TRUE))
)

result <- s_odds_ratio(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta,
variables = list(arm = "grp", strata = "strata")
# https://github.com/therneau/survival/issues/240
withr::with_options(
opts_partial_match_old,
result <- s_odds_ratio(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta,
variables = list(arm = "grp", strata = "strata")
)
)

res <- testthat::expect_silent(result)
Expand All @@ -86,15 +94,19 @@ testthat::test_that("s_odds_ratio returns error for incorrect groups", {
"Arms A+B" = c("A", "B")
)

testthat::expect_error(result <- s_odds_ratio(
df = subset(data, grp == "A"),
.var = "rsp",
.ref_group = subset(data, grp == "B"),
.in_ref_col = FALSE,
.df_row = data,
variables = list(arm = "grp", strata = "strata"),
groups_list = groups
))
# https://github.com/therneau/survival/issues/240
withr::with_options(
opts_partial_match_old,
result <- testthat::expect_error(s_odds_ratio(
df = subset(data, grp == "A"),
.var = "rsp",
.ref_group = subset(data, grp == "B"),
.in_ref_col = FALSE,
.df_row = data,
variables = list(arm = "grp", strata = "strata"),
groups_list = groups
))
)
})

testthat::test_that("estimate_odds_ratio estimates right OR and CI (unstratified analysis)", {
Expand All @@ -120,10 +132,14 @@ testthat::test_that("estimate_odds_ratio estimates right OR and CI (stratified a
strata = factor(sample(c("C", "D"), 100, TRUE))
)

result <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "A", split_fun = ref_group_position("first")) %>%
estimate_odds_ratio(vars = "rsp", variables = list(arm = "grp", strata = "strata")) %>%
build_table(df = data)
# https://github.com/therneau/survival/issues/240
withr::with_options(
opts_partial_match_old,
result <- basic_table() %>%
split_cols_by(var = "grp", ref_group = "A", split_fun = ref_group_position("first")) %>%
estimate_odds_ratio(vars = "rsp", variables = list(arm = "grp", strata = "strata")) %>%
build_table(df = data)
)

res <- testthat::expect_silent(result)
testthat::expect_snapshot(res)
Expand Down Expand Up @@ -154,7 +170,11 @@ testthat::test_that("estimate_odds_ratio works with strata and combined groups",
groups_list = groups
)

result <- build_table(lyt = lyt, df = anl)
# https://github.com/therneau/survival/issues/240
withr::with_options(
opts_partial_match_old,
result <- build_table(lyt = lyt, df = anl)
)

res <- testthat::expect_silent(result)
testthat::expect_snapshot(res)
Expand All @@ -172,14 +192,18 @@ testthat::test_that("s_odds_ratio method argument works", {
stringsAsFactors = TRUE
)

res <- s_odds_ratio(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta,
variables = list(arm = "grp", strata = "strata"),
method = "approximate"
# https://github.com/therneau/survival/issues/240
withr::with_options(
opts_partial_match_old,
res <- s_odds_ratio(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta,
variables = list(arm = "grp", strata = "strata"),
method = "approximate"
)
)

testthat::expect_false(all(is.na(res$or_ci)))
Expand Down Expand Up @@ -213,7 +237,11 @@ testthat::test_that("estimate_odds_ratio method argument works", {
split_cols_by(var = "grp", ref_group = "B") %>%
estimate_odds_ratio(vars = "rsp", variables = list(arm = "grp", strata = "strata"), method = "approximate")

result <- build_table(lyt, df = dta)
# https://github.com/therneau/survival/issues/240
withr::with_options(
opts_partial_match_old,
result <- build_table(lyt, df = dta)
)

res <- testthat::expect_silent(result)
testthat::expect_snapshot(res)
Expand Down

0 comments on commit f5616ea

Please sign in to comment.