Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates for glmmTMB changes #861

Merged
merged 5 commits into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,7 +1,7 @@
Type: Package
Package: insight
Title: Easy Access to Model Information for Various Model Objects
Version: 0.19.9.1
Version: 0.19.9.2
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Expand Up @@ -5,6 +5,8 @@
* Function like `find_variables()` or `clean_names()` now support multi-membership
formulas for models from *brms*.

* Updated tests to work with the latest changes in *glmmTMBM 1.1.9*.

# insight 0.19.9

## New supported models
Expand Down
9 changes: 5 additions & 4 deletions tests/testthat/test-get_variance.R
Expand Up @@ -3,12 +3,12 @@ skip_if_not_installed("lme4")
data(sleepstudy, package = "lme4")
data("Penicillin", package = "lme4")
set.seed(12345)
sleepstudy$grp <- sample(1:5, size = 180, replace = TRUE)
sleepstudy$grp <- sample.int(5, size = 180, replace = TRUE)
sleepstudy$subgrp <- NA
for (i in 1:5) {
filter_group <- sleepstudy$grp == i
sleepstudy$subgrp[filter_group] <-
sample(1:30, size = sum(filter_group), replace = TRUE)
sample.int(30, size = sum(filter_group), replace = TRUE)
}

study_data <<- sleepstudy
Expand Down Expand Up @@ -286,7 +286,7 @@ test_that("get_variance-cat_random_slope", {

data(sleepstudy, package = "lme4")
set.seed(123)
sleepstudy$Months <- sample(1:4, nrow(sleepstudy), TRUE)
sleepstudy$Months <- sample.int(4, nrow(sleepstudy), TRUE)
study_data3 <<- sleepstudy

m2 <- lme4::lmer(Reaction ~ Days + (0 + Days | Subject), data = study_data3)
Expand Down Expand Up @@ -364,9 +364,10 @@ test_that("fixed effects variance for rank-deficient models, #765", {
mod_TMB <- glmmTMB::glmmTMB(
z ~ x1 + x2 + x3 + x4 + (1 | re),
data = dd,
start = list(theta = 3),
control = glmmTMB::glmmTMBControl(rank_check = "adjust")
)
})
out <- get_variance_fixed(mod_TMB)
expect_equal(out, 627.03661, tolerance = 1e-4, ignore_attr = TRUE)
expect_equal(out, 627.04511567, tolerance = 1e-4, ignore_attr = TRUE)
})
10 changes: 6 additions & 4 deletions tests/testthat/test-glmmTMB.R
Expand Up @@ -617,7 +617,7 @@
expect_null(get_data(m4, component = "disp", effects = "random", verbose = FALSE))
})

test_that("find_paramaters", {
test_that("find_parameters", {
expect_identical(
find_parameters(m4),
list(
Expand Down Expand Up @@ -685,7 +685,7 @@
})


test_that("get_paramaters", {
test_that("get_parameters", {
expect_identical(nrow(get_parameters(m4)), 6L)
expect_identical(
colnames(get_parameters(m4)),
Expand Down Expand Up @@ -773,7 +773,7 @@
# expect_warning(expect_equal(get_variance_fixed(m1), c(var.fixed = 1.09712435712435052437), tolerance = 1e-3))
# expect_warning(expect_equal(get_variance_random(m1), c(var.random = 0.86712737445492238386), tolerance = 1e-3))
# expect_warning(expect_equal(get_variance_residual(m1), c(var.residual = 0.02634500773355940087 ), tolerance = 1e-3))
# expect_warning(expect_equal(get_variance_distribution(m1), c(var.distribution = 0.02634500773355940087 ), tolerance = 1e-3))

Check warning on line 776 in tests/testthat/test-glmmTMB.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-glmmTMB.R,line=776,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 128 characters.
# expect_warning(expect_equal(get_variance_dispersion(m1), c(var.dispersion = 0), tolerance = 1e-3))
# })

Expand Down Expand Up @@ -880,7 +880,9 @@
dat <- rbind(d1, d2)
m0 <- glmmTMB::glmmTMB(x ~ sd + (1 | t), dispformula = ~sd, data = dat)

test_that("get_paramaters", {

test_that("get_parameters", {
skip_if_not_installed("glmmTMB", minimum_version = "1.1.9")
expect_identical(nrow(get_parameters(m0)), 4L)
expect_identical(
colnames(get_parameters(m0)),
Expand All @@ -897,7 +899,7 @@
)
expect_equal(
get_parameters(m0)$Estimate,
c(200.03431, -99.71491, 3.20287, 1.38648),
c(200.03431, -99.71491, 1.6014, 0.69323),
tolerance = 1e-3
)
expect_identical(
Expand Down