Skip to content

Commit 61a1aeb

Browse files
authored
Odds ratios for clm() and alike from package ordinal (#1162)
* Odds ratios for `clm()` and alike from package ordinal Fixes #1161 * Add Air workflow * fix * remove * update snaps
1 parent c84f3c9 commit 61a1aeb

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
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.28.0.15
4+
Version: 0.28.0.16
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
* Fixed issue with `equivalence_test()` for models of class `glmmTMB` with
1717
`beta_family()`.
1818

19+
* `exponentiate = TRUE` in `model_parameters()` did not exponentiate location
20+
and scale parameters for models from package *ordinal*.
21+
1922
# parameters 0.28.0
2023

2124
## Breaking Changes

R/utils_model_parameters.R

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,9 @@
347347
if (inherits(model, "mvord")) {
348348
rows <- params$Component != "correlation"
349349
} else if (is.null(params$Component)) {
350-
# don't exponentiate dispersion
351350
rows <- seq_len(nrow(params))
352-
} else if (inherits(model, c("clm", "clm2", "clmm"))) {
353-
## TODO: make sure we catch all ordinal models properly here
354-
rows <- !tolower(params$Component) %in% c("location", "scale")
355351
} else {
352+
# don't exponentiate dispersion
356353
rows <- !tolower(params$Component) %in% c("dispersion", "residual")
357354
}
358355
params[rows, columns] <- exp(params[rows, columns])

inst/WORDLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ nestedLogit
327327
nlme
328328
nnet
329329
nubmer
330+
onwards
330331
pam
331332
pamk
332333
patilindrajeets

tests/testthat/_snaps/model_parameters_ordinal.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
1818
Parameter | Estimate | SE | 95% CI | z | p
1919
------------------------------------------------------------
20-
Stim [Old] | 0.55 | 0.04 | [0.47, 0.63] | 13.64 | < .001
20+
Stim [Old] | 1.74 | 0.07 | [1.60, 1.88] | 13.64 | < .001
2121
2222
# Scale Parameters
2323
2424
Parameter | Estimate | SE | 95% CI | z | p
2525
------------------------------------------------------------
26-
Stim [Old] | -0.04 | 0.04 | [0.47, 0.63] | 13.64 | < .001
26+
Stim [Old] | 0.96 | 0.04 | [1.60, 1.88] | 13.64 | < .001
2727
Message
2828
2929
Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
@@ -48,13 +48,13 @@
4848
4949
Parameter | Estimate | SE | 95% CI | z | p
5050
------------------------------------------------------------
51-
Stim [Old] | 0.55 | 0.04 | [0.47, 0.63] | 13.64 | < .001
51+
Stim [Old] | 1.74 | 0.07 | [1.60, 1.88] | 13.64 | < .001
5252
5353
# Scale Parameters
5454
55-
Parameter | Estimate | SE | 95% CI | z | p
56-
------------------------------------------------------------
57-
Stim [Old] | -0.04 | 0.04 | [-0.12, 0.04] | -1.11 | 0.268
55+
Parameter | Estimate | SE | 95% CI | z | p
56+
-----------------------------------------------------------
57+
Stim [Old] | 0.96 | 0.04 | [0.89, 1.04] | -1.11 | 0.268
5858
Message
5959
6060
Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed

tests/testthat/test-marginaleffects.R

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -265,20 +265,20 @@ test_that("modelbased, tidiers work", {
265265
})
266266

267267

268-
## TODO: check this test locally
269-
270-
# Following test may fail on CI, probably due to scoping issues?
271-
# ── Error (test-marginaleffects.R:179:3): predictions, using bayestestR #1063 ───
272-
# Error in ``[.data.frame`(data, random_factors)`: undefined columns selected
273-
# Backtrace:
274-
#
275-
# 1. ├─insight::get_datagrid(m, by = "Days", include_random = TRUE) at test-marginaleffects.R:179:3
276-
# 2. └─insight:::get_datagrid.default(m, by = "Days", include_random = TRUE)
277-
# 3. ├─base::lapply(data[random_factors], as.factor)
278-
# 4. ├─data[random_factors]
279-
# 5. └─base::`[.data.frame`(data, random_factors)
280-
281268
test_that("predictions, using bayestestR #1063", {
269+
# Following test may fail on CI, probably due to scoping issues?
270+
# ── Error (test-marginaleffects.R:179:3): predictions, using bayestestR #1063 ───
271+
# Error in ``[.data.frame`(data, random_factors)`: undefined columns selected
272+
# Backtrace:
273+
#
274+
# 1. ├─insight::get_datagrid(m, by = "Days", include_random = TRUE) at test-marginaleffects.R:179:3
275+
# 2. └─insight:::get_datagrid.default(m, by = "Days", include_random = TRUE)
276+
# 3. ├─base::lapply(data[random_factors], as.factor)
277+
# 4. ├─data[random_factors]
278+
# 5. └─base::`[.data.frame`(data, random_factors)
279+
## TODO: check this test locally
280+
skip("TODO: check this test locally, fails on CI, probably due to scoping issues?")
281+
282282
skip_on_ci()
283283
skip_on_cran()
284284
skip_if_not_installed("curl")

tests/testthat/test-model_parameters_ordinal.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ test_that("model_parameters.clm", {
5353
mp <- model_parameters(m1, exponentiate = TRUE)
5454
expect_equal(
5555
mp$Coefficient,
56-
c(0.48266, 0.85332, 1.30451, 2.006, 3.4376, 0.55237, -0.04069),
56+
c(0.48266, 0.85332, 1.30451, 2.006, 3.4376, 1.737366, 0.9601267),
5757
tolerance = 1e-4
5858
)
5959

@@ -85,7 +85,7 @@ test_that("model_parameters.clm2", {
8585
mp <- model_parameters(m2, exponentiate = TRUE)
8686
expect_equal(
8787
mp$Coefficient,
88-
c(0.48266, 0.85332, 1.30451, 2.006, 3.4376, 0.55237, -0.04069),
88+
c(0.48266, 0.85332, 1.30451, 2.006, 3.4376, 1.73737, 0.96013),
8989
tolerance = 1e-4
9090
)
9191

0 commit comments

Comments
 (0)