Skip to content

Commit d69d263

Browse files
authored
minor revisions (#1089)
* minor revisions * paper * skip on CI * Update DESCRIPTION * update tests
1 parent 532e63f commit d69d263

File tree

10 files changed

+116
-23
lines changed

10 files changed

+116
-23
lines changed

DESCRIPTION

Lines changed: 3 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.2.15
4+
Version: 0.24.2.16
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",
@@ -80,7 +80,7 @@ Depends:
8080
Imports:
8181
bayestestR (>= 0.15.2),
8282
datawizard (>= 1.0.2),
83-
insight (>= 1.1.0),
83+
insight (>= 1.2.0),
8484
graphics,
8585
methods,
8686
stats,
@@ -224,5 +224,6 @@ Roxygen: list(markdown = TRUE)
224224
Config/testthat/edition: 3
225225
Config/testthat/parallel: true
226226
Config/Needs/website: easystats/easystatstemplate
227+
Config/Needs/check: stan-dev/cmdstanr
227228
Config/rcmdcheck/ignore-inconsequential-notes: true
228229
Remotes: easystats/insight, easystats/bayestestR

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* `model_parameters()` now shows a more informative coefficient name for binomial
1010
models with probit-link.
1111

12+
* Argument `wb_component` now defaults to `FALSE`.
13+
1214
## Bug fixes
1315

1416
* Fixed printing issue with `model_parameters()` for `htest` objects when

R/methods_glmmTMB.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ model_parameters.glmmTMB <- function(model,
171171
group_level = FALSE,
172172
exponentiate = FALSE,
173173
p_adjust = NULL,
174-
wb_component = TRUE,
174+
wb_component = FALSE,
175175
include_info = getOption("parameters_mixed_info", FALSE),
176176
include_sigma = FALSE,
177177
keep = NULL,

R/methods_lme4.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ model_parameters.merMod <- function(model,
1515
p_adjust = NULL,
1616
vcov = NULL,
1717
vcov_args = NULL,
18-
wb_component = TRUE,
18+
wb_component = FALSE,
1919
include_info = getOption("parameters_mixed_info", FALSE),
2020
include_sigma = FALSE,
2121
keep = NULL,

R/utils_model_parameters.R

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# This function add meta-information to the returned parameters data frame,
2-
# usually used for printing etc.
3-
1+
#' This function adds meta-information to the returned parameters data frame,
2+
#' usually used for printing etc. Prettifying names can be time consuming, if
3+
#' it is not necessary to have pretty names, set `pretty_names = FALSE`
4+
#'
45
#' @keywords internal
6+
#' @noRd
57
.add_model_parameters_attributes <- function(params,
68
model,
79
ci,
@@ -241,6 +243,12 @@
241243
)
242244
}
243245

246+
247+
#' This function formats the column name of the printed output, to reflect
248+
#' the correct type of coefficient.
249+
#'
250+
#' @keywords internal
251+
#' @noRd
244252
.find_coefficient_type <- function(info, exponentiate, model = NULL) {
245253
# column name for coefficients
246254
coef_col <- "Coefficient"
@@ -300,7 +308,11 @@
300308
}
301309

302310

311+
#' This function exponentiates coefficients, e.g. to return odds ratios instead
312+
#' of log-odds ratios.
313+
#'
303314
#' @keywords internal
315+
#' @noRd
304316
.exponentiate_parameters <- function(params, model = NULL, exponentiate = TRUE) {
305317
# "exponentiate" must be
306318
# - TRUE, will always exponentiate all coefficients
@@ -347,6 +359,12 @@
347359
}
348360

349361

362+
#' this function extract "prettified" parameter names, using
363+
#' `insight::clean_parameters()`, and matches them with the parameter names.
364+
#' the result is a named vector, added as attributes to the output
365+
#'
366+
#' @keywords internal
367+
#' @noRd
350368
.add_pretty_names <- function(params, model) {
351369
attr(params, "model_class") <- class(model)
352370
cp <- insight::clean_parameters(model)
@@ -437,10 +455,12 @@
437455
}
438456

439457

440-
# checks for valid inputs in model_parameters(). E.g., some models don't support
441-
# the "vcov" argument - this should not be silently ignored, but rather the user
442-
# should be informed that robust SE are not available for that model.
443-
458+
#' checks for valid inputs in model_parameters(). E.g., some models don't support
459+
#' the "vcov" argument - this should not be silently ignored, but rather the user
460+
#' should be informed that robust SE are not available for that model.
461+
#'
462+
#' @keywords internal
463+
#' @noRd
444464
.check_dots <- function(dots, not_allowed, model_class, function_name = "model_parameters", verbose = TRUE) {
445465
# remove arguments that are NULL
446466
dots <- insight::compact_list(dots)

man/model_parameters.glmmTMB.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

paper/paper.bib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ @article{lakens2020equivalence
5454
title = {Equivalence Testing for Psychological Research: A Tutorial},
5555
volume = {1},
5656
issn = {2515-2459, 2515-2467},
57-
url = {http://journals.sagepub.com/doi/10.1177/2515245918770963},
57+
url = {https://journals.sagepub.com/doi/10.1177/2515245918770963},
5858
doi = {10.1177/2515245918770963},
5959
language = {en},
6060
number = {2},

tests/testthat/_snaps/model_parameters.mixed.md

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# print-model_parameters
1+
# print-model_parameters-1
22

33
Code
4-
model_parameters(model, effects = "fixed")
4+
model_parameters(model, effects = "fixed", wb_component = TRUE)
55
Output
66
Parameter | Coefficient | SE | 95% CI | t(558) | p
77
-------------------------------------------------------------------
@@ -27,7 +27,25 @@
2727
---
2828

2929
Code
30-
model_parameters(m1, effects = "all")
30+
model_parameters(model, effects = "fixed", wb_component = FALSE)
31+
Output
32+
# Fixed Effects
33+
34+
Parameter | Coefficient | SE | 95% CI | t(558) | p
35+
--------------------------------------------------------------------
36+
(Intercept) | 71.53 | 1.56 | [68.48, 74.59] | 45.98 | < .001
37+
time | 1.09 | 0.64 | [-0.17, 2.34] | 1.70 | 0.089
38+
phq4 within | -3.66 | 0.41 | [-4.46, -2.86] | -8.95 | < .001
39+
phq4 between | -6.28 | 0.50 | [-7.27, -5.30] | -12.53 | < .001
40+
Message
41+
42+
Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
43+
using a Wald t-distribution approximation.
44+
45+
# print-model_parameters-2
46+
47+
Code
48+
model_parameters(m1, effects = "all", wb_component = TRUE)
3149
Output
3250
# Fixed Effects
3351
@@ -52,7 +70,53 @@
5270
---
5371

5472
Code
55-
model_parameters(m1, effects = "fixed", include_info = TRUE)
73+
model_parameters(m1, effects = "all", wb_component = FALSE)
74+
Output
75+
# Fixed Effects
76+
77+
Parameter | Coefficient | SE | 95% CI | t(28) | p
78+
-----------------------------------------------------------------
79+
(Intercept) | 0.65 | 0.50 | [-0.38, 1.68] | 1.29 | 0.206
80+
cyl | 0.40 | 0.08 | [ 0.25, 0.56] | 5.29 | < .001
81+
82+
# Random Effects
83+
84+
Parameter | Coefficient | SE | 95% CI
85+
--------------------------------------------------------
86+
SD (Intercept: gear) | 0.27 | 0.24 | [0.05, 1.54]
87+
SD (Residual) | 0.59 | 0.08 | [0.46, 0.77]
88+
Message
89+
90+
Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
91+
using a Wald t-distribution approximation. Uncertainty intervals for
92+
random effect variances computed using a Wald z-distribution
93+
approximation.
94+
95+
---
96+
97+
Code
98+
model_parameters(m1, effects = "fixed", include_info = TRUE, wb_component = TRUE)
99+
Output
100+
# Fixed Effects
101+
102+
Parameter | Coefficient | SE | 95% CI | t(28) | p
103+
-----------------------------------------------------------------
104+
(Intercept) | 0.65 | 0.50 | [-0.38, 1.68] | 1.29 | 0.206
105+
cyl | 0.40 | 0.08 | [ 0.25, 0.56] | 5.29 | < .001
106+
107+
Model: wt ~ cyl (32 Observations)
108+
Sigma: 0.594 (df = 28)
109+
RMSE : 0.564
110+
Conditional R2: 0.628; Marginal R2: 0.550
111+
Message
112+
113+
Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
114+
using a Wald t-distribution approximation.
115+
116+
---
117+
118+
Code
119+
model_parameters(m1, effects = "fixed", include_info = TRUE, wb_component = FALSE)
56120
Output
57121
# Fixed Effects
58122

tests/testthat/test-bootstrap_emmeans.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test_that("emmeans | lm", {
2121
tolerance = 0.1
2222
)
2323

24+
skip_on_ci()
2425
mp <- model_parameters(emmeans::emmeans(b, consec ~ cyl), verbose = FALSE)
2526
expect_identical(
2627
colnames(mp),

tests/testthat/test-model_parameters.mixed.R

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,25 @@ model <- lme4::lmer(
122122
QoL ~ time + phq4_within + phq4_between + (1 | ID),
123123
data = qol_cancer
124124
)
125-
mp <- model_parameters(model, effects = "fixed")
126125

127126
test_that("model_parameters.mixed", {
127+
mp <- model_parameters(model, effects = "fixed", wb_component = TRUE)
128+
mp2 <- model_parameters(model, effects = "fixed", wb_component = FALSE)
128129
expect_identical(mp$Component, c("rewb-contextual", "rewb-contextual", "within", "between"))
130+
expect_null(mp2$Component)
129131
})
130132

131133

132-
test_that("print-model_parameters", {
133-
expect_snapshot(model_parameters(model, effects = "fixed"))
134+
test_that("print-model_parameters-1", {
135+
expect_snapshot(model_parameters(model, effects = "fixed", wb_component = TRUE))
136+
expect_snapshot(model_parameters(model, effects = "fixed", wb_component = FALSE))
134137
})
135138

136-
test_that("print-model_parameters", {
139+
test_that("print-model_parameters-2", {
137140
skip_if_not_installed("merDeriv")
138-
expect_snapshot(model_parameters(m1, effects = "all"))
141+
expect_snapshot(model_parameters(m1, effects = "all", wb_component = TRUE))
142+
expect_snapshot(model_parameters(m1, effects = "all", wb_component = FALSE))
139143

140-
expect_snapshot(model_parameters(m1, effects = "fixed", include_info = TRUE))
144+
expect_snapshot(model_parameters(m1, effects = "fixed", include_info = TRUE, wb_component = TRUE))
145+
expect_snapshot(model_parameters(m1, effects = "fixed", include_info = TRUE, wb_component = FALSE))
141146
})

0 commit comments

Comments
 (0)