Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 20, 2023
1 parent cffd93a commit d993e1d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
37 changes: 37 additions & 0 deletions tests/testthat/test-survey.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
skip_if_not_installed("withr")

withr::with_environment(
new.env(),
test_that("model_parameters svytable", {
skip_if_not_installed("survey")
# svychisq is called in model_parameters
svychisq <- survey::svychisq

data(api, package = "survey")
dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc)
m <- survey::svytable(~ sch.wide + stype, dclus1)
mp <- model_parameters(m)
expect_named(mp, c("F", "df", "df_error", "p", "Method"))
expect_equal(mp$p, 0.02174746, tolerance = 1e-3)
})
)

withr::with_environment(
new.env(),
test_that("model_parameters, bootstrap svyglm", {
data(api, package = "survey")
dstrat <- survey::svydesign(
id = ~1,
strata = ~stype,
weights = ~pw,
data = apistrat,
fpc = ~fpc
)

model_svyglm <- suppressWarnings(survey::svyglm(sch.wide ~ ell + meals + mobility,
design = dstrat,
family = binomial(link = "logit")
))
expect_message(parameters(model_svyglm, bootstrap = TRUE), regex = "arguments are not supported")
})
)
12 changes: 0 additions & 12 deletions tests/testthat/test-svytable.R

This file was deleted.

0 comments on commit d993e1d

Please sign in to comment.