From 38de624b9961be8291b6a20610383bd3b4811ad9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 14:26:51 +0200 Subject: [PATCH 01/18] Replace `degrees_of_freedom()` with `get_df()` --- DESCRIPTION | 3 ++- R/2_ci.R | 7 +++---- R/4_standard_error.R | 27 ++++++++++++++------------- man/model_parameters.default.Rd | 11 ++++++----- man/model_parameters.merMod.Rd | 11 ++++++----- man/model_parameters.mlm.Rd | 11 ++++++----- man/p_value.Rd | 11 ++++++----- man/standard_error.Rd | 27 +++++++++++++++------------ 8 files changed, 58 insertions(+), 50 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 82b3c485d..834ede363 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.22.1.1 +Version: 0.22.1.2 Authors@R: c(person(given = "Daniel", family = "Lüdecke", @@ -218,3 +218,4 @@ Config/testthat/edition: 3 Config/testthat/parallel: true Config/Needs/website: easystats/easystatstemplate Config/rcmdcheck/ignore-inconsequential-notes: true +Remotes: easystats/insight diff --git a/R/2_ci.R b/R/2_ci.R index df2b3b966..79e3e59da 100644 --- a/R/2_ci.R +++ b/R/2_ci.R @@ -7,10 +7,9 @@ #' @param ci Confidence Interval (CI) level. Default to `0.95` (`95%`). #' @param dof Number of degrees of freedom to be used when calculating #' confidence intervals. If `NULL` (default), the degrees of freedom are -#' retrieved by calling [`degrees_of_freedom()`] with -#' approximation method defined in `method`. If not `NULL`, use this argument -#' to override the default degrees of freedom used to compute confidence -#' intervals. +#' retrieved by calling [`insight::get_df()`] with approximation method +#' defined in `method`. If not `NULL`, use this argument to override the +#' default degrees of freedom used to compute confidence intervals. #' @param method Method for computing degrees of freedom for #' confidence intervals (CI) and the related p-values. Allowed are following #' options (which vary depending on the model class): `"residual"`, diff --git a/R/4_standard_error.R b/R/4_standard_error.R index c35300bcc..0824296d7 100644 --- a/R/4_standard_error.R +++ b/R/4_standard_error.R @@ -18,11 +18,12 @@ #' * A string which indicates the kind of uncertainty estimates to return. #' - Heteroskedasticity-consistent: `"vcovHC"`, `"HC"`, `"HC0"`, `"HC1"`, #' `"HC2"`, `"HC3"`, `"HC4"`, `"HC4m"`, `"HC5"`. See `?sandwich::vcovHC`. -#' - Cluster-robust: `"vcovCR"`, `"CR0"`, `"CR1"`, `"CR1p"`, `"CR1S"`, `"CR2"`, -#' `"CR3"`. See `?clubSandwich::vcovCR`. -#' - Bootstrap: `"vcovBS"`, `"xy"`, `"residual"`, `"wild"`, `"mammen"`, `"webb"`. -#' See `?sandwich::vcovBS`. -#' - Other `sandwich` package functions: `"vcovHAC"`, `"vcovPC"`, `"vcovCL"`, `"vcovPL"`. +#' - Cluster-robust: `"vcovCR"`, `"CR0"`, `"CR1"`, `"CR1p"`, `"CR1S"`, +#' `"CR2"`, `"CR3"`. See `?clubSandwich::vcovCR`. +#' - Bootstrap: `"vcovBS"`, `"xy"`, `"residual"`, `"wild"`, `"mammen"`, +#' `"webb"`. See `?sandwich::vcovBS`. +#' - Other `sandwich` package functions: `"vcovHAC"`, `"vcovPC"`, `"vcovCL"`, +#' `"vcovPL"`. #' @param vcov_args List of arguments to be passed to the function identified by #' the `vcov` argument. This function is typically supplied by the **sandwich** #' or **clubSandwich** packages. Please refer to their documentation (e.g., @@ -46,18 +47,18 @@ #' standard errors. Depending on the model, may also include columns for model #' components etc. #' -#' @examples +#' @examplesIf require("sandwich") && require("clubSandwich") #' model <- lm(Petal.Length ~ Sepal.Length * Species, data = iris) #' standard_error(model) #' -#' if (require("sandwich") && require("clubSandwich")) { -#' standard_error(model, vcov = "HC3") +#' # robust standard errors +#' standard_error(model, vcov = "HC3") #' -#' standard_error(model, -#' vcov = "vcovCL", -#' vcov_args = list(cluster = iris$Species) -#' ) -#' } +#' # cluster-robust standard errors +#' standard_error(model, +#' vcov = "vcovCL", +#' vcov_args = list(cluster = iris$Species) +#' ) #' @export standard_error <- function(model, ...) { UseMethod("standard_error") diff --git a/man/model_parameters.default.Rd b/man/model_parameters.default.Rd index 2a2ccec29..dcf2dddfc 100644 --- a/man/model_parameters.default.Rd +++ b/man/model_parameters.default.Rd @@ -161,11 +161,12 @@ the function to be used to compute the covariance matrix. \itemize{ \item Heteroskedasticity-consistent: \code{"vcovHC"}, \code{"HC"}, \code{"HC0"}, \code{"HC1"}, \code{"HC2"}, \code{"HC3"}, \code{"HC4"}, \code{"HC4m"}, \code{"HC5"}. See \code{?sandwich::vcovHC}. -\item Cluster-robust: \code{"vcovCR"}, \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, \code{"CR1S"}, \code{"CR2"}, -\code{"CR3"}. See \code{?clubSandwich::vcovCR}. -\item Bootstrap: \code{"vcovBS"}, \code{"xy"}, \code{"residual"}, \code{"wild"}, \code{"mammen"}, \code{"webb"}. -See \code{?sandwich::vcovBS}. -\item Other \code{sandwich} package functions: \code{"vcovHAC"}, \code{"vcovPC"}, \code{"vcovCL"}, \code{"vcovPL"}. +\item Cluster-robust: \code{"vcovCR"}, \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, \code{"CR1S"}, +\code{"CR2"}, \code{"CR3"}. See \code{?clubSandwich::vcovCR}. +\item Bootstrap: \code{"vcovBS"}, \code{"xy"}, \code{"residual"}, \code{"wild"}, \code{"mammen"}, +\code{"webb"}. See \code{?sandwich::vcovBS}. +\item Other \code{sandwich} package functions: \code{"vcovHAC"}, \code{"vcovPC"}, \code{"vcovCL"}, +\code{"vcovPL"}. } }} diff --git a/man/model_parameters.merMod.Rd b/man/model_parameters.merMod.Rd index 8b1b8e75c..680b99992 100644 --- a/man/model_parameters.merMod.Rd +++ b/man/model_parameters.merMod.Rd @@ -320,11 +320,12 @@ the function to be used to compute the covariance matrix. \itemize{ \item Heteroskedasticity-consistent: \code{"vcovHC"}, \code{"HC"}, \code{"HC0"}, \code{"HC1"}, \code{"HC2"}, \code{"HC3"}, \code{"HC4"}, \code{"HC4m"}, \code{"HC5"}. See \code{?sandwich::vcovHC}. -\item Cluster-robust: \code{"vcovCR"}, \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, \code{"CR1S"}, \code{"CR2"}, -\code{"CR3"}. See \code{?clubSandwich::vcovCR}. -\item Bootstrap: \code{"vcovBS"}, \code{"xy"}, \code{"residual"}, \code{"wild"}, \code{"mammen"}, \code{"webb"}. -See \code{?sandwich::vcovBS}. -\item Other \code{sandwich} package functions: \code{"vcovHAC"}, \code{"vcovPC"}, \code{"vcovCL"}, \code{"vcovPL"}. +\item Cluster-robust: \code{"vcovCR"}, \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, \code{"CR1S"}, +\code{"CR2"}, \code{"CR3"}. See \code{?clubSandwich::vcovCR}. +\item Bootstrap: \code{"vcovBS"}, \code{"xy"}, \code{"residual"}, \code{"wild"}, \code{"mammen"}, +\code{"webb"}. See \code{?sandwich::vcovBS}. +\item Other \code{sandwich} package functions: \code{"vcovHAC"}, \code{"vcovPC"}, \code{"vcovCL"}, +\code{"vcovPL"}. } }} diff --git a/man/model_parameters.mlm.Rd b/man/model_parameters.mlm.Rd index fb6e86490..bae5ce615 100644 --- a/man/model_parameters.mlm.Rd +++ b/man/model_parameters.mlm.Rd @@ -170,11 +170,12 @@ the function to be used to compute the covariance matrix. \itemize{ \item Heteroskedasticity-consistent: \code{"vcovHC"}, \code{"HC"}, \code{"HC0"}, \code{"HC1"}, \code{"HC2"}, \code{"HC3"}, \code{"HC4"}, \code{"HC4m"}, \code{"HC5"}. See \code{?sandwich::vcovHC}. -\item Cluster-robust: \code{"vcovCR"}, \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, \code{"CR1S"}, \code{"CR2"}, -\code{"CR3"}. See \code{?clubSandwich::vcovCR}. -\item Bootstrap: \code{"vcovBS"}, \code{"xy"}, \code{"residual"}, \code{"wild"}, \code{"mammen"}, \code{"webb"}. -See \code{?sandwich::vcovBS}. -\item Other \code{sandwich} package functions: \code{"vcovHAC"}, \code{"vcovPC"}, \code{"vcovCL"}, \code{"vcovPL"}. +\item Cluster-robust: \code{"vcovCR"}, \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, \code{"CR1S"}, +\code{"CR2"}, \code{"CR3"}. See \code{?clubSandwich::vcovCR}. +\item Bootstrap: \code{"vcovBS"}, \code{"xy"}, \code{"residual"}, \code{"wild"}, \code{"mammen"}, +\code{"webb"}. See \code{?sandwich::vcovBS}. +\item Other \code{sandwich} package functions: \code{"vcovHAC"}, \code{"vcovPC"}, \code{"vcovCL"}, +\code{"vcovPL"}. } }} diff --git a/man/p_value.Rd b/man/p_value.Rd index 9797e389f..c0af41e07 100644 --- a/man/p_value.Rd +++ b/man/p_value.Rd @@ -57,11 +57,12 @@ the function to be used to compute the covariance matrix. \itemize{ \item Heteroskedasticity-consistent: \code{"vcovHC"}, \code{"HC"}, \code{"HC0"}, \code{"HC1"}, \code{"HC2"}, \code{"HC3"}, \code{"HC4"}, \code{"HC4m"}, \code{"HC5"}. See \code{?sandwich::vcovHC}. -\item Cluster-robust: \code{"vcovCR"}, \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, \code{"CR1S"}, \code{"CR2"}, -\code{"CR3"}. See \code{?clubSandwich::vcovCR}. -\item Bootstrap: \code{"vcovBS"}, \code{"xy"}, \code{"residual"}, \code{"wild"}, \code{"mammen"}, \code{"webb"}. -See \code{?sandwich::vcovBS}. -\item Other \code{sandwich} package functions: \code{"vcovHAC"}, \code{"vcovPC"}, \code{"vcovCL"}, \code{"vcovPL"}. +\item Cluster-robust: \code{"vcovCR"}, \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, \code{"CR1S"}, +\code{"CR2"}, \code{"CR3"}. See \code{?clubSandwich::vcovCR}. +\item Bootstrap: \code{"vcovBS"}, \code{"xy"}, \code{"residual"}, \code{"wild"}, \code{"mammen"}, +\code{"webb"}. See \code{?sandwich::vcovBS}. +\item Other \code{sandwich} package functions: \code{"vcovHAC"}, \code{"vcovPC"}, \code{"vcovCL"}, +\code{"vcovPL"}. } }} diff --git a/man/standard_error.Rd b/man/standard_error.Rd index 3dc8d3410..bbe63709e 100644 --- a/man/standard_error.Rd +++ b/man/standard_error.Rd @@ -59,11 +59,12 @@ the function to be used to compute the covariance matrix. \itemize{ \item Heteroskedasticity-consistent: \code{"vcovHC"}, \code{"HC"}, \code{"HC0"}, \code{"HC1"}, \code{"HC2"}, \code{"HC3"}, \code{"HC4"}, \code{"HC4m"}, \code{"HC5"}. See \code{?sandwich::vcovHC}. -\item Cluster-robust: \code{"vcovCR"}, \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, \code{"CR1S"}, \code{"CR2"}, -\code{"CR3"}. See \code{?clubSandwich::vcovCR}. -\item Bootstrap: \code{"vcovBS"}, \code{"xy"}, \code{"residual"}, \code{"wild"}, \code{"mammen"}, \code{"webb"}. -See \code{?sandwich::vcovBS}. -\item Other \code{sandwich} package functions: \code{"vcovHAC"}, \code{"vcovPC"}, \code{"vcovCL"}, \code{"vcovPL"}. +\item Cluster-robust: \code{"vcovCR"}, \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, \code{"CR1S"}, +\code{"CR2"}, \code{"CR3"}. See \code{?clubSandwich::vcovCR}. +\item Bootstrap: \code{"vcovBS"}, \code{"xy"}, \code{"residual"}, \code{"wild"}, \code{"mammen"}, +\code{"webb"}. See \code{?sandwich::vcovBS}. +\item Other \code{sandwich} package functions: \code{"vcovHAC"}, \code{"vcovPC"}, \code{"vcovCL"}, +\code{"vcovPL"}. } }} @@ -109,15 +110,17 @@ For Bayesian models (from \strong{rstanarm} or \strong{brms}), the standard error is the SD of the posterior samples. } \examples{ +\dontshow{if (require("sandwich") && require("clubSandwich")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} model <- lm(Petal.Length ~ Sepal.Length * Species, data = iris) standard_error(model) -if (require("sandwich") && require("clubSandwich")) { - standard_error(model, vcov = "HC3") +# robust standard errors +standard_error(model, vcov = "HC3") - standard_error(model, - vcov = "vcovCL", - vcov_args = list(cluster = iris$Species) - ) -} +# cluster-robust standard errors +standard_error(model, + vcov = "vcovCL", + vcov_args = list(cluster = iris$Species) +) +\dontshow{\}) # examplesIf} } From c2d07e6c04e3852d2a75771e613e38fa1c23092d Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 14:29:07 +0200 Subject: [PATCH 02/18] update p_value and ci --- R/3_p_value.R | 4 ++-- R/ci_generic.R | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/3_p_value.R b/R/3_p_value.R index 05ba9cd7c..c2c76c886 100644 --- a/R/3_p_value.R +++ b/R/3_p_value.R @@ -76,7 +76,7 @@ p_value.default <- function(model, if (method %in% c("residual", "wald", "normal", "satterthwaite", "kenward", "kr")) { if (is.null(dof)) { - dof <- degrees_of_freedom(model, method = method, verbose = FALSE) + dof <- insight::get_df(x = model, type = method, verbose = FALSE) } return(.p_value_dof( model, @@ -111,7 +111,7 @@ p_value.default <- function(model, se <- do.call("standard_error", fun_args) } - dof <- degrees_of_freedom(model, method = "wald", verbose = FALSE) + dof <- insight::get_df(x = model, type = "wald", verbose = FALSE) se <- merge(se, co, sort = FALSE) se$Statistic <- se$Estimate / se$SE se$p <- 2 * stats::pt(abs(se$Statistic), df = dof, lower.tail = FALSE) diff --git a/R/ci_generic.R b/R/ci_generic.R index 267143a1c..1bfad93e3 100644 --- a/R/ci_generic.R +++ b/R/ci_generic.R @@ -144,7 +144,7 @@ # check if we have a valid dof vector if (is.null(dof)) { # residual df - dof <- degrees_of_freedom(model, method = method, verbose = FALSE) + dof <- insight::get_df(x = model, type = method, verbose = FALSE) # make sure we have a value for degrees of freedom if (is.null(dof) || length(dof) == 0 || .is_chi2_model(model, dof)) { dof <- Inf From 9e6eed19fa6277c5e1edacb3779e6d740a849a8e Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 14:31:34 +0200 Subject: [PATCH 03/18] equi_test, extract_params --- R/equivalence_test.R | 2 +- R/extract_parameters.R | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/equivalence_test.R b/R/equivalence_test.R index e0e368709..754dbdb42 100644 --- a/R/equivalence_test.R +++ b/R/equivalence_test.R @@ -674,7 +674,7 @@ equivalence_test.ggeffects <- function(x, params <- insight::get_parameters(model) # degrees of freedom - dof <- degrees_of_freedom(model, method = "any") + dof <- insight::get_df(x = model, type = "residual") # mu params$mu <- params$Estimate * -1 diff --git a/R/extract_parameters.R b/R/extract_parameters.R index 34e6e1305..05fb66751 100644 --- a/R/extract_parameters.R +++ b/R/extract_parameters.R @@ -186,9 +186,9 @@ # ==== degrees of freedom if (is.null(ci_method)) { - df_error <- degrees_of_freedom(model, method = "any", verbose = FALSE) + df_error <- insight::get_df(x = model, type = "residual", verbose = FALSE) } else { - df_error <- degrees_of_freedom(model, method = ci_method, verbose = FALSE) + df_error <- insight::get_df(x = model, type = ci_method, verbose = FALSE) } if (!is.null(df_error) && (length(df_error) == 1 || length(df_error) == nrow(parameters))) { if (length(df_error) == 1) { @@ -565,7 +565,7 @@ if (!ci_method %in% special_ci_methods) { df_error <- data.frame( Parameter = parameters$Parameter, - df_error = degrees_of_freedom(model, method = "any"), + df_error = insight::get_df(x = model, type = "residual"), stringsAsFactors = FALSE ) } From 9403627b0d2f3d78800370220112c0ee2096a9cf Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 14:48:54 +0200 Subject: [PATCH 04/18] fix --- R/4_standard_error.R | 32 +++++++++++++-------------- tests/testthat/test-rank_deficienty.R | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/R/4_standard_error.R b/R/4_standard_error.R index 0824296d7..88a2466cb 100644 --- a/R/4_standard_error.R +++ b/R/4_standard_error.R @@ -163,27 +163,25 @@ standard_error.default <- function(model, cs <- .safe(suppressWarnings(stats::coef(summary(model)))) se <- NULL - if (!is.null(se)) { - if (is.list(cs) && !is.null(component)) { - cs <- cs[[component]] + if (is.list(cs) && !is.null(component)) { + cs <- cs[[component]] + } + if (!is.null(cs)) { + # do we have a se column? + se_col <- which(colnames(cs) == "Std. Error") + # if not, default to 2 + if (length(se_col) == 0) { + se_col <- 2 } - if (!is.null(cs)) { - # do we have a se column? - se_col <- which(colnames(cs) == "Std. Error") - # if not, default to 2 - if (length(se_col) == 0) { - se_col <- 2 - } - se <- as.vector(cs[, se_col]) - if (is.null(names(se))) { - coef_names <- rownames(cs) - if (length(coef_names) == length(se)) { - names(se) <- coef_names - } + se <- as.vector(cs[, se_col]) + if (is.null(names(se))) { + coef_names <- rownames(cs) + if (length(coef_names) == length(se)) { + names(se) <- coef_names } } - names(se) <- .remove_backticks_from_string(names(se)) } + names(se) <- .remove_backticks_from_string(names(se)) se } diff --git a/tests/testthat/test-rank_deficienty.R b/tests/testthat/test-rank_deficienty.R index 4234d7fc6..ade83e5d8 100644 --- a/tests/testthat/test-rank_deficienty.R +++ b/tests/testthat/test-rank_deficienty.R @@ -8,7 +8,7 @@ model <- test_that("model_parameters-rank_deficiency", { expect_message(model_parameters(model)) - params <- suppressMessages(model_parameters(model)) + params <- suppressWarnings(suppressMessages(model_parameters(model))) expect_equal(params$Parameter, c("(Intercept)", "am", "cyl", "vs", "am:cyl", "am:vs"), tolerance = 1e-3) expect_equal(params$Coefficient, c(2.28908, -1.37908, 0.22688, -0.26158, 0.08062, 0.14987), tolerance = 1e-3) }) From 0e4c87f224959397231aaa69adf2fe4c0d21caf8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 15:17:00 +0200 Subject: [PATCH 05/18] fix --- R/methods_mice.R | 44 +++++++++++++++--------------------- man/ci.default.Rd | 7 +++--- man/model_parameters.mira.Rd | 44 ++++++++++++++++-------------------- man/p_value.Rd | 7 +++--- 4 files changed, 43 insertions(+), 59 deletions(-) diff --git a/R/methods_mice.R b/R/methods_mice.R index cdf326399..3d77df0c2 100644 --- a/R/methods_mice.R +++ b/R/methods_mice.R @@ -140,41 +140,33 @@ model_parameters.mipo <- function(model, #' similar to `summary(mice::pool())`, i.e. it generates the pooled summary #' of multiple imputed repeated regression analyses. #' -#' @examples +#' @examplesIf require("mice", quietly = TRUE) && require("gee", quietly = TRUE) #' library(parameters) -#' if (require("mice", quietly = TRUE)) { -#' data(nhanes2) -#' imp <- mice(nhanes2) -#' fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) -#' model_parameters(fit) -#' } +#' data(nhanes2, package = "mice") +#' imp <- mice::mice(nhanes2) +#' fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) +#' model_parameters(fit) #' \donttest{ #' # model_parameters() also works for models that have no "tidy"-method in mice -#' if (require("mice", quietly = TRUE) && require("gee", quietly = TRUE)) { -#' data(warpbreaks) -#' set.seed(1234) -#' warpbreaks$tension[sample(1:nrow(warpbreaks), size = 10)] <- NA -#' imp <- mice(warpbreaks) -#' fit <- with(data = imp, expr = gee(breaks ~ tension, id = wool)) +#' data(warpbreaks, package = "gee") +#' set.seed(1234) +#' warpbreaks$tension[sample(1:nrow(warpbreaks), size = 10)] <- NA +#' imp <- mice::mice(warpbreaks) +#' fit <- with(data = imp, expr = gee::gee(breaks ~ tension, id = wool)) #' -#' # does not work: -#' # summary(pool(fit)) +#' # does not work: +#' # summary(mice::pool(fit)) #' -#' model_parameters(fit) -#' } +#' model_parameters(fit) #' } #' -#' -#' #' # and it works with pooled results -#' if (require("mice")) { -#' data("nhanes2") -#' imp <- mice(nhanes2) -#' fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) -#' pooled <- pool(fit) +#' data("nhanes2", package = "mice") +#' imp <- mice::mice(nhanes2) +#' fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) +#' pooled <- mice::pool(fit) #' -#' model_parameters(pooled) -#' } +#' model_parameters(pooled) #' @export model_parameters.mira <- function(model, ci = 0.95, diff --git a/man/ci.default.Rd b/man/ci.default.Rd index 57ffe3539..2e86093f1 100644 --- a/man/ci.default.Rd +++ b/man/ci.default.Rd @@ -27,10 +27,9 @@ \item{dof}{Number of degrees of freedom to be used when calculating confidence intervals. If \code{NULL} (default), the degrees of freedom are -retrieved by calling \code{\link[=degrees_of_freedom]{degrees_of_freedom()}} with -approximation method defined in \code{method}. If not \code{NULL}, use this argument -to override the default degrees of freedom used to compute confidence -intervals.} +retrieved by calling \code{\link[insight:get_df]{insight::get_df()}} with approximation method +defined in \code{method}. If not \code{NULL}, use this argument to override the +default degrees of freedom used to compute confidence intervals.} \item{method}{Method for computing degrees of freedom for confidence intervals (CI) and the related p-values. Allowed are following diff --git a/man/model_parameters.mira.Rd b/man/model_parameters.mira.Rd index 323886aa8..2a56061fb 100644 --- a/man/model_parameters.mira.Rd +++ b/man/model_parameters.mira.Rd @@ -87,38 +87,32 @@ similar to \code{summary(mice::pool())}, i.e. it generates the pooled summary of multiple imputed repeated regression analyses. } \examples{ +\dontshow{if (require("mice", quietly = TRUE) && require("gee", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} library(parameters) -if (require("mice", quietly = TRUE)) { - data(nhanes2) - imp <- mice(nhanes2) - fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) - model_parameters(fit) -} +data(nhanes2, package = "mice") +imp <- mice::mice(nhanes2) +fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) +model_parameters(fit) \donttest{ # model_parameters() also works for models that have no "tidy"-method in mice -if (require("mice", quietly = TRUE) && require("gee", quietly = TRUE)) { - data(warpbreaks) - set.seed(1234) - warpbreaks$tension[sample(1:nrow(warpbreaks), size = 10)] <- NA - imp <- mice(warpbreaks) - fit <- with(data = imp, expr = gee(breaks ~ tension, id = wool)) +data(warpbreaks, package = "gee") +set.seed(1234) +warpbreaks$tension[sample(1:nrow(warpbreaks), size = 10)] <- NA +imp <- mice::mice(warpbreaks) +fit <- with(data = imp, expr = gee::gee(breaks ~ tension, id = wool)) - # does not work: - # summary(pool(fit)) +# does not work: +# summary(mice::pool(fit)) - model_parameters(fit) -} +model_parameters(fit) } - - # and it works with pooled results -if (require("mice")) { - data("nhanes2") - imp <- mice(nhanes2) - fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) - pooled <- pool(fit) +data("nhanes2", package = "mice") +imp <- mice::mice(nhanes2) +fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) +pooled <- mice::pool(fit) - model_parameters(pooled) -} +model_parameters(pooled) +\dontshow{\}) # examplesIf} } diff --git a/man/p_value.Rd b/man/p_value.Rd index c0af41e07..d49b0390b 100644 --- a/man/p_value.Rd +++ b/man/p_value.Rd @@ -28,10 +28,9 @@ p_value(model, ...) \item{dof}{Number of degrees of freedom to be used when calculating confidence intervals. If \code{NULL} (default), the degrees of freedom are -retrieved by calling \code{\link[=degrees_of_freedom]{degrees_of_freedom()}} with -approximation method defined in \code{method}. If not \code{NULL}, use this argument -to override the default degrees of freedom used to compute confidence -intervals.} +retrieved by calling \code{\link[insight:get_df]{insight::get_df()}} with approximation method +defined in \code{method}. If not \code{NULL}, use this argument to override the +default degrees of freedom used to compute confidence intervals.} \item{method}{Method for computing degrees of freedom for confidence intervals (CI) and the related p-values. Allowed are following From 86d62e781353d482c0919bcef04fb726444b59d3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 15:22:59 +0200 Subject: [PATCH 06/18] fix --- R/equivalence_test.R | 2 +- R/extract_parameters.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/equivalence_test.R b/R/equivalence_test.R index 754dbdb42..0fab558d0 100644 --- a/R/equivalence_test.R +++ b/R/equivalence_test.R @@ -674,7 +674,7 @@ equivalence_test.ggeffects <- function(x, params <- insight::get_parameters(model) # degrees of freedom - dof <- insight::get_df(x = model, type = "residual") + dof <- insight::get_df(x = model, type = "wald") # mu params$mu <- params$Estimate * -1 diff --git a/R/extract_parameters.R b/R/extract_parameters.R index 05fb66751..75872772d 100644 --- a/R/extract_parameters.R +++ b/R/extract_parameters.R @@ -186,7 +186,7 @@ # ==== degrees of freedom if (is.null(ci_method)) { - df_error <- insight::get_df(x = model, type = "residual", verbose = FALSE) + df_error <- insight::get_df(x = model, type = "wald", verbose = FALSE) } else { df_error <- insight::get_df(x = model, type = ci_method, verbose = FALSE) } @@ -565,7 +565,7 @@ if (!ci_method %in% special_ci_methods) { df_error <- data.frame( Parameter = parameters$Parameter, - df_error = insight::get_df(x = model, type = "residual"), + df_error = insight::get_df(x = model, type = "wald"), stringsAsFactors = FALSE ) } From f616c6b01cc7311478e4667cd660aba639298b0c Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 15:29:05 +0200 Subject: [PATCH 07/18] fix examples --- R/methods_mice.R | 2 +- man/model_parameters.mira.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/methods_mice.R b/R/methods_mice.R index 3d77df0c2..93b25ddfd 100644 --- a/R/methods_mice.R +++ b/R/methods_mice.R @@ -148,7 +148,7 @@ model_parameters.mipo <- function(model, #' model_parameters(fit) #' \donttest{ #' # model_parameters() also works for models that have no "tidy"-method in mice -#' data(warpbreaks, package = "gee") +#' data(warpbreaks) #' set.seed(1234) #' warpbreaks$tension[sample(1:nrow(warpbreaks), size = 10)] <- NA #' imp <- mice::mice(warpbreaks) diff --git a/man/model_parameters.mira.Rd b/man/model_parameters.mira.Rd index 2a56061fb..5b379f152 100644 --- a/man/model_parameters.mira.Rd +++ b/man/model_parameters.mira.Rd @@ -95,7 +95,7 @@ fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) model_parameters(fit) \donttest{ # model_parameters() also works for models that have no "tidy"-method in mice -data(warpbreaks, package = "gee") +data(warpbreaks) set.seed(1234) warpbreaks$tension[sample(1:nrow(warpbreaks), size = 10)] <- NA imp <- mice::mice(warpbreaks) From d9961e9a159515358a047ae823418888a4e98c48 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 15:47:02 +0200 Subject: [PATCH 08/18] reduce warnings --- tests/testthat/test-compare_parameters.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-compare_parameters.R b/tests/testthat/test-compare_parameters.R index ce299dc56..029f0cf29 100644 --- a/tests/testthat/test-compare_parameters.R +++ b/tests/testthat/test-compare_parameters.R @@ -96,7 +96,7 @@ withr::with_options( test_that("compare_parameters, correct random effects", { - skip_if_not_installed("glmmTMB") + suppressWarnings(skip_if_not_installed("glmmTMB")) skip_if_not(getRversion() >= "4.0.0") data("fish") From 225e1d4594dfd4099689c05f1589ab5eda195e87 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 15:50:02 +0200 Subject: [PATCH 09/18] fix --- tests/testthat/test-bootstrap_emmeans.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-bootstrap_emmeans.R b/tests/testthat/test-bootstrap_emmeans.R index 3036c1a91..b1b8dd3fa 100644 --- a/tests/testthat/test-bootstrap_emmeans.R +++ b/tests/testthat/test-bootstrap_emmeans.R @@ -65,7 +65,7 @@ test_that("emmeans | glmmTMB", { skip_if_not_installed("emmeans") skip_if_not_installed("boot") skip_if_not_installed("lme4") - skip_if_not_installed("glmmTMB") + suppressWarnings(skip_if_not_installed("glmmTMB")) data(Salamanders, package = "glmmTMB") model <- glmmTMB::glmmTMB(count ~ spp + mined + (1 | site), family = glmmTMB::nbinom2, data = Salamanders) From 1b40884ba31a7d21d9b5772edb97b5ccbf455725 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 17:45:03 +0200 Subject: [PATCH 10/18] try... --- R/extract_parameters.R | 2 +- R/methods_flexsurvreg.R | 2 +- R/methods_gee.R | 4 ++-- R/methods_glmgee.R | 2 +- R/methods_lm.R | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/extract_parameters.R b/R/extract_parameters.R index 75872772d..473036b2d 100644 --- a/R/extract_parameters.R +++ b/R/extract_parameters.R @@ -451,7 +451,7 @@ # Degrees of freedom if (.dof_method_ok(model, ci_method)) { - dof <- degrees_of_freedom(model, method = ci_method, verbose = FALSE) + dof <- insight::get_df(x = model, type = ci_method, verbose = FALSE) } else { dof <- Inf } diff --git a/R/methods_flexsurvreg.R b/R/methods_flexsurvreg.R index 8cf8c9113..c213abec4 100644 --- a/R/methods_flexsurvreg.R +++ b/R/methods_flexsurvreg.R @@ -17,7 +17,7 @@ p_value.flexsurvreg <- function(model, ...) { params <- insight::get_parameters(model) est <- params$Estimate se <- standard_error(model)$SE - p <- 2 * stats::pt(abs(est / se), df = degrees_of_freedom(model, method = "any"), lower.tail = FALSE) + p <- 2 * stats::pt(abs(est / se), df = insight::get_df(x = model, type = "wald"), lower.tail = FALSE) .data_frame( Parameter = params$Parameter, p = as.vector(p) diff --git a/R/methods_gee.R b/R/methods_gee.R index cc0723edc..3b173b8f9 100644 --- a/R/methods_gee.R +++ b/R/methods_gee.R @@ -26,13 +26,13 @@ p_value.gee <- function(model, method = NULL, ...) { if (isTRUE(list(...)$robust) || "vcov" %in% names(list(...))) { p <- 2 * stats::pt( abs(cs[, "Estimate"] / cs[, "Robust S.E."]), - df = degrees_of_freedom(model, method = method), + df = insight::get_df(x = model, type = method), lower.tail = FALSE ) } else { p <- 2 * stats::pt( abs(cs[, "Estimate"] / cs[, "Naive S.E."]), - df = degrees_of_freedom(model, method = method), + df = insight::get_df(x = model, type = method), lower.tail = FALSE ) } diff --git a/R/methods_glmgee.R b/R/methods_glmgee.R index 2d3bde52f..22f08a543 100644 --- a/R/methods_glmgee.R +++ b/R/methods_glmgee.R @@ -28,7 +28,7 @@ p_value.glmgee <- function(model, p <- 2 * stats::pt( abs(est$Estimate / se$SE), - df = degrees_of_freedom(model, method = method), + df = insight::get_df(x = model, type = method), lower.tail = FALSE ) diff --git a/R/methods_lm.R b/R/methods_lm.R index 800776144..a52ad3d87 100644 --- a/R/methods_lm.R +++ b/R/methods_lm.R @@ -45,7 +45,7 @@ p_value.summary.lm <- function(model, ...) { #' @export ci.summary.lm <- function(x, ci = 0.95, method = "residual", ...) { - .ci_generic(model = x, ci = ci, method = method, dof = degrees_of_freedom(x), ...) + .ci_generic(model = x, ci = ci, method = method, dof = insight::get_df(x), ...) } From cc8b28db14164ba8f5ac50c4ecf33fe0630eaceb Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 17:50:39 +0200 Subject: [PATCH 11/18] fix --- R/methods_glmgee.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/methods_glmgee.R b/R/methods_glmgee.R index 22f08a543..82b8e5b58 100644 --- a/R/methods_glmgee.R +++ b/R/methods_glmgee.R @@ -26,6 +26,10 @@ p_value.glmgee <- function(model, est <- insight::get_parameters(model, component = "conditional") se <- standard_error(model, vcov = vcov, verbose = FALSE) + if (is.null(method)) { + method <- "wald" + } + p <- 2 * stats::pt( abs(est$Estimate / se$SE), df = insight::get_df(x = model, type = method), From 2d42c70e60d95546720b47a276fb7bb49601b406 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 17:53:48 +0200 Subject: [PATCH 12/18] add test --- DESCRIPTION | 1 + tests/testthat/test-model_parameters.glmgee.R | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/testthat/test-model_parameters.glmgee.R diff --git a/DESCRIPTION b/DESCRIPTION index 834ede363..395016582 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -134,6 +134,7 @@ Suggests: ggplot2, GLMMadaptive, glmmTMB, + glmtoolbox, GPArotation, gt, haven, diff --git a/tests/testthat/test-model_parameters.glmgee.R b/tests/testthat/test-model_parameters.glmgee.R new file mode 100644 index 000000000..84d8d5cba --- /dev/null +++ b/tests/testthat/test-model_parameters.glmgee.R @@ -0,0 +1,15 @@ +skip_on_cran() +skip_if_not_installed("glmtoolbox") + +test_that("model_parameters.glmgee", { + data(spruces, package = "glmtoolbox") + fit1 <- glmtoolbox::glmgee( + size ~ poly(days,4) + treat, + id = tree, + family = Gamma("log"), + corstr = "AR-M-dependent(1)", + data = spruces + ) + out <- model_parameters(fit1) + expect_snapshot(out, variant = "windows") +}) From fef7a1ac56c0a46c5a7d2111b56d27785d381051 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 17:57:49 +0200 Subject: [PATCH 13/18] styler --- tests/testthat/test-model_parameters.glmgee.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-model_parameters.glmgee.R b/tests/testthat/test-model_parameters.glmgee.R index 84d8d5cba..f87435d1d 100644 --- a/tests/testthat/test-model_parameters.glmgee.R +++ b/tests/testthat/test-model_parameters.glmgee.R @@ -4,7 +4,7 @@ skip_if_not_installed("glmtoolbox") test_that("model_parameters.glmgee", { data(spruces, package = "glmtoolbox") fit1 <- glmtoolbox::glmgee( - size ~ poly(days,4) + treat, + size ~ poly(days, 4) + treat, id = tree, family = Gamma("log"), corstr = "AR-M-dependent(1)", From a21e9482eb2d0dfe38c0a6bcb9e2a83581752471 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 18:00:05 +0200 Subject: [PATCH 14/18] snapshot --- .../_snaps/windows/model_parameters.glmgee.md | 23 +++++++++++++++++++ .../windows/model_parameters.glmgee.new.md | 20 ++++++++++++++++ tests/testthat/test-model_parameters.glmgee.R | 2 +- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/_snaps/windows/model_parameters.glmgee.md create mode 100644 tests/testthat/_snaps/windows/model_parameters.glmgee.new.md diff --git a/tests/testthat/_snaps/windows/model_parameters.glmgee.md b/tests/testthat/_snaps/windows/model_parameters.glmgee.md new file mode 100644 index 000000000..323301a6a --- /dev/null +++ b/tests/testthat/_snaps/windows/model_parameters.glmgee.md @@ -0,0 +1,23 @@ +# model_parameters.glmgee + + Code + out + Output + # Fixed Effects + + Parameter | Log-Prevalence | SE | 95% CI | z | p + --------------------------------------------------------------------------------- + (Intercept) | 5.90 | 0.10 | [ 5.70, 6.11] | 56.30 | < .001 + days [1st degree] | 19.20 | 0.52 | [18.18, 20.22] | 37.03 | < .001 + days [2nd degree] | -2.86 | 0.21 | [-3.26, -2.45] | -13.88 | < .001 + days [3rd degree] | 5.42 | 0.18 | [ 5.06, 5.77] | 29.69 | < .001 + days [4th degree] | -3.57 | 0.12 | [-3.82, -3.33] | -28.64 | < .001 + treat [ozone-enriched] | -0.26 | 0.13 | [-0.51, -0.01] | -2.01 | 0.044 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + + The model has a log- or logit-link. Consider using `exponentiate = + TRUE` to interpret coefficients as ratios. + diff --git a/tests/testthat/_snaps/windows/model_parameters.glmgee.new.md b/tests/testthat/_snaps/windows/model_parameters.glmgee.new.md new file mode 100644 index 000000000..da1e47fb8 --- /dev/null +++ b/tests/testthat/_snaps/windows/model_parameters.glmgee.new.md @@ -0,0 +1,20 @@ +# model_parameters.glmgee + + Code + print(out) + Output + # Fixed Effects + + Parameter | Log-Prevalence | SE | 95% CI | z | p + --------------------------------------------------------------------------------- + (Intercept) | 5.90 | 0.10 | [ 5.70, 6.11] | 56.30 | < .001 + days [1st degree] | 19.20 | 0.52 | [18.18, 20.22] | 37.03 | < .001 + days [2nd degree] | -2.86 | 0.21 | [-3.26, -2.45] | -13.88 | < .001 + days [3rd degree] | 5.42 | 0.18 | [ 5.06, 5.77] | 29.69 | < .001 + days [4th degree] | -3.57 | 0.12 | [-3.82, -3.33] | -28.64 | < .001 + treat [ozone-enriched] | -0.26 | 0.13 | [-0.51, -0.01] | -2.01 | 0.044 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/test-model_parameters.glmgee.R b/tests/testthat/test-model_parameters.glmgee.R index f87435d1d..2cffb7229 100644 --- a/tests/testthat/test-model_parameters.glmgee.R +++ b/tests/testthat/test-model_parameters.glmgee.R @@ -11,5 +11,5 @@ test_that("model_parameters.glmgee", { data = spruces ) out <- model_parameters(fit1) - expect_snapshot(out, variant = "windows") + expect_snapshot(print(out), variant = "windows") }) From 0c64594b8ca14a549692eedb993fef9cc69c005d Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 18:01:29 +0200 Subject: [PATCH 15/18] update snapshots --- .../_snaps/windows/model_parameters.glmgee.md | 2 +- .../windows/model_parameters.glmgee.new.md | 20 ------------------- 2 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 tests/testthat/_snaps/windows/model_parameters.glmgee.new.md diff --git a/tests/testthat/_snaps/windows/model_parameters.glmgee.md b/tests/testthat/_snaps/windows/model_parameters.glmgee.md index 323301a6a..1b034dadb 100644 --- a/tests/testthat/_snaps/windows/model_parameters.glmgee.md +++ b/tests/testthat/_snaps/windows/model_parameters.glmgee.md @@ -1,7 +1,7 @@ # model_parameters.glmgee Code - out + print(out) Output # Fixed Effects diff --git a/tests/testthat/_snaps/windows/model_parameters.glmgee.new.md b/tests/testthat/_snaps/windows/model_parameters.glmgee.new.md deleted file mode 100644 index da1e47fb8..000000000 --- a/tests/testthat/_snaps/windows/model_parameters.glmgee.new.md +++ /dev/null @@ -1,20 +0,0 @@ -# model_parameters.glmgee - - Code - print(out) - Output - # Fixed Effects - - Parameter | Log-Prevalence | SE | 95% CI | z | p - --------------------------------------------------------------------------------- - (Intercept) | 5.90 | 0.10 | [ 5.70, 6.11] | 56.30 | < .001 - days [1st degree] | 19.20 | 0.52 | [18.18, 20.22] | 37.03 | < .001 - days [2nd degree] | -2.86 | 0.21 | [-3.26, -2.45] | -13.88 | < .001 - days [3rd degree] | 5.42 | 0.18 | [ 5.06, 5.77] | 29.69 | < .001 - days [4th degree] | -3.57 | 0.12 | [-3.82, -3.33] | -28.64 | < .001 - treat [ozone-enriched] | -0.26 | 0.13 | [-0.51, -0.01] | -2.01 | 0.044 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - From d88446f2e36beb0b7eccf41f26f16af2a87054c1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 18:04:30 +0200 Subject: [PATCH 16/18] trigger CI --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 395016582..dc45cab66 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.22.1.2 +Version: 0.22.1.3 Authors@R: c(person(given = "Daniel", family = "Lüdecke", From 72f4983b612d46fac3518362c202f582f9ce9864 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 18:18:21 +0200 Subject: [PATCH 17/18] trigger CI --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index dc45cab66..43a45c612 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.22.1.3 +Version: 0.22.1.4 Authors@R: c(person(given = "Daniel", family = "Lüdecke", From fd52b7b102244423767f73f8de9e5b6e15adeabf Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Jul 2024 22:26:41 +0200 Subject: [PATCH 18/18] update snapshot --- .../{windows => }/model_parameters.glmgee.md | 3 -- tests/testthat/test-model_parameters.glmgee.R | 28 +++++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) rename tests/testthat/_snaps/{windows => }/model_parameters.glmgee.md (87%) diff --git a/tests/testthat/_snaps/windows/model_parameters.glmgee.md b/tests/testthat/_snaps/model_parameters.glmgee.md similarity index 87% rename from tests/testthat/_snaps/windows/model_parameters.glmgee.md rename to tests/testthat/_snaps/model_parameters.glmgee.md index 1b034dadb..da1e47fb8 100644 --- a/tests/testthat/_snaps/windows/model_parameters.glmgee.md +++ b/tests/testthat/_snaps/model_parameters.glmgee.md @@ -17,7 +17,4 @@ Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed using a Wald z-distribution approximation. - - The model has a log- or logit-link. Consider using `exponentiate = - TRUE` to interpret coefficients as ratios. diff --git a/tests/testthat/test-model_parameters.glmgee.R b/tests/testthat/test-model_parameters.glmgee.R index 2cffb7229..8f9ec5607 100644 --- a/tests/testthat/test-model_parameters.glmgee.R +++ b/tests/testthat/test-model_parameters.glmgee.R @@ -1,15 +1,19 @@ skip_on_cran() skip_if_not_installed("glmtoolbox") +skip_if_not_installed("withr") -test_that("model_parameters.glmgee", { - data(spruces, package = "glmtoolbox") - fit1 <- glmtoolbox::glmgee( - size ~ poly(days, 4) + treat, - id = tree, - family = Gamma("log"), - corstr = "AR-M-dependent(1)", - data = spruces - ) - out <- model_parameters(fit1) - expect_snapshot(print(out), variant = "windows") -}) +withr::with_options( + list(parameters_exponentiate = FALSE), + test_that("model_parameters.glmgee", { + data(spruces, package = "glmtoolbox") + fit1 <- glmtoolbox::glmgee( + size ~ poly(days, 4) + treat, + id = tree, + family = Gamma("log"), + corstr = "AR-M-dependent(1)", + data = spruces + ) + out <- model_parameters(fit1) + expect_snapshot(print(out)) + }) +)