| 1 |
skip_on_cran() |
| 2 |
|
| 3 |
skip_if_not_installed("modeltests") |
| 4 |
library(modeltests) |
| 5 |
|
| 6 |
skip_if_not_installed("robust") |
| 7 |
suppressPackageStartupMessages(library(robust)) |
| 8 |
|
| 9 |
fit <- lmRob(mpg ~ wt, data = mtcars) |
| 10 |
fit2 <- glmRob(am ~ wt, data = mtcars, family = "binomial") |
| 11 |
|
| 12 |
test_that("robust tidier arguments", { |
| 13 |
check_arguments(tidy.lmRob) |
| 14 |
check_arguments(glance.lmRob) |
| 15 |
check_arguments(augment.lmRob) |
| 16 |
|
| 17 |
check_arguments(tidy.glmRob) |
| 18 |
check_arguments(glance.glmRob) |
| 19 |
}) |
| 20 |
|
| 21 |
test_that("tidy.lmRob", { |
| 22 |
td <- tidy(fit) |
| 23 |
td2 <- tidy(fit, conf.int = TRUE) |
| 24 |
|
| 25 |
check_tidy_output(td) |
| 26 |
check_tidy_output(td2) |
| 27 |
}) |
| 28 |
|
| 29 |
test_that("glance.lmRob", { |
| 30 |
gl <- glance(fit) |
| 31 |
check_glance_outputs(gl) |
| 32 |
}) |
| 33 |
|
| 34 |
test_that("augment.lmRob", { |
| 35 |
check_augment_function( |
| 36 |
aug = augment.lmRob, |
| 37 |
model = fit, |
| 38 |
data = mtcars, |
| 39 |
newdata = mtcars |
| 40 |
) |
| 41 |
}) |
| 42 |
|
| 43 |
test_that("tidy.glmRob", { |
| 44 |
td <- tidy(fit2) |
| 45 |
td2 <- tidy(fit2) |
| 46 |
|
| 47 |
check_tidy_output(td) |
| 48 |
check_tidy_output(td2) |
| 49 |
}) |
| 50 |
|
| 51 |
test_that("glance.glmRob", { |
| 52 |
gl <- glance(fit2) |
| 53 |
check_glance_outputs(gl) |
| 54 |
}) |
| 55 |
|
| 56 |
test_that("no more rlang issues with model objects from robust", { |
| 57 |
# from issue 720 |
| 58 |
|
| 59 |
expect_equal( |
| 60 |
tidy(fit, conf.int = TRUE), |
| 61 |
tidy(fit) |
| 62 |
) |
| 63 |
|
| 64 |
expect_equal( |
| 65 |
tidy(fit, exponentiate = TRUE), |
| 66 |
tidy(fit) |
| 67 |
) |
| 68 |
|
| 69 |
expect_equal( |
| 70 |
tidy(fit2, conf.int = TRUE), |
| 71 |
tidy(fit2) |
| 72 |
) |
| 73 |
|
| 74 |
expect_equal( |
| 75 |
tidy(fit2, exponentiate = TRUE), |
| 76 |
tidy(fit2) |
| 77 |
) |
| 78 |
}) |