|
1 | 1 | skip_if(utils::packageVersion("insight") <= "1.1.0")
|
2 | 2 | skip_if(utils::packageVersion("parameters") <= "0.24.1")
|
3 | 3 |
|
| 4 | +test_that("estimate_grouplevel - errors", { |
| 5 | + m <- lm(mpg ~ gear, data = mtcars) |
| 6 | + expect_error(estimate_grouplevel(m), regex = "Model must be a mixed") |
| 7 | +}) |
| 8 | + |
4 | 9 | test_that("estimate_grouplevel - lme4", {
|
5 | 10 | skip_if_not_installed("lme4")
|
6 | 11 | set.seed(333)
|
@@ -83,7 +88,7 @@ test_that("estimate_grouplevel - glmmTMB", {
|
83 | 88 | expect_named(out, c("Group", "Level", "Parameter", "Coefficient"))
|
84 | 89 | })
|
85 | 90 |
|
86 |
| -test_that("estimate_grouplevel - Bayesian", { |
| 91 | +test_that("estimate_grouplevel - Bayesian, brms", { |
87 | 92 | skip_on_cran()
|
88 | 93 | skip_if_not_installed("curl")
|
89 | 94 | skip_if_offline()
|
@@ -112,3 +117,33 @@ test_that("estimate_grouplevel - Bayesian", {
|
112 | 117 | expect_identical(dim(out), c(12L, 9L))
|
113 | 118 | expect_named(out, c("Component", "Group", "Level", "Parameter", "Median", "MAD", "CI", "CI_low", "CI_high"))
|
114 | 119 | })
|
| 120 | + |
| 121 | +test_that("estimate_grouplevel - Bayesian, rstanarm", { |
| 122 | + skip_on_cran() |
| 123 | + skip_if_not_installed("curl") |
| 124 | + skip_if_offline() |
| 125 | + skip_if_not_installed("httr2") |
| 126 | + skip_if_not_installed("rstanarm") |
| 127 | + |
| 128 | + m <- insight::download_model("brms_mixed_10") |
| 129 | + skip_if(is.null(m)) |
| 130 | + |
| 131 | + out <- estimate_grouplevel(m) |
| 132 | + expect_identical(dim(out), c(6L, 8L)) |
| 133 | + expect_named(out, c("Group", "Level", "Parameter", "Median", "MAD", "CI", "CI_low", "CI_high")) |
| 134 | + |
| 135 | + out <- estimate_grouplevel(m, type = "total", dispersion = FALSE) |
| 136 | + expect_identical(dim(out), c(6L, 7L)) |
| 137 | + expect_named(out, c("Group", "Level", "Parameter", "Median", "CI", "CI_low", "CI_high")) |
| 138 | + |
| 139 | + m <- insight::download_model("brms_sigma_3") |
| 140 | + skip_if(is.null(m)) |
| 141 | + |
| 142 | + out <- estimate_grouplevel(m) |
| 143 | + expect_identical(dim(out), c(12L, 9L)) |
| 144 | + expect_named(out, c("Component", "Group", "Level", "Parameter", "Median", "MAD", "CI", "CI_low", "CI_high")) |
| 145 | + |
| 146 | + out <- estimate_grouplevel(m, type = "total") |
| 147 | + expect_identical(dim(out), c(12L, 9L)) |
| 148 | + expect_named(out, c("Component", "Group", "Level", "Parameter", "Median", "MAD", "CI", "CI_low", "CI_high")) |
| 149 | +}) |
0 commit comments