Skip to content

Commit eff54e5

Browse files
authored
parameters() fails on binomial mgcv::gam (#1052)
* parameters() fails on binomial mgcv::gam Fixes #1051 * news. desc * fix * update snapshots * include performance remotes * styler
1 parent ac2eb02 commit eff54e5

File tree

6 files changed

+49
-4
lines changed

6 files changed

+49
-4
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: parameters
33
Title: Processing of Model Parameters
4-
Version: 0.24.0.2
4+
Version: 0.24.0.3
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",
@@ -224,4 +224,4 @@ Config/testthat/edition: 3
224224
Config/testthat/parallel: true
225225
Config/Needs/website: easystats/easystatstemplate
226226
Config/rcmdcheck/ignore-inconsequential-notes: true
227-
Remotes: easystats/datawizard
227+
Remotes: easystats/datawizard, easystats/performance

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# parameters 0.24.1
2+
3+
## Bug fixes
4+
5+
* Fixed issue when printing `model_parameters()` with models from `mgcv::gam()`.
6+
7+
* Fixed issues due to breaking changes in the latest release of the *datawizard*
8+
package.
9+
110
# parameters 0.24.0
211

312
## Breaking Changes

R/dominance_analysis.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ dominance_analysis <- function(model, sets = NULL, all = NULL,
571571
}
572572

573573
da_df_res <- datawizard::data_rename(
574-
da_df_res,
574+
da_df_res,
575575
replacement = c(
576576
"Parameter", "General_Dominance",
577577
"Percent", "Ranks", "Subset"

R/format.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,9 +887,14 @@ format.parameters_sem <- function(x,
887887
logit_model <- isTRUE(.additional_arguments(x, "logit_link", FALSE)) ||
888888
isTRUE(attributes(x)$coefficient_name %in% c("Log-Odds", "Odds Ratio"))
889889

890+
# remove NA and infinite values from spurios coefficients
891+
if (!is.null(spurious_coefficients)) {
892+
spurious_coefficients <- spurious_coefficients[!is.na(spurious_coefficients) & !is.infinite(spurious_coefficients)] # nolint
893+
}
894+
890895
# check for complete separation coefficients or possible issues with
891896
# too few data points
892-
if (!is.null(spurious_coefficients) && logit_model) {
897+
if (!is.null(spurious_coefficients) && length(spurious_coefficients) && logit_model) {
893898
if (any(spurious_coefficients > 50)) {
894899
msg <- c(msg, "Some coefficients are very large, which may indicate issues with complete separation.") # nolint
895900
} else if (any(spurious_coefficients > 15)) {

tests/testthat/_snaps/printing.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,24 @@
361361
Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
362362
using a Wald t-distribution approximation.
363363

364+
# no fail for mgcv-binomial
365+
366+
Code
367+
print(out)
368+
Output
369+
# Fixed Effects
370+
371+
Parameter | Log-Odds | SE | 95% CI | z | df | p
372+
---------------------------------------------------------------------
373+
(Intercept) | -0.20 | 0.50 | [-1.18, 0.79] | -0.39 | 29.98 | 0.695
374+
375+
# Smooth Terms
376+
377+
Parameter | z | df | p
378+
---------------------------------------
379+
Smooth term (mpg) | 7.24 | 1.02 | 0.007
380+
Message
381+
382+
The model has a log- or logit-link. Consider using `exponentiate =
383+
TRUE` to interpret coefficients as ratios.
384+

tests/testthat/test-printing.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,13 @@ withr::with_options(
118118
expect_snapshot(print(out))
119119
})
120120
)
121+
122+
withr::with_options(
123+
list(parameters_warning_exponentiate = TRUE),
124+
test_that("no fail for mgcv-binomial", {
125+
skip_if_not_installed("mgcv")
126+
m <- mgcv::gam(vs ~ s(mpg), data = mtcars, family = "binomial")
127+
out <- model_parameters(m)
128+
expect_snapshot(print(out))
129+
})
130+
)

0 commit comments

Comments
 (0)