Skip to content

Commit

Permalink
Update test_metapred_3.R
Browse files Browse the repository at this point in the history
Added tests for multiple generalizability and performance functions in metapred. This should prevent the fixed bug from reoccuring.
  • Loading branch information
VMTdeJong committed Feb 15, 2024
1 parent 6692479 commit 386bc6f
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/testthat/test_metapred_3.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ test_that("metapred can handle different perfFUN", {
expect_is(mp <- metamisc:::metapred(td, strata = "X4", scope = f, formula = f, family = binomial, perfFUN = "auc"
, selFUN = "which.max", meta.method = "FE")
, "metapred")

expect_is(mp <- metamisc:::metapred(td, strata = "X4", scope = f, formula = f, family = binomial,
perfFUN = list("mse", "auc"),
selFUN = "which.max", meta.method = "FE")
, "metapred")

})

test_that("metapred can handle multiple genFUN.", {
Expand All @@ -79,6 +85,56 @@ test_that("metapred can handle multiple genFUN.", {
# , "metapred")
})

test_that("metapred can handle multiple genFUN and perfFUN.", {
genFUN <- list(abs.mean = "abs.mean", coef.var.mean = "coef.var.mean")
perfFUN = list("mse", "auc")

expect_is(mp <- metamisc:::metapred(data = td,
strata = "X4",
scope = f,
formula = f,
family = binomial,
genFUN = genFUN,
perfFUN = perfFUN,
meta.method = "FE",
gen.of.perf = "first") # default
, "metapred")

expect_s3_class(perf(mp), "data.frame")
expect_type(mp$FUN$perfFUN[[2]], "closure")
expect_length(gen(mp, 0), 2)

expect_is(mp <- metamisc:::metapred(data = td,
strata = "X4",
scope = f,
formula = f,
family = binomial,
genFUN = genFUN,
perfFUN = perfFUN,
meta.method = "FE",
gen.of.perf = "factorial")
, "metapred")

expect_s3_class(perf(mp), "data.frame")
expect_type(mp$FUN$perfFUN[[2]], "closure")
expect_length(gen(mp, 0), 4)

expect_is(mp <- metamisc:::metapred(data = td,
strata = "X4",
scope = f,
formula = f,
family = binomial,
genFUN = genFUN,
perfFUN = perfFUN,
meta.method = "FE",
gen.of.perf = "respective")
, "metapred")
expect_length(gen(mp, 0), 2)

expect_s3_class(perf(mp), "data.frame")
expect_type(mp$FUN$perfFUN[[2]], "closure")
})

test_that("metapred can handle different distributions.", {
expect_true(is.list(mp <- metapred(data = td, strata = "X4", family = binomial, max.steps = 0,
meta.method = "FE") )) # binomial
Expand Down

0 comments on commit 386bc6f

Please sign in to comment.