From ae642cae2d172c5eae8f10a639556413c9e23086 Mon Sep 17 00:00:00 2001 From: Joseph Larmarange Date: Sat, 27 Jul 2024 13:45:25 +0200 Subject: [PATCH] improving doc, examples and adding NEWS fix #260 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ R/custom_tidiers.R | 14 ++++++++++++-- man/tidy_multgee.Rd | 14 ++++++++++++-- tests/testthat/test-tidy_plus_plus.R | 14 ++++++++++---- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c6a5dfe3..6208c775 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -86,4 +86,4 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 diff --git a/NEWS.md b/NEWS.md index 27e957bd..e142cad8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,6 +19,8 @@ **Fixes** +- `tidy_multgee()` has been fixed to properly identify the different `y.levels` + (#260 @jackmwolf) - `tidy_marginal_predictions()` has been updated to avoid the use of the deprecated function `marginaleffects::datagridcf()` (#256) diff --git a/R/custom_tidiers.R b/R/custom_tidiers.R index 4e53c625..0ce95079 100644 --- a/R/custom_tidiers.R +++ b/R/custom_tidiers.R @@ -258,15 +258,25 @@ tidy_broom <- function(x, ...) { #' interval in the tidied output #' @param conf.level the confidence level to use for the confidence interval #' @param ... additional parameters passed to `parameters::model_parameters()` +#' @details +#' To be noted, for `multgee::nomLORgee()`, the baseline `y` category is the +#' latest modality of `y`. +#' #' @export #' @family custom_tieders #' @examplesIf interactive() #' if (.assert_package("multgee", boolean = TRUE)) { #' library(multgee) #' +#' h <- housing +#' h$status <- factor( +#' h$y, +#' labels = c("street", "community", "independant") +#' ) +#' #' mod <- multgee::nomLORgee( -#' y ~ factor(time) * sec, -#' data = multgee::housing, +#' status ~ factor(time) * sec, +#' data = h, #' id = id, #' repeated = time, #' ) diff --git a/man/tidy_multgee.Rd b/man/tidy_multgee.Rd index a7995da9..dce63148 100644 --- a/man/tidy_multgee.Rd +++ b/man/tidy_multgee.Rd @@ -22,14 +22,24 @@ A tidier for models generated with \code{multgee::nomLORgee()} or \code{multgee: Term names will be updated to be consistent with generic models. The original term names are preserved in an \code{"original_term"} column. } +\details{ +To be noted, for \code{multgee::nomLORgee()}, the baseline \code{y} category is the +latest modality of \code{y}. +} \examples{ \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} if (.assert_package("multgee", boolean = TRUE)) { library(multgee) + h <- housing + h$status <- factor( + h$y, + labels = c("street", "community", "independant") + ) + mod <- multgee::nomLORgee( - y ~ factor(time) * sec, - data = multgee::housing, + status ~ factor(time) * sec, + data = h, id = id, repeated = time, ) diff --git a/tests/testthat/test-tidy_plus_plus.R b/tests/testthat/test-tidy_plus_plus.R index 0ef6d5e4..ca0585f2 100644 --- a/tests/testthat/test-tidy_plus_plus.R +++ b/tests/testthat/test-tidy_plus_plus.R @@ -715,9 +715,14 @@ test_that("tidy_plus_plus() works with multgee models", { skip_if_not_installed("parameters") library(multgee) + h <- housing + h$status <- factor( + h$y, + labels = c("street", "community", "independant") + ) mod <- multgee::nomLORgee( - y ~ factor(time) * sec, - data = multgee::housing, + status ~ factor(time) * sec, + data = h, id = id, repeated = time, ) @@ -728,8 +733,9 @@ test_that("tidy_plus_plus() works with multgee models", { expect_equivalent( res$y.level, c( - "0", "0", "0", "0", "0", "0", "0", "0", - "1", "1", "1", "1", "1", "1", "1", "1" + "street", "street", "street", "street", "street", "street", + "street", "street", "community", "community", "community", "community", + "community", "community", "community", "community" ) ) expect_equivalent(