Skip to content

Commit a400880

Browse files
authored
Improve printing for special brms models, remove ggeffects-metods (#1078)
* Improve printing for special brms models, remove ggeffects-metods * remove suggested * fix
1 parent 4f446f6 commit a400880

18 files changed

+109
-385
lines changed

DESCRIPTION

Lines changed: 1 addition & 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.7
4+
Version: 0.24.2.8
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",
@@ -133,7 +133,6 @@ Suggests:
133133
gamlss,
134134
gee,
135135
geepack,
136-
ggeffects (>= 1.3.2),
137136
ggplot2,
138137
GLMMadaptive,
139138
glmmTMB (>= 1.1.10),

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ S3method(equivalence_test,MixMod)
136136
S3method(equivalence_test,feis)
137137
S3method(equivalence_test,felm)
138138
S3method(equivalence_test,gee)
139-
S3method(equivalence_test,ggeffects)
140139
S3method(equivalence_test,glm)
141140
S3method(equivalence_test,glmmTMB)
142141
S3method(equivalence_test,gls)
@@ -238,7 +237,6 @@ S3method(model_parameters,flic)
238237
S3method(model_parameters,gam)
239238
S3method(model_parameters,gamlss)
240239
S3method(model_parameters,gamm)
241-
S3method(model_parameters,ggeffects)
242240
S3method(model_parameters,glht)
243241
S3method(model_parameters,glimML)
244242
S3method(model_parameters,glm)

R/1_model_parameters.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030
#' - [Zero-inflated and hurdle][model_parameters.zcpglm()]: **cplm**, **mhurdle**,
3131
#' **pscl**, ...
3232
#' - [Other models][model_parameters.glimML()]: **aod**, **bbmle**, **betareg**,
33-
#' **emmeans**, **epiR**, **ggeffects**, **glmx**, **ivfixed**, **ivprobit**,
34-
#' **JRM**, **lmodel2**, **logitsf**, **marginaleffects**, **margins**, **maxLik**,
33+
#' **emmeans**, **epiR**, **glmx**, **ivfixed**, **ivprobit**, **JRM**,
34+
#' **lmodel2**, **logitsf**, **marginaleffects**, **margins**, **maxLik**,
3535
#' **mediation**, **mfx**, **multcomp**, **mvord**, **plm**, **PMCMRplus**,
3636
#' **quantreg**, **selection**, **systemfit**, **tidymodels**, **varEST**,
37-
#' **WRS2**, `bfsl`, `deltaMethod`, `fitdistr`, `mjoint`, `mle`, `model.avg`, ...
37+
#' **WRS2**, `bfsl`, `deltaMethod`, `fitdistr`, `mjoint`, `mle`, `model.avg`,
38+
#' ...
3839
#'
3940
#' A full overview can be found here:
4041
#' https://easystats.github.io/parameters/reference/

R/equivalence_test.R

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ bayestestR::equivalence_test
1414
#' @param ci Confidence Interval (CI) level. Default to `0.95` (`95%`).
1515
#' @param rule Character, indicating the rules when testing for practical
1616
#' equivalence. Can be `"bayes"`, `"classic"` or `"cet"`. See 'Details'.
17-
#' @param test Hypothesis test for computing contrasts or pairwise comparisons.
18-
#' See [`?ggeffects::test_predictions`](https://strengejacke.github.io/ggeffects/reference/test_predictions.html)
19-
#' for details.
2017
#' @param verbose Toggle warnings and messages.
2118
#' @param ... Arguments passed to or from other methods.
2219
#' @inheritParams model_parameters.glmmTMB
@@ -405,85 +402,6 @@ equivalence_test.parameters_model <- function(x,
405402
}
406403

407404

408-
#' @rdname equivalence_test.lm
409-
#' @export
410-
equivalence_test.ggeffects <- function(x,
411-
range = "default",
412-
rule = "classic",
413-
test = "pairwise",
414-
verbose = TRUE,
415-
...) {
416-
insight::check_if_installed("ggeffects")
417-
418-
# get attributes from ggeffects objects, so we have the original model and terms
419-
focal <- attributes(x)$original.terms
420-
obj_name <- attributes(x)$model.name
421-
ci <- attributes(x)$ci.lvl
422-
dof <- attributes(x)$df
423-
424-
x <- .get_ggeffects_model(x)
425-
426-
# validation check rope range
427-
rule <- match.arg(tolower(rule), choices = c("bayes", "classic", "cet"))
428-
range <- .check_rope_range(x, range, verbose)
429-
430-
out <- ggeffects::test_predictions(
431-
x,
432-
terms = focal,
433-
test = test,
434-
equivalence = range,
435-
verbose = verbose,
436-
...
437-
)
438-
439-
out <- insight::standardize_names(out)
440-
441-
# we only have one type of CIs
442-
conf_int <- conf_int2 <- as.data.frame(t(out[c("CI_low", "CI_high")]))
443-
444-
l <- Map(
445-
function(ci_wide, ci_narrow) {
446-
.equivalence_test_numeric(
447-
ci = ci,
448-
ci_wide,
449-
ci_narrow,
450-
range_rope = range,
451-
rule = rule,
452-
dof = dof,
453-
verbose = verbose
454-
)
455-
}, conf_int, conf_int2
456-
)
457-
458-
# bind to data frame
459-
dat <- do.call(rbind, l)
460-
461-
# remove old CIs, bind results from equivalence test
462-
out$CI_low <- out$CI_high <- NULL
463-
out$CI <- ci
464-
out <- cbind(out, dat)
465-
466-
# standardize column order
467-
cols <- c(
468-
"Estimate", "Contrast", "Slope", "Predicted", "CI", "CI_low", "CI_high",
469-
"SGPV", "ROPE_low", "ROPE_high", "ROPE_Percentage", "ROPE_Equivalence", "p"
470-
)
471-
472-
# order of shared columns
473-
shared_order <- intersect(cols, colnames(out))
474-
parameter_columns <- setdiff(colnames(out), shared_order)
475-
# add remaining columns, sort
476-
out <- out[c(parameter_columns, shared_order)]
477-
478-
attr(out, "object_name") <- obj_name
479-
attr(out, "parameter_columns") <- parameter_columns
480-
attr(out, "rule") <- rule
481-
attr(out, "rope") <- range
482-
class(out) <- c("equivalence_test_lm", "see_equivalence_test_ggeffects", "data.frame")
483-
out
484-
}
485-
486-
487405
# helper -------------------
488406

489407

R/format.R

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ format.parameters_sem <- function(x,
561561
footer_text <- attributes(x)$footer_text
562562
text_alternative <- attributes(x)$text_alternative
563563
n_obs <- attributes(x)$n_obs
564-
is_ggeffects <- isTRUE(attributes(x)$is_ggeffects)
565564

566565
# footer: model formula
567566
if (isTRUE(show_formula)) {
@@ -611,26 +610,20 @@ format.parameters_sem <- function(x,
611610

612611
# footer: generic text
613612
if (!is.null(footer_text)) {
614-
footer <- .add_footer_text(footer, footer_text, type, is_ggeffects)
613+
footer <- .add_footer_text(footer, footer_text, type)
615614
}
616615

617616
# if we have two trailing newlines, remove one
618617
if (identical(type, "text") && !is.null(footer) && endsWith(footer[1], "\n\n")) {
619618
footer[1] <- substr(footer[1], 0, nchar(x) - 1)
620619
}
621620

622-
# finally, for ggeffects and HTML, remove *
623-
if (is_ggeffects && type == "html") {
624-
footer <- gsub("*", "", footer, fixed = TRUE)
625-
footer <- gsub(":;", ":", footer, fixed = TRUE)
626-
}
627-
628621
footer
629622
}
630623

631624

632625
# footer: generic text
633-
.add_footer_text <- function(footer = NULL, text = NULL, type = "text", is_ggeffects = FALSE) {
626+
.add_footer_text <- function(footer = NULL, text = NULL, type = "text") {
634627
if (!is.null(text) && length(text)) {
635628
if (type == "text" || type == "markdown") {
636629
if (is.null(footer)) {
@@ -640,8 +633,7 @@ format.parameters_sem <- function(x,
640633
}
641634
footer <- paste0(footer, sprintf("%s%s\n", fill, text))
642635
} else if (type == "html") {
643-
replacement <- ifelse(is_ggeffects, ";", "")
644-
footer <- c(footer, gsub("\n", replacement, text, fixed = TRUE))
636+
footer <- c(footer, gsub("\n", "", text, fixed = TRUE))
645637
}
646638
}
647639
footer

R/group_level_total.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
)
138138

139139
# select parameters to keep. We want all intercepts, and all random slopes
140-
components <- insight::find_auxiliary(x)
140+
components <- .safe(insight::find_auxiliary(x))
141141
# standard components
142142
parameters_to_keep <- params$Parameter %in% c("Intercept", random_slopes$random)
143143
parameters_to_keep <- parameters_to_keep |

R/methods_ggeffects.R

Lines changed: 0 additions & 121 deletions
This file was deleted.

R/print.parameters_model.R

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,7 @@ print.parameters_random <- function(x, digits = 2, ...) {
486486

487487
# caption = NULL, set default for HTML tables
488488
if (identical(format, "html") && is.null(caption)) {
489-
if (isTRUE(attributes(x)$is_ggeffects)) {
490-
table_caption <- title_attribute
491-
} else {
492-
table_caption <- "Model Summary"
493-
}
489+
table_caption <- "Model Summary"
494490
} else if (isTRUE(attributes(x)$ordinal_model)) {
495491
table_caption <- ""
496492

0 commit comments

Comments
 (0)