Skip to content

Commit

Permalink
Revert c1d4e8 - run tests calling Stan on CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
dmphillippo committed Feb 27, 2024
1 parent 4c8cb42 commit 59e5e14
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 67 deletions.
73 changes: 34 additions & 39 deletions tests/testthat/test-nma.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,40 @@ test_that("nma() error if missing values in outcomes or predictors", {
regression = ~x1, center = TRUE)), m)
})

smknet_3l <- combine_network(
set_agd_arm(smkdummy %>% mutate(extra = 0.5, tclass = if_else(trtn == 1, 0, 1)),
studyn, trtn, r = r, n = n, trt_class = tclass),
set_ipd(ipddummy %>% mutate(extra = TRUE, tclass = if_else(trtn == 1, 0, 1)),
studyn, trtn, r = r, trt_class = tclass),
trt_ref = 1) %>%
add_integration(x1 = distr(qnorm, x1_mean, x1_sd),
x2 = distr(qbinom, 1, x2),
x3 = distr(qnorm, x3_mean, x3_sd))

smknet_3c <- combine_network(
set_agd_arm(smkdummy %>% mutate(extra = 0.5, tclass = if_else(trtn == 1, 0, 1)),
studyn, trtn, r = r, n = n, trt_class = tclass),
set_ipd(ipddummy %>% mutate(extra = "a", tclass = if_else(trtn == 1, 0, 1)),
studyn, trtn, r = r, trt_class = tclass),
trt_ref = 1) %>%
add_integration(x1 = distr(qnorm, x1_mean, x1_sd),
x2 = distr(qbinom, 1, x2),
x3 = distr(qnorm, x3_mean, x3_sd))

test_that("nma() silently drops unnecessary columns", {
expect_error(nma(smknet_3l, regression = ~(x1 + x2 + x3):.trt,
prior_intercept = normal(0, 10),
prior_trt = normal(0, 10),
prior_reg = normal(0, 5),
test_grad = TRUE), NA)

expect_error(nma(smknet_3c, regression = ~(x1 + x2 + x3):.trt,
prior_intercept = normal(0, 10),
prior_trt = normal(0, 10),
prior_reg = normal(0, 5),
test_grad = TRUE), NA)
})

test_that("nma.fit() error if only one of x or y provided", {
x <- matrix(1, nrow = 3, ncol = 3)
colnames(x) <- c("a", "b", "c")
Expand Down Expand Up @@ -252,45 +286,6 @@ test_that("nma.fit() error if agd_contrast_Sigma is not right dimensions", {
})


# avoid running Stan models on CRAN
skip_on_cran()


smknet_3l <- combine_network(
set_agd_arm(smkdummy %>% mutate(extra = 0.5, tclass = if_else(trtn == 1, 0, 1)),
studyn, trtn, r = r, n = n, trt_class = tclass),
set_ipd(ipddummy %>% mutate(extra = TRUE, tclass = if_else(trtn == 1, 0, 1)),
studyn, trtn, r = r, trt_class = tclass),
trt_ref = 1) %>%
add_integration(x1 = distr(qnorm, x1_mean, x1_sd),
x2 = distr(qbinom, 1, x2),
x3 = distr(qnorm, x3_mean, x3_sd))

smknet_3c <- combine_network(
set_agd_arm(smkdummy %>% mutate(extra = 0.5, tclass = if_else(trtn == 1, 0, 1)),
studyn, trtn, r = r, n = n, trt_class = tclass),
set_ipd(ipddummy %>% mutate(extra = "a", tclass = if_else(trtn == 1, 0, 1)),
studyn, trtn, r = r, trt_class = tclass),
trt_ref = 1) %>%
add_integration(x1 = distr(qnorm, x1_mean, x1_sd),
x2 = distr(qbinom, 1, x2),
x3 = distr(qnorm, x3_mean, x3_sd))

test_that("nma() silently drops unnecessary columns", {
expect_error(nma(smknet_3l, regression = ~(x1 + x2 + x3):.trt,
prior_intercept = normal(0, 10),
prior_trt = normal(0, 10),
prior_reg = normal(0, 5),
test_grad = TRUE), NA)

expect_error(nma(smknet_3c, regression = ~(x1 + x2 + x3):.trt,
prior_intercept = normal(0, 10),
prior_trt = normal(0, 10),
prior_reg = normal(0, 5),
test_grad = TRUE), NA)
})


single_study_a <- tibble(study = "A", trt = c("a", "b"), r = 500, n = 1000)
net_ss_a <- set_agd_arm(single_study_a, study, trt, r = r, n = n)

Expand Down
28 changes: 12 additions & 16 deletions tests/testthat/test-nodesplit.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ test_that("nma() nodesplit error if no comparisons to split", {
)
})

test_that("nma() nodesplit warning about ignoring comparisons", {
expect_warning(
nma(thrombo_net,
consistency = "nodesplit",
nodesplit = data.frame(trt1 = "Acc t-PA", trt2 = c("TNK", "ASPAC")),
prior_intercept = normal(scale = 10),
prior_trt = normal(scale = 10),
test_grad = TRUE),
"Ignoring node-split comparisons.+Acc t-PA vs\\. TNK"
)
})

test_that("nma() nodesplit argument validation", {
m1 <- "The data frame passed to `nodesplit` should have two columns"

Expand Down Expand Up @@ -221,22 +233,6 @@ test_that("nma() nodesplit argument validation", {
)
})


# avoid running Stan models on CRAN
skip_on_cran()

test_that("nma() nodesplit warning about ignoring comparisons", {
expect_warning(
nma(thrombo_net,
consistency = "nodesplit",
nodesplit = data.frame(trt1 = "Acc t-PA", trt2 = c("TNK", "ASPAC")),
prior_intercept = normal(scale = 10),
prior_trt = normal(scale = 10),
test_grad = TRUE),
"Ignoring node-split comparisons.+Acc t-PA vs\\. TNK"
)
})

thrombo_ns1 <- nma(thrombo_net,
consistency = "nodesplit",
nodesplit = c("SK", "t-PA"),
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test-plot_integration_error.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

# avoid running Stan models on CRAN
skip_on_cran()

smk_net <- set_agd_arm(smoking,
study = studyn,
trt = trtc,
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test-posterior_ranks.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

# avoid running Stan models on CRAN
skip_on_cran()

smk_net <- set_agd_arm(smoking,
study = studyn,
trt = trtc,
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test-predict.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

# avoid running Stan models on CRAN
skip_on_cran()

smk_net <- set_agd_arm(smoking,
study = studyn,
trt = trtc,
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test-relative_effects.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

# avoid running Stan models on CRAN
skip_on_cran()

smk_net <- set_agd_arm(smoking,
study = studyn,
trt = trtc,
Expand Down

0 comments on commit 59e5e14

Please sign in to comment.