From 62b86f7aaa7c67e7173d6360e9b471e833a52296 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 3 Dec 2023 14:06:47 +0100 Subject: [PATCH] fix ordbeta get_variance --- DESCRIPTION | 2 +- NEWS.md | 2 ++ R/compute_variances.R | 2 +- tests/testthat/test-glmmTMB.R | 3 +++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2dd608d56..095e0b927 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: insight Title: Easy Access to Model Information for Various Model Objects -Version: 0.19.7.2 +Version: 0.19.7.3 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index 7f2b10c9a..da50365ea 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,8 @@ * Fixed issue in `find_formula()` for models of class `glmmPQL` (package *MASS*). +* Fixed issue in `get_variance()` for *glmmTMB* models with `family = "ordbeta"`. + # insight 0.19.7 ## General diff --git a/R/compute_variances.R b/R/compute_variances.R index fa691975b..0de7360d2 100644 --- a/R/compute_variances.R +++ b/R/compute_variances.R @@ -634,7 +634,7 @@ # transform mu mu <- switch(faminfo$family, beta = mu, - ordbeta = stats::qlogis(mu), + ordbeta = stats::plogis(mu), exp(mu) ) } diff --git a/tests/testthat/test-glmmTMB.R b/tests/testthat/test-glmmTMB.R index b1a1125e3..32b35f343 100644 --- a/tests/testthat/test-glmmTMB.R +++ b/tests/testthat/test-glmmTMB.R @@ -969,6 +969,9 @@ test_that("model_info, ordered beta", { out <- model_info(m) expect_true(out$is_orderedbeta) expect_identical(out$family, "ordbeta") + skip_on_cran() + out <- get_variance(m) + expect_equal(out$var.distribution, 1.44250604187634, tolerance = 1e-4) })