| 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 |
fit <- speedlm(mpg ~ wt, mtcars, fitted = TRUE) |
| 10 |
fit2 <- speedlm(mpg ~ wt + disp, mtcars, fitted = TRUE) |
| 11 |
fit3 <- speedlm(mpg ~ wt, mtcars) |
| 12 |
|
| 13 |
test_that("speedlm tidiers arguments", { |
| 14 |
check_arguments(tidy.speedlm) |
| 15 |
check_arguments(glance.speedlm) |
| 16 |
check_arguments(augment.speedlm) |
| 17 |
}) |
| 18 |
|
| 19 |
test_that("tidy.speedlm", { |
| 20 |
td <- tidy(fit) |
| 21 |
td2 <- tidy(fit2) |
| 22 |
|
| 23 |
check_tidy_output(td) |
| 24 |
check_tidy_output(td2) |
| 25 |
|
| 26 |
check_dims(td, 2) |
| 27 |
check_dims(td2, 3) |
| 28 |
|
| 29 |
expect_equal(td$term, c("(Intercept)", "wt")) |
| 30 |
expect_equal(td2$term, c("(Intercept)", "wt", "disp")) |
| 31 |
}) |
| 32 |
|
| 33 |
test_that("glance.speedlm", { |
| 34 |
gl <- glance(fit) |
| 35 |
check_glance_outputs(gl) |
| 36 |
}) |
| 37 |
|
| 38 |
test_that("augment.speedlm", { |
| 39 |
check_augment_function( |
| 40 |
aug = augment.speedlm, |
| 41 |
model = fit, |
| 42 |
data = mtcars, |
| 43 |
newdata = mtcars |
| 44 |
) |
| 45 |
|
| 46 |
check_augment_function( |
| 47 |
aug = augment.speedlm, |
| 48 |
model = fit2, |
| 49 |
data = mtcars, |
| 50 |
newdata = mtcars |
| 51 |
) |
| 52 |
|
| 53 |
expect_snapshot(error = TRUE, augment(fit3)) |
| 54 |
}) |