| 1 |
skip_on_cran() |
| 2 |
|
| 3 |
skip_if_not_installed("modeltests") |
| 4 |
library(modeltests) |
| 5 |
|
| 6 |
skip_if_not_installed("quantreg") |
| 7 |
suppressPackageStartupMessages(library(quantreg)) |
| 8 |
|
| 9 |
set.seed(27) |
| 10 |
|
| 11 |
df <- tibble::tibble( |
| 12 |
x = rep(1:25, 20), |
| 13 |
y = SSlogis(x, 10, 12, 2) * rnorm(500, 1, 0.1) |
| 14 |
) |
| 15 |
|
| 16 |
fit <- nlrq( |
| 17 |
y ~ SSlogis(x, Asym, mid, scal), |
| 18 |
data = df, |
| 19 |
tau = 0.5, |
| 20 |
trace = FALSE |
| 21 |
) |
| 22 |
|
| 23 |
test_that("quantreg::nlrq tidier arguments", { |
| 24 |
check_arguments(tidy.nlrq) |
| 25 |
check_arguments(glance.nlrq) |
| 26 |
check_arguments(augment.nlrq) |
| 27 |
}) |
| 28 |
|
| 29 |
test_that("tidy.nlrq", { |
| 30 |
td <- tidy(fit) |
| 31 |
td_iid <- tidy(fit, se.type = "iid") |
| 32 |
tdci <- tidy(fit, conf.int = TRUE) |
| 33 |
|
| 34 |
check_tidy_output(td) |
| 35 |
check_tidy_output(td_iid) |
| 36 |
check_tidy_output(tdci) |
| 37 |
}) |
| 38 |
|
| 39 |
test_that("glance.nlrq", { |
| 40 |
gl <- glance(fit) |
| 41 |
check_glance_outputs(gl) |
| 42 |
}) |
| 43 |
|
| 44 |
test_that("augment.nlrq", { |
| 45 |
au <- augment(fit) |
| 46 |
check_tibble(au, method = "augment", strict = FALSE) |
| 47 |
|
| 48 |
check_augment_function( |
| 49 |
aug = augment.nlrq, |
| 50 |
model = fit, |
| 51 |
data = df, |
| 52 |
newdata = df |
| 53 |
) |
| 54 |
}) |