Skip to content

Commit

Permalink
updates for glmmTMB changes (#861)
Browse files Browse the repository at this point in the history
* updates for glmmTMB changes

* skip test for glmmTMB < 1.1.9

* lintr, accuracy of result

* styler

* news, desc

---------

Co-authored-by: Daniel <mail@danielluedecke.de>
  • Loading branch information
bbolker and strengejacke committed Mar 20, 2024
1 parent ad16942 commit 56655d3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ test_that("get_data", {
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("find_paramaters", {
})


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 @@ -880,7 +880,9 @@ d2$sd <- "five"
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 @@ test_that("get_paramaters", {
)
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

0 comments on commit 56655d3

Please sign in to comment.