Debian Codegraph @

tests/testthat/test-speedglm-speedglm.R

raw
1 skip_on_cran()
2
3 skip_if_not_installed("modeltests")
4 library(modeltests)
5
6 skip_if_not_installed("speedglm")
7 suppressPackageStartupMessages(library(speedglm))
8
9 clotting <- data.frame(
10 u = c(5, 10, 15, 20, 30, 40, 60, 80, 100),
11 lot1 = c(118, 58, 42, 35, 27, 25, 21, 19, 18)
12 )
13
14 fit <- speedglm(lot1 ~ log(u), data = clotting, family = Gamma(log))
15
16 test_that("speedglm tidiers arguments", {
17 check_arguments(tidy.speedglm)
18 check_arguments(glance.speedglm)
19 })
20
21 test_that("tidy.speedglm", {
22 td <- tidy(fit, conf.int = TRUE, exponentiate = TRUE)
23 check_tidy_output(td)
24
25 # watch out for the bizarro factor p-values reported in #660
26 expect_type(td$p.value, "double")
27
28 check_dims(td, 2, 7)
29 })
30
31 test_that("glance.speedglm", {
32 gl <- glance(fit)
33 check_glance_outputs(gl)
34 })
35
36 test_that("augment.speedglm errors", {
37 # speedglm sub-classes speedlm, and there's an augment.speedlm()
38 # method we want to make sure isn't accidentally invoked
39 expect_snapshot(error = TRUE, augment(fit))
40 })