From c36d0d375f7c467fe4f749a6d3cdcd603f55a585 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 4 Oct 2023 12:28:44 +0200 Subject: [PATCH] add test --- tests/testthat/test-binned_residuals.R | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/testthat/test-binned_residuals.R diff --git a/tests/testthat/test-binned_residuals.R b/tests/testthat/test-binned_residuals.R new file mode 100644 index 000000000..972f030af --- /dev/null +++ b/tests/testthat/test-binned_residuals.R @@ -0,0 +1,19 @@ +test_that("binned_residuals", { + data(mtcars) + model <- glm(vs ~ wt + mpg, data = mtcars, family = "binomial") + result <- binned_residuals(model) + expect_named( + result, + c("xbar", "ybar", "n", "x.lo", "x.hi", "se", "ci_range", "CI_low", "CI_high", "group") + ) + expect_equal( + result$xbar, + c(0.03786, 0.09514, 0.25911, 0.47955, 0.71109, 0.97119), + tolerance = 1e-4 + ) + expect_equal( + result$ybar, + c(-0.03786, -0.09514, 0.07423, -0.07955, 0.28891, -0.13786), + tolerance = 1e-4 + ) +})