diff --git a/tests/testthat/test-check_distribution.R b/tests/testthat/test-check_distribution.R new file mode 100644 index 000000000..9226e6102 --- /dev/null +++ b/tests/testthat/test-check_distribution.R @@ -0,0 +1,34 @@ +test_that("check_distribution", { + skip_if_not_installed("lme4") + skip_if_not_installed("randomForest") + data(sleepstudy, package = "lme4") + model <<- lme4::lmer(Reaction ~ Days + (Days | Subject), sleepstudy) + out <- check_distribution(model) + + expect_identical( + out$Distribution, + c( + "bernoulli", "beta", "beta-binomial", "binomial", "cauchy", + "chi", "exponential", "F", "gamma", "half-cauchy", "inverse-gamma", + "lognormal", "neg. binomial (zero-infl.)", "negative binomial", + "normal", "pareto", "poisson", "poisson (zero-infl.)", "tweedie", + "uniform", "weibull" + ) + ) + expect_equal( + out$p_Residuals, + c( + 0, 0, 0, 0, 0.9375, 0, 0, 0, 0, 0, 0, 0.03125, 0, 0, 0, 0, + 0, 0, 0, 0, 0.03125 + ), + tolerance = 1e-4 + ) + expect_equal( + out$p_Response, + c( + 0, 0, 0.03125, 0, 0, 0, 0, 0, 0.4375, 0.03125, 0, 0.46875, + 0.03125, 0, 0, 0, 0, 0, 0, 0, 0 + ), + tolerance = 1e-4 + ) +})