Skip to content

Commit 3252d15

Browse files
committed
add test
1 parent a21f0f5 commit 3252d15

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
skip_on_cran()
2+
skip_if_not_installed("glmmTMB")
3+
skip_if_not_installed("lme4")
4+
5+
test_that("group_level_total", {
6+
data("fish", package = "insight")
7+
8+
m1 <- suppressWarnings(glmmTMB::glmmTMB(
9+
count ~ child + camper + (1 | ID),
10+
data = fish,
11+
family = poisson()
12+
))
13+
14+
m2 <- suppressWarnings(glmmTMB::glmmTMB(
15+
count ~ child + camper + (1 + xb | persons) + (1 + zg | ID),
16+
ziformula = ~ child + livebait + (1 + zg + nofish | ID),
17+
dispformula = ~xb,
18+
data = fish,
19+
family = glmmTMB::truncated_poisson()
20+
))
21+
22+
m3 <- suppressWarnings(glmmTMB::glmmTMB(
23+
count ~ child + camper,
24+
ziformula = ~ child + livebait + (1 | ID),
25+
data = fish,
26+
family = glmmTMB::truncated_poisson()
27+
))
28+
29+
m4 <- suppressWarnings(glmmTMB::glmmTMB(
30+
count ~ child + camper + (1 + xb | persons),
31+
ziformula = ~ child + livebait,
32+
dispformula = ~xb,
33+
data = fish,
34+
family = glmmTMB::truncated_poisson()
35+
))
36+
37+
m5 <- suppressWarnings(lme4::glmer(
38+
count ~ child + camper + (1 | ID),
39+
data = fish,
40+
family = poisson()
41+
))
42+
43+
m6 <- suppressWarnings(lme4::lmer(
44+
Reaction ~ Days + (1 + Days | Subject),
45+
data = lme4::sleepstudy
46+
))
47+
48+
out <- model_parameters(m1, effects = "total")
49+
expect_identical(dim(out), c(4L, 6L))
50+
51+
out <- model_parameters(m2, effects = "total")
52+
expect_identical(dim(out), c(28L, 6L))
53+
54+
out <- model_parameters(m3, effects = "total")
55+
expect_identical(dim(out), c(4L, 6L))
56+
57+
out <- model_parameters(m4, effects = "total")
58+
expect_identical(dim(out), c(8L, 6L))
59+
60+
out <- model_parameters(m5, effects = "total")
61+
expect_identical(dim(out), c(4L, 5L))
62+
63+
out <- model_parameters(m6, effects = "total")
64+
expect_identical(dim(out), c(36L, 5L))
65+
})

0 commit comments

Comments
 (0)