From 2e3b010234551fcb2272f69b9a45514fc001989c Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Mon, 13 May 2024 13:29:24 -0400 Subject: [PATCH] marginaleffects 0.20.1: minor change in labels (#968) * marginaleffects 0.20.1: minor change in labels * trigger CI * update test * bump required version --------- Co-authored-by: Daniel --- DESCRIPTION | 5 ++--- R/methods_marginaleffects.R | 3 +++ tests/testthat/test-marginaleffects.R | 6 ++---- tests/testthat/test-model_parameters.coxme.R | 1 + 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0b8d8ccf0..ef780a305 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.21.6.6 +Version: 0.21.6.7 Authors@R: c(person(given = "Daniel", family = "Lüdecke", @@ -151,7 +151,7 @@ Suggests: logspline, lqmm, M3C, - marginaleffects (>= 0.16.0), + marginaleffects (>= 0.20.1), MASS, Matrix, mclogit, @@ -218,4 +218,3 @@ Config/Needs/website: r-lib/pkgdown, easystats/easystatstemplate Config/rcmdcheck/ignore-inconsequential-notes: true -Remotes: easystats/insight diff --git a/R/methods_marginaleffects.R b/R/methods_marginaleffects.R index 87a6eae3f..803970fa1 100644 --- a/R/methods_marginaleffects.R +++ b/R/methods_marginaleffects.R @@ -23,6 +23,9 @@ model_parameters.marginaleffects <- function(model, attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model)) + # do not print or report these columns + out <- out[, !colnames(out) %in% c("predicted_lo", "predicted_hi"), drop = FALSE] + if (inherits(model, "marginalmeans")) { attr(out, "coefficient_name") <- "Marginal Means" } else if (inherits(model, "comparisons")) { diff --git a/tests/testthat/test-marginaleffects.R b/tests/testthat/test-marginaleffects.R index 22853e264..6e7184485 100644 --- a/tests/testthat/test-marginaleffects.R +++ b/tests/testthat/test-marginaleffects.R @@ -8,10 +8,8 @@ test_that("marginaleffects()", { model <- marginaleffects::avg_slopes(x, newdata = insight::get_datagrid(x, at = "Species"), variables = "Petal.Length") out <- parameters(model) expect_identical(nrow(out), 1L) - expect_named(out, c( - "Parameter", "Coefficient", "SE", "Statistic", - "p", "S", "CI", "CI_low", "CI_high" - )) + cols <- c("Parameter", "Comparison", "Coefficient", "SE", "Statistic", "p", "S", "CI", "CI_low", "CI_high") + expect_true(all(cols %in% colnames(out))) out <- model_parameters(model, exponentiate = TRUE) expect_equal(out$Coefficient, 1.394, tolerance = 1e-3) diff --git a/tests/testthat/test-model_parameters.coxme.R b/tests/testthat/test-model_parameters.coxme.R index abc14d89c..e64af9d92 100644 --- a/tests/testthat/test-model_parameters.coxme.R +++ b/tests/testthat/test-model_parameters.coxme.R @@ -1,6 +1,7 @@ skip_on_cran() skip_if_not_installed("coxme") skip_if_not_installed("survival") +skip_if_not_installed("withr") # modelparameters ----------------------------------